clang 10.0.0git

Namespaces | Typedefs | Enumerations | Functions
RegionStore.cpp File Reference
`#include "clang/AST/Attr.h"`
`#include "clang/AST/CharUnits.h"`
`#include "clang/ASTMatchers/ASTMatchFinder.h"`
`#include "clang/Analysis/Analyses/LiveVariables.h"`
`#include "clang/Analysis/AnalysisDeclContext.h"`
`#include "clang/Basic/JsonSupport.h"`
`#include "clang/Basic/TargetInfo.h"`
`#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"`
`#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"`
`#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"`
`#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"`
`#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"`
`#include "clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h"`
`#include "llvm/ADT/ImmutableMap.h"`
`#include "llvm/ADT/Optional.h"`
`#include "llvm/Support/raw_ostream.h"`
`#include <utility>`
Include dependency graph for RegionStore.cpp:

Go to the source code of this file.

## Namespaces
| llvm
| Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion.

## Typedefs
typedef llvm::ImmutableMap< BindingKey, SVal > | ClusterBindings
typedef llvm::ImmutableMapRef< BindingKey, SVal > | ClusterBindingsRef
typedef std::pair< BindingKey, SVal > | BindingPair
typedef llvm::ImmutableMap< const MemRegion *, ClusterBindings > | RegionBindings
typedef const RegionBindingsRef & | RegionBindingsConstRef
typedef SmallVector< const FieldDecl *, 8 > | FieldVector

## Enumerations
enum | GlobalsFilterKind
| Used to determine which global regions are automatically included in the initial worklist of a ClusterAnalysis. More...

## Functions
static raw_ostream & | llvm::operator<< (raw_ostream &Out, BindingKey K)
static bool | isUnionField (const FieldRegion *FR)
static void | getSymbolicOffsetFields (BindingKey K, FieldVector &Fields)
static bool | isCompatibleWithFields (BindingKey K, const FieldVector &Fields)
static void | collectSubRegionBindings (SmallVectorImpl< BindingPair > &Bindings, SValBuilder &SVB, const ClusterBindings &Cluster, const SubRegion *Top, BindingKey TopKey, bool IncludeAllDefaultBindings)
| Collects all bindings in `Cluster` that may refer to bindings within `Top`. More...
static void | collectSubRegionBindings (SmallVectorImpl< BindingPair > &Bindings, SValBuilder &SVB, const ClusterBindings &Cluster, const SubRegion *Top, bool IncludeAllDefaultBindings)
static QualType | getUnderlyingType (const SubRegion *R)
static Optional< nonloc::LazyCompoundVal > | getExistingLazyBinding (SValBuilder &SVB, RegionBindingsConstRef B, const SubRegion *R, bool AllowSubregionBindings)
| Checks to see if store `B` has a lazy binding for region `R`. More...
static bool | isRecordEmpty (const RecordDecl *RD)

## Typedef Documentation

## ◆ BindingPair

typedef std::pair<BindingKey, SVal> BindingPair

Definition at line 148 of file RegionStore.cpp.

## ◆ ClusterBindings

typedef llvm::ImmutableMap<BindingKey, SVal> ClusterBindings

Definition at line 146 of file RegionStore.cpp.

## ◆ ClusterBindingsRef

typedef llvm::ImmutableMapRef<BindingKey, SVal> ClusterBindingsRef

Definition at line 147 of file RegionStore.cpp.

## ◆ FieldVector

typedef SmallVector<const FieldDecl *, 8> FieldVector

Definition at line 820 of file RegionStore.cpp.

## ◆ RegionBindings

typedef llvm::ImmutableMap<const MemRegion *, ClusterBindings> RegionBindings

Definition at line 151 of file RegionStore.cpp.

## ◆ RegionBindingsConstRef

typedef const RegionBindingsRef& RegionBindingsConstRef

Definition at line 263 of file RegionStore.cpp.

## Enumeration Type Documentation

## ◆ GlobalsFilterKind

enum GlobalsFilterKind

Used to determine which global regions are automatically included in the initial worklist of a ClusterAnalysis.

Definition at line 696 of file RegionStore.cpp.

## Function Documentation

## ◆ collectSubRegionBindings() [1/2]

static void collectSubRegionBindings | ( | SmallVectorImpl< BindingPair > & | Bindings,
|  | SValBuilder & | SVB,
|  | const ClusterBindings & | Cluster,
|  | const SubRegion * | Top,
|  | BindingKey | TopKey,
|  | bool | IncludeAllDefaultBindings
| ) |  |
| static

Collects all bindings in `Cluster` that may refer to bindings within `Top`.

Each binding is a pair whose `first` is the key (a BindingKey) and whose `second` is the value (an SVal).

The `IncludeAllDefaultBindings` parameter specifies whether to include default bindings that may extend beyond `Top` itself, e.g. if `Top` is an aggregate within a larger aggregate with a default binding.

Definition at line 866 of file RegionStore.cpp.

References clang::Default, getSymbolicOffsetFields(), and clang::Make.

Referenced by collectSubRegionBindings(), and getExistingLazyBinding().

## ◆ collectSubRegionBindings() [2/2]

static void collectSubRegionBindings | ( | SmallVectorImpl< BindingPair > & | Bindings,
|  | SValBuilder & | SVB,
|  | const ClusterBindings & | Cluster,
|  | const SubRegion * | Top,
|  | bool | IncludeAllDefaultBindings
| ) |  |
| static

Definition at line 938 of file RegionStore.cpp.

References collectSubRegionBindings(), clang::ast_matchers::declRefExpr, clang::Default, clang::ast_matchers::hasDescendant, clang::Make, clang::ast_matchers::stmt, clang::ento::RegionAndSymbolInvalidationTraits::TK_DoNotInvalidateSuperRegion, clang::ento::RegionAndSymbolInvalidationTraits::TK_PreserveContents, and clang::ast_matchers::varDecl.

## ◆ getExistingLazyBinding()

static Optional<nonloc::LazyCompoundVal> getExistingLazyBinding | ( | SValBuilder & | SVB,
|  | RegionBindingsConstRef | B,
|  | const SubRegion * | R,
|  | bool | AllowSubregionBindings
| ) |  |
| static

Checks to see if store `B` has a lazy binding for region `R`.

If `AllowSubregionBindings` is `false`, a lazy binding will be rejected if there are additional bindings within `R`.

Note that unlike RegionStoreManager::findLazyBinding, this will not search for lazy bindings for super-regions of `R`.

Definition at line 1592 of file RegionStore.cpp.

References collectSubRegionBindings(), clang::VarDecl::getAnyInitializer(), clang::StringLiteral::getCodeUnit(), clang::FieldDecl::getInClassInitializer(), clang::StringLiteral::getLength(), clang::ValueDecl::getType(), getUnderlyingType(), clang::VarDecl::hasGlobalStorage(), clang::QualType::isConstQualified(), clang::QualType::isNull(), clang::Type::isScalarType(), clang::Type::isVoidPointerType(), and length().

## ◆ getSymbolicOffsetFields()

static void getSymbolicOffsetFields | ( | BindingKey | K,
|  | FieldVector & | Fields
| ) |  |
| static

Definition at line 822 of file RegionStore.cpp.

References isUnionField().

Referenced by collectSubRegionBindings(), and isCompatibleWithFields().

## ◆ getUnderlyingType()

static QualType getUnderlyingType | ( | const SubRegion * | R | ) |
| static

Definition at line 1573 of file RegionStore.cpp.

Referenced by clang::MacroQualifiedType::desugar(), clang::TypeOfType::desugar(), clang::TypedefNameDecl::getAnonDeclWithTypedefName(), getExistingLazyBinding(), clang::ASTContext::getTypeInfo(), clang::TypeOfTypeLoc::initializeLocal(), MarkUsedTemplateParameters(), and UnwrapTypeForDebugInfo().

## ◆ isCompatibleWithFields()

static bool isCompatibleWithFields | ( | BindingKey | K,
|  | const FieldVector & | Fields
| ) |  |
| static

Definition at line 837 of file RegionStore.cpp.

References getSymbolicOffsetFields().

## ◆ isRecordEmpty()

static bool isRecordEmpty | ( | const RecordDecl * | RD | ) |
| static

Definition at line 2102 of file RegionStore.cpp.

References clang::ento::SymbolManager::canSymbolicate(), clang::Type::castAs(), clang::Default, clang::RecordDecl::field_empty(), clang::RecordDecl::fields(), clang::Type::getAsCXXRecordDecl(), clang::RecordDecl::getDefinition(), clang::ArrayType::getElementType(), clang::VectorType::getElementType(), clang::VectorType::getNumElements(), clang::Type::getPointeeType(), clang::LocationContext::getStackFrame(), clang::Indent(), clang::Type::isAnyPointerType(), clang::Type::isArrayType(), clang::Type::isIntegralOrEnumerationType(), clang::ento::Loc::isLocType(), clang::Type::isReferenceType(), clang::Type::isScalarType(), clang::Type::isStructureOrClassType(), clang::Type::isUnionType(), clang::Type::isVectorType(), clang::Make, true, and V.

## ◆ isUnionField()

static bool isUnionField | ( | const FieldRegion * | FR | ) |
| inline static

Definition at line 816 of file RegionStore.cpp.

Referenced by getSymbolicOffsetFields().