forked from OSchip/llvm-project
[analyzer] Fix SVal/SymExpr/MemRegion class and enum names for consistency.
The purpose of these changes is to simplify introduction of definition files for the three hierarchies. 1. For every sub-class C of these classes, its kind in the relevant enumeration is changed to "CKind" (or C##Kind in preprocessor-ish terms), eg: MemRegionKind -> MemRegionValKind RegionValueKind -> SymbolRegionValueKind CastSymbolKind -> SymbolCastKind SymIntKind -> SymIntExprKind 2. MemSpaceRegion used to be inconsistently used as both an abstract base and a particular region. This region class is now an abstract base and no longer occupies GenericMemSpaceRegionKind. Instead, a new class, CodeSpaceRegion, is introduced for handling the unique use case for MemSpaceRegion as "the generic memory space" (when it represents a memory space that holds all executable code). 3. BEG_ prefixes in memory region kind ranges are renamed to BEGIN_ for consisitency with symbol kind ranges. 4. FunctionTextRegion and BlockTextRegion are renamed to FunctionCodeRegion and BlockCodeRegion, respectively. The term 'code' is less jargony than 'text' and we already refer to BlockTextRegion as a 'code region' in BlockDataRegion. Differential Revision: http://reviews.llvm.org/D16062 llvm-svn: 257598
This commit is contained in:
parent
46ff7ec317
commit
73f018e381
|
@ -80,7 +80,7 @@ class MemRegion : public llvm::FoldingSetNode {
|
|||
public:
|
||||
enum Kind {
|
||||
// Memory spaces.
|
||||
GenericMemSpaceRegionKind,
|
||||
CodeSpaceRegionKind,
|
||||
StackLocalsSpaceRegionKind,
|
||||
StackArgumentsSpaceRegionKind,
|
||||
HeapSpaceRegionKind,
|
||||
|
@ -89,29 +89,29 @@ public:
|
|||
GlobalInternalSpaceRegionKind,
|
||||
GlobalSystemSpaceRegionKind,
|
||||
GlobalImmutableSpaceRegionKind,
|
||||
BEG_NON_STATIC_GLOBAL_MEMSPACES = GlobalInternalSpaceRegionKind,
|
||||
BEGIN_NON_STATIC_GLOBAL_MEMSPACES = GlobalInternalSpaceRegionKind,
|
||||
END_NON_STATIC_GLOBAL_MEMSPACES = GlobalImmutableSpaceRegionKind,
|
||||
BEG_GLOBAL_MEMSPACES = StaticGlobalSpaceRegionKind,
|
||||
BEGIN_GLOBAL_MEMSPACES = StaticGlobalSpaceRegionKind,
|
||||
END_GLOBAL_MEMSPACES = GlobalImmutableSpaceRegionKind,
|
||||
BEG_MEMSPACES = GenericMemSpaceRegionKind,
|
||||
BEGIN_MEMSPACES = CodeSpaceRegionKind,
|
||||
END_MEMSPACES = GlobalImmutableSpaceRegionKind,
|
||||
// Untyped regions.
|
||||
SymbolicRegionKind,
|
||||
AllocaRegionKind,
|
||||
// Typed regions.
|
||||
BEG_TYPED_REGIONS,
|
||||
FunctionTextRegionKind = BEG_TYPED_REGIONS,
|
||||
BlockTextRegionKind,
|
||||
BEGIN_TYPED_REGIONS,
|
||||
FunctionCodeRegionKind = BEGIN_TYPED_REGIONS,
|
||||
BlockCodeRegionKind,
|
||||
BlockDataRegionKind,
|
||||
BEG_TYPED_VALUE_REGIONS,
|
||||
CompoundLiteralRegionKind = BEG_TYPED_VALUE_REGIONS,
|
||||
BEGIN_TYPED_VALUE_REGIONS,
|
||||
CompoundLiteralRegionKind = BEGIN_TYPED_VALUE_REGIONS,
|
||||
CXXThisRegionKind,
|
||||
StringRegionKind,
|
||||
ObjCStringRegionKind,
|
||||
ElementRegionKind,
|
||||
// Decl Regions.
|
||||
BEG_DECL_REGIONS,
|
||||
VarRegionKind = BEG_DECL_REGIONS,
|
||||
BEGIN_DECL_REGIONS,
|
||||
VarRegionKind = BEGIN_DECL_REGIONS,
|
||||
FieldRegionKind,
|
||||
ObjCIvarRegionKind,
|
||||
END_DECL_REGIONS = ObjCIvarRegionKind,
|
||||
|
@ -193,12 +193,9 @@ public:
|
|||
/// for example, the set of global variables, the stack frame, etc.
|
||||
class MemSpaceRegion : public MemRegion {
|
||||
protected:
|
||||
friend class MemRegionManager;
|
||||
|
||||
MemRegionManager *Mgr;
|
||||
|
||||
MemSpaceRegion(MemRegionManager *mgr, Kind k = GenericMemSpaceRegionKind)
|
||||
: MemRegion(k), Mgr(mgr) {
|
||||
MemSpaceRegion(MemRegionManager *mgr, Kind k) : MemRegion(k), Mgr(mgr) {
|
||||
assert(classof(this));
|
||||
}
|
||||
|
||||
|
@ -211,10 +208,26 @@ public:
|
|||
|
||||
static bool classof(const MemRegion *R) {
|
||||
Kind k = R->getKind();
|
||||
return k >= BEG_MEMSPACES && k <= END_MEMSPACES;
|
||||
return k >= BEGIN_MEMSPACES && k <= END_MEMSPACES;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// CodeSpaceRegion - The memory space that holds the executable code of
|
||||
/// functions and blocks.
|
||||
class CodeSpaceRegion : public MemSpaceRegion {
|
||||
friend class MemRegionManager;
|
||||
|
||||
CodeSpaceRegion(MemRegionManager *mgr)
|
||||
: MemSpaceRegion(mgr, CodeSpaceRegionKind) {}
|
||||
|
||||
public:
|
||||
void dumpToStream(raw_ostream &os) const override;
|
||||
|
||||
static bool classof(const MemRegion *R) {
|
||||
return R->getKind() == CodeSpaceRegionKind;
|
||||
}
|
||||
};
|
||||
|
||||
class GlobalsSpaceRegion : public MemSpaceRegion {
|
||||
virtual void anchor();
|
||||
protected:
|
||||
|
@ -223,7 +236,7 @@ protected:
|
|||
public:
|
||||
static bool classof(const MemRegion *R) {
|
||||
Kind k = R->getKind();
|
||||
return k >= BEG_GLOBAL_MEMSPACES && k <= END_GLOBAL_MEMSPACES;
|
||||
return k >= BEGIN_GLOBAL_MEMSPACES && k <= END_GLOBAL_MEMSPACES;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -259,17 +272,15 @@ public:
|
|||
/// RegionStoreManager::invalidateRegions (instead of finding all the dependent
|
||||
/// globals, we invalidate the whole parent region).
|
||||
class NonStaticGlobalSpaceRegion : public GlobalsSpaceRegion {
|
||||
friend class MemRegionManager;
|
||||
|
||||
protected:
|
||||
NonStaticGlobalSpaceRegion(MemRegionManager *mgr, Kind k)
|
||||
: GlobalsSpaceRegion(mgr, k) {}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
static bool classof(const MemRegion *R) {
|
||||
Kind k = R->getKind();
|
||||
return k >= BEG_NON_STATIC_GLOBAL_MEMSPACES &&
|
||||
return k >= BEGIN_NON_STATIC_GLOBAL_MEMSPACES &&
|
||||
k <= END_NON_STATIC_GLOBAL_MEMSPACES;
|
||||
}
|
||||
};
|
||||
|
@ -357,7 +368,7 @@ public:
|
|||
return R->getKind() == UnknownSpaceRegionKind;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class StackSpaceRegion : public MemSpaceRegion {
|
||||
private:
|
||||
const StackFrameContext *SFC;
|
||||
|
@ -368,18 +379,18 @@ protected:
|
|||
assert(classof(this));
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
const StackFrameContext *getStackFrame() const { return SFC; }
|
||||
|
||||
|
||||
void Profile(llvm::FoldingSetNodeID &ID) const override;
|
||||
|
||||
static bool classof(const MemRegion *R) {
|
||||
Kind k = R->getKind();
|
||||
return k >= StackLocalsSpaceRegionKind &&
|
||||
k <= StackArgumentsSpaceRegionKind;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class StackLocalsSpaceRegion : public StackSpaceRegion {
|
||||
virtual void anchor();
|
||||
friend class MemRegionManager;
|
||||
|
@ -491,7 +502,7 @@ public:
|
|||
|
||||
static bool classof(const MemRegion* R) {
|
||||
unsigned k = R->getKind();
|
||||
return k >= BEG_TYPED_REGIONS && k <= END_TYPED_REGIONS;
|
||||
return k >= BEGIN_TYPED_REGIONS && k <= END_TYPED_REGIONS;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -523,7 +534,7 @@ public:
|
|||
|
||||
static bool classof(const MemRegion* R) {
|
||||
unsigned k = R->getKind();
|
||||
return k >= BEG_TYPED_VALUE_REGIONS && k <= END_TYPED_VALUE_REGIONS;
|
||||
return k >= BEGIN_TYPED_VALUE_REGIONS && k <= END_TYPED_VALUE_REGIONS;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -538,16 +549,16 @@ public:
|
|||
|
||||
static bool classof(const MemRegion* R) {
|
||||
Kind k = R->getKind();
|
||||
return k >= FunctionTextRegionKind && k <= BlockTextRegionKind;
|
||||
return k >= FunctionCodeRegionKind && k <= BlockCodeRegionKind;
|
||||
}
|
||||
};
|
||||
|
||||
/// FunctionTextRegion - A region that represents code texts of function.
|
||||
class FunctionTextRegion : public CodeTextRegion {
|
||||
/// FunctionCodeRegion - A region that represents code texts of function.
|
||||
class FunctionCodeRegion : public CodeTextRegion {
|
||||
const NamedDecl *FD;
|
||||
public:
|
||||
FunctionTextRegion(const NamedDecl *fd, const MemRegion* sreg)
|
||||
: CodeTextRegion(sreg, FunctionTextRegionKind), FD(fd) {
|
||||
FunctionCodeRegion(const NamedDecl *fd, const MemRegion* sreg)
|
||||
: CodeTextRegion(sreg, FunctionCodeRegionKind), FD(fd) {
|
||||
assert(isa<ObjCMethodDecl>(fd) || isa<FunctionDecl>(fd));
|
||||
}
|
||||
|
||||
|
@ -577,27 +588,27 @@ public:
|
|||
const MemRegion*);
|
||||
|
||||
static bool classof(const MemRegion* R) {
|
||||
return R->getKind() == FunctionTextRegionKind;
|
||||
return R->getKind() == FunctionCodeRegionKind;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// BlockTextRegion - A region that represents code texts of blocks (closures).
|
||||
/// Blocks are represented with two kinds of regions. BlockTextRegions
|
||||
/// BlockCodeRegion - A region that represents code texts of blocks (closures).
|
||||
/// Blocks are represented with two kinds of regions. BlockCodeRegions
|
||||
/// represent the "code", while BlockDataRegions represent instances of blocks,
|
||||
/// which correspond to "code+data". The distinction is important, because
|
||||
/// like a closure a block captures the values of externally referenced
|
||||
/// variables.
|
||||
class BlockTextRegion : public CodeTextRegion {
|
||||
class BlockCodeRegion : public CodeTextRegion {
|
||||
friend class MemRegionManager;
|
||||
|
||||
const BlockDecl *BD;
|
||||
AnalysisDeclContext *AC;
|
||||
CanQualType locTy;
|
||||
|
||||
BlockTextRegion(const BlockDecl *bd, CanQualType lTy,
|
||||
BlockCodeRegion(const BlockDecl *bd, CanQualType lTy,
|
||||
AnalysisDeclContext *ac, const MemRegion* sreg)
|
||||
: CodeTextRegion(sreg, BlockTextRegionKind), BD(bd), AC(ac), locTy(lTy) {}
|
||||
: CodeTextRegion(sreg, BlockCodeRegionKind), BD(bd), AC(ac), locTy(lTy) {}
|
||||
|
||||
public:
|
||||
QualType getLocationType() const override {
|
||||
|
@ -619,32 +630,32 @@ public:
|
|||
const MemRegion*);
|
||||
|
||||
static bool classof(const MemRegion* R) {
|
||||
return R->getKind() == BlockTextRegionKind;
|
||||
return R->getKind() == BlockCodeRegionKind;
|
||||
}
|
||||
};
|
||||
|
||||
/// BlockDataRegion - A region that represents a block instance.
|
||||
/// Blocks are represented with two kinds of regions. BlockTextRegions
|
||||
/// Blocks are represented with two kinds of regions. BlockCodeRegions
|
||||
/// represent the "code", while BlockDataRegions represent instances of blocks,
|
||||
/// which correspond to "code+data". The distinction is important, because
|
||||
/// like a closure a block captures the values of externally referenced
|
||||
/// variables.
|
||||
class BlockDataRegion : public TypedRegion {
|
||||
friend class MemRegionManager;
|
||||
const BlockTextRegion *BC;
|
||||
const BlockCodeRegion *BC;
|
||||
const LocationContext *LC; // Can be null */
|
||||
unsigned BlockCount;
|
||||
void *ReferencedVars;
|
||||
void *OriginalVars;
|
||||
|
||||
BlockDataRegion(const BlockTextRegion *bc, const LocationContext *lc,
|
||||
BlockDataRegion(const BlockCodeRegion *bc, const LocationContext *lc,
|
||||
unsigned count, const MemRegion *sreg)
|
||||
: TypedRegion(sreg, BlockDataRegionKind), BC(bc), LC(lc),
|
||||
BlockCount(count),
|
||||
ReferencedVars(nullptr), OriginalVars(nullptr) {}
|
||||
|
||||
public:
|
||||
const BlockTextRegion *getCodeRegion() const { return BC; }
|
||||
const BlockCodeRegion *getCodeRegion() const { return BC; }
|
||||
|
||||
const BlockDecl *getDecl() const { return BC->getDecl(); }
|
||||
|
||||
|
@ -691,7 +702,7 @@ public:
|
|||
|
||||
void Profile(llvm::FoldingSetNodeID& ID) const override;
|
||||
|
||||
static void ProfileRegion(llvm::FoldingSetNodeID&, const BlockTextRegion *,
|
||||
static void ProfileRegion(llvm::FoldingSetNodeID&, const BlockCodeRegion *,
|
||||
const LocationContext *, unsigned,
|
||||
const MemRegion *);
|
||||
|
||||
|
@ -856,7 +867,7 @@ public:
|
|||
|
||||
static bool classof(const MemRegion* R) {
|
||||
unsigned k = R->getKind();
|
||||
return k >= BEG_DECL_REGIONS && k <= END_DECL_REGIONS;
|
||||
return k >= BEGIN_DECL_REGIONS && k <= END_DECL_REGIONS;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1138,7 +1149,7 @@ class MemRegionManager {
|
|||
|
||||
HeapSpaceRegion *heap;
|
||||
UnknownSpaceRegion *unknown;
|
||||
MemSpaceRegion *code;
|
||||
CodeSpaceRegion *code;
|
||||
|
||||
public:
|
||||
MemRegionManager(ASTContext &c, llvm::BumpPtrAllocator &a)
|
||||
|
@ -1174,9 +1185,9 @@ public:
|
|||
|
||||
/// getUnknownRegion - Retrieve the memory region associated with unknown
|
||||
/// memory space.
|
||||
const MemSpaceRegion *getUnknownRegion();
|
||||
const UnknownSpaceRegion *getUnknownRegion();
|
||||
|
||||
const MemSpaceRegion *getCodeRegion();
|
||||
const CodeSpaceRegion *getCodeRegion();
|
||||
|
||||
/// getAllocaRegion - Retrieve a region associated with a call to alloca().
|
||||
const AllocaRegion *getAllocaRegion(const Expr *Ex, unsigned Cnt,
|
||||
|
@ -1262,8 +1273,8 @@ public:
|
|||
baseReg->isVirtual());
|
||||
}
|
||||
|
||||
const FunctionTextRegion *getFunctionTextRegion(const NamedDecl *FD);
|
||||
const BlockTextRegion *getBlockTextRegion(const BlockDecl *BD,
|
||||
const FunctionCodeRegion *getFunctionCodeRegion(const NamedDecl *FD);
|
||||
const BlockCodeRegion *getBlockCodeRegion(const BlockDecl *BD,
|
||||
CanQualType locTy,
|
||||
AnalysisDeclContext *AC);
|
||||
|
||||
|
@ -1271,7 +1282,7 @@ public:
|
|||
/// of a block. Unlike many other MemRegions, the LocationContext*
|
||||
/// argument is allowed to be NULL for cases where we have no known
|
||||
/// context.
|
||||
const BlockDataRegion *getBlockDataRegion(const BlockTextRegion *bc,
|
||||
const BlockDataRegion *getBlockDataRegion(const BlockCodeRegion *bc,
|
||||
const LocationContext *lc,
|
||||
unsigned blockCount);
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ class SVal {
|
|||
public:
|
||||
enum BaseKind {
|
||||
// The enumerators must be representable using 2 bits.
|
||||
UndefinedKind = 0, // for subclass UndefinedVal (an uninitialized value)
|
||||
UnknownKind = 1, // for subclass UnknownVal (a void value)
|
||||
UndefinedValKind = 0, // for subclass UndefinedVal (an uninitialized value)
|
||||
UnknownValKind = 1, // for subclass UnknownVal (a void value)
|
||||
LocKind = 2, // for subclass Loc (an L-value)
|
||||
NonLocKind = 3 // for subclass NonLoc (an R-value that's not
|
||||
// an L-value)
|
||||
|
@ -115,19 +115,19 @@ public:
|
|||
}
|
||||
|
||||
inline bool isUnknown() const {
|
||||
return getRawKind() == UnknownKind;
|
||||
return getRawKind() == UnknownValKind;
|
||||
}
|
||||
|
||||
inline bool isUndef() const {
|
||||
return getRawKind() == UndefinedKind;
|
||||
return getRawKind() == UndefinedValKind;
|
||||
}
|
||||
|
||||
inline bool isUnknownOrUndef() const {
|
||||
return getRawKind() <= UnknownKind;
|
||||
return getRawKind() <= UnknownValKind;
|
||||
}
|
||||
|
||||
inline bool isValid() const {
|
||||
return getRawKind() > UnknownKind;
|
||||
return getRawKind() > UnknownValKind;
|
||||
}
|
||||
|
||||
bool isConstant() const;
|
||||
|
@ -190,12 +190,12 @@ public:
|
|||
|
||||
class UndefinedVal : public SVal {
|
||||
public:
|
||||
UndefinedVal() : SVal(UndefinedKind) {}
|
||||
UndefinedVal() : SVal(UndefinedValKind) {}
|
||||
|
||||
private:
|
||||
friend class SVal;
|
||||
static bool isKind(const SVal& V) {
|
||||
return V.getBaseKind() == UndefinedKind;
|
||||
return V.getBaseKind() == UndefinedValKind;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -223,12 +223,12 @@ private:
|
|||
|
||||
class UnknownVal : public DefinedOrUnknownSVal {
|
||||
public:
|
||||
explicit UnknownVal() : DefinedOrUnknownSVal(UnknownKind) {}
|
||||
explicit UnknownVal() : DefinedOrUnknownSVal(UnknownValKind) {}
|
||||
|
||||
private:
|
||||
friend class SVal;
|
||||
static bool isKind(const SVal &V) {
|
||||
return V.getBaseKind() == UnknownKind;
|
||||
return V.getBaseKind() == UnknownValKind;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -465,7 +465,7 @@ private:
|
|||
|
||||
namespace loc {
|
||||
|
||||
enum Kind { GotoLabelKind, MemRegionKind, ConcreteIntKind };
|
||||
enum Kind { GotoLabelKind, MemRegionValKind, ConcreteIntKind };
|
||||
|
||||
class GotoLabel : public Loc {
|
||||
public:
|
||||
|
@ -490,7 +490,7 @@ private:
|
|||
|
||||
class MemRegionVal : public Loc {
|
||||
public:
|
||||
explicit MemRegionVal(const MemRegion* r) : Loc(MemRegionKind, r) {}
|
||||
explicit MemRegionVal(const MemRegion* r) : Loc(MemRegionValKind, r) {}
|
||||
|
||||
/// \brief Get the underlining region.
|
||||
const MemRegion* getRegion() const {
|
||||
|
@ -518,11 +518,11 @@ private:
|
|||
MemRegionVal() {}
|
||||
static bool isKind(const SVal& V) {
|
||||
return V.getBaseKind() == LocKind &&
|
||||
V.getSubKind() == MemRegionKind;
|
||||
V.getSubKind() == MemRegionValKind;
|
||||
}
|
||||
|
||||
static bool isKind(const Loc& V) {
|
||||
return V.getSubKind() == MemRegionKind;
|
||||
return V.getSubKind() == MemRegionValKind;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -42,14 +42,22 @@ namespace ento {
|
|||
class SymExpr : public llvm::FoldingSetNode {
|
||||
virtual void anchor();
|
||||
public:
|
||||
enum Kind { RegionValueKind, ConjuredKind, DerivedKind, ExtentKind,
|
||||
MetadataKind,
|
||||
BEGIN_SYMBOLS = RegionValueKind,
|
||||
END_SYMBOLS = MetadataKind,
|
||||
SymIntKind, IntSymKind, SymSymKind,
|
||||
BEGIN_BINARYSYMEXPRS = SymIntKind,
|
||||
END_BINARYSYMEXPRS = SymSymKind,
|
||||
CastSymbolKind };
|
||||
enum Kind {
|
||||
SymbolRegionValueKind,
|
||||
SymbolConjuredKind,
|
||||
SymbolDerivedKind,
|
||||
SymbolExtentKind,
|
||||
SymbolMetadataKind,
|
||||
BEGIN_SYMBOLS = SymbolRegionValueKind,
|
||||
END_SYMBOLS = SymbolMetadataKind,
|
||||
SymIntExprKind,
|
||||
IntSymExprKind,
|
||||
SymSymExprKind,
|
||||
BEGIN_BINARYSYMEXPRS = SymIntExprKind,
|
||||
END_BINARYSYMEXPRS = SymSymExprKind,
|
||||
SymbolCastKind
|
||||
};
|
||||
|
||||
private:
|
||||
Kind K;
|
||||
|
||||
|
@ -126,12 +134,12 @@ class SymbolRegionValue : public SymbolData {
|
|||
|
||||
public:
|
||||
SymbolRegionValue(SymbolID sym, const TypedValueRegion *r)
|
||||
: SymbolData(RegionValueKind, sym), R(r) {}
|
||||
: SymbolData(SymbolRegionValueKind, sym), R(r) {}
|
||||
|
||||
const TypedValueRegion* getRegion() const { return R; }
|
||||
|
||||
static void Profile(llvm::FoldingSetNodeID& profile, const TypedValueRegion* R) {
|
||||
profile.AddInteger((unsigned) RegionValueKind);
|
||||
profile.AddInteger((unsigned) SymbolRegionValueKind);
|
||||
profile.AddPointer(R);
|
||||
}
|
||||
|
||||
|
@ -145,7 +153,7 @@ public:
|
|||
|
||||
// Implement isa<T> support.
|
||||
static inline bool classof(const SymExpr *SE) {
|
||||
return SE->getKind() == RegionValueKind;
|
||||
return SE->getKind() == SymbolRegionValueKind;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -160,11 +168,9 @@ class SymbolConjured : public SymbolData {
|
|||
|
||||
public:
|
||||
SymbolConjured(SymbolID sym, const Stmt *s, const LocationContext *lctx,
|
||||
QualType t, unsigned count,
|
||||
const void *symbolTag)
|
||||
: SymbolData(ConjuredKind, sym), S(s), T(t), Count(count),
|
||||
LCtx(lctx),
|
||||
SymbolTag(symbolTag) {}
|
||||
QualType t, unsigned count, const void *symbolTag)
|
||||
: SymbolData(SymbolConjuredKind, sym), S(s), T(t), Count(count),
|
||||
LCtx(lctx), SymbolTag(symbolTag) {}
|
||||
|
||||
const Stmt *getStmt() const { return S; }
|
||||
unsigned getCount() const { return Count; }
|
||||
|
@ -177,7 +183,7 @@ public:
|
|||
static void Profile(llvm::FoldingSetNodeID& profile, const Stmt *S,
|
||||
QualType T, unsigned Count, const LocationContext *LCtx,
|
||||
const void *SymbolTag) {
|
||||
profile.AddInteger((unsigned) ConjuredKind);
|
||||
profile.AddInteger((unsigned) SymbolConjuredKind);
|
||||
profile.AddPointer(S);
|
||||
profile.AddPointer(LCtx);
|
||||
profile.Add(T);
|
||||
|
@ -191,7 +197,7 @@ public:
|
|||
|
||||
// Implement isa<T> support.
|
||||
static inline bool classof(const SymExpr *SE) {
|
||||
return SE->getKind() == ConjuredKind;
|
||||
return SE->getKind() == SymbolConjuredKind;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -203,7 +209,7 @@ class SymbolDerived : public SymbolData {
|
|||
|
||||
public:
|
||||
SymbolDerived(SymbolID sym, SymbolRef parent, const TypedValueRegion *r)
|
||||
: SymbolData(DerivedKind, sym), parentSymbol(parent), R(r) {}
|
||||
: SymbolData(SymbolDerivedKind, sym), parentSymbol(parent), R(r) {}
|
||||
|
||||
SymbolRef getParentSymbol() const { return parentSymbol; }
|
||||
const TypedValueRegion *getRegion() const { return R; }
|
||||
|
@ -214,7 +220,7 @@ public:
|
|||
|
||||
static void Profile(llvm::FoldingSetNodeID& profile, SymbolRef parent,
|
||||
const TypedValueRegion *r) {
|
||||
profile.AddInteger((unsigned) DerivedKind);
|
||||
profile.AddInteger((unsigned) SymbolDerivedKind);
|
||||
profile.AddPointer(r);
|
||||
profile.AddPointer(parent);
|
||||
}
|
||||
|
@ -225,7 +231,7 @@ public:
|
|||
|
||||
// Implement isa<T> support.
|
||||
static inline bool classof(const SymExpr *SE) {
|
||||
return SE->getKind() == DerivedKind;
|
||||
return SE->getKind() == SymbolDerivedKind;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -237,7 +243,7 @@ class SymbolExtent : public SymbolData {
|
|||
|
||||
public:
|
||||
SymbolExtent(SymbolID sym, const SubRegion *r)
|
||||
: SymbolData(ExtentKind, sym), R(r) {}
|
||||
: SymbolData(SymbolExtentKind, sym), R(r) {}
|
||||
|
||||
const SubRegion *getRegion() const { return R; }
|
||||
|
||||
|
@ -246,7 +252,7 @@ public:
|
|||
void dumpToStream(raw_ostream &os) const override;
|
||||
|
||||
static void Profile(llvm::FoldingSetNodeID& profile, const SubRegion *R) {
|
||||
profile.AddInteger((unsigned) ExtentKind);
|
||||
profile.AddInteger((unsigned) SymbolExtentKind);
|
||||
profile.AddPointer(R);
|
||||
}
|
||||
|
||||
|
@ -256,7 +262,7 @@ public:
|
|||
|
||||
// Implement isa<T> support.
|
||||
static inline bool classof(const SymExpr *SE) {
|
||||
return SE->getKind() == ExtentKind;
|
||||
return SE->getKind() == SymbolExtentKind;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -273,7 +279,7 @@ class SymbolMetadata : public SymbolData {
|
|||
public:
|
||||
SymbolMetadata(SymbolID sym, const MemRegion* r, const Stmt *s, QualType t,
|
||||
unsigned count, const void *tag)
|
||||
: SymbolData(MetadataKind, sym), R(r), S(s), T(t), Count(count), Tag(tag) {}
|
||||
: SymbolData(SymbolMetadataKind, sym), R(r), S(s), T(t), Count(count), Tag(tag) {}
|
||||
|
||||
const MemRegion *getRegion() const { return R; }
|
||||
const Stmt *getStmt() const { return S; }
|
||||
|
@ -287,7 +293,7 @@ public:
|
|||
static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion *R,
|
||||
const Stmt *S, QualType T, unsigned Count,
|
||||
const void *Tag) {
|
||||
profile.AddInteger((unsigned) MetadataKind);
|
||||
profile.AddInteger((unsigned) SymbolMetadataKind);
|
||||
profile.AddPointer(R);
|
||||
profile.AddPointer(S);
|
||||
profile.Add(T);
|
||||
|
@ -301,7 +307,7 @@ public:
|
|||
|
||||
// Implement isa<T> support.
|
||||
static inline bool classof(const SymExpr *SE) {
|
||||
return SE->getKind() == MetadataKind;
|
||||
return SE->getKind() == SymbolMetadataKind;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -315,7 +321,7 @@ class SymbolCast : public SymExpr {
|
|||
|
||||
public:
|
||||
SymbolCast(const SymExpr *In, QualType From, QualType To) :
|
||||
SymExpr(CastSymbolKind), Operand(In), FromTy(From), ToTy(To) { }
|
||||
SymExpr(SymbolCastKind), Operand(In), FromTy(From), ToTy(To) { }
|
||||
|
||||
QualType getType() const override { return ToTy; }
|
||||
|
||||
|
@ -325,7 +331,7 @@ public:
|
|||
|
||||
static void Profile(llvm::FoldingSetNodeID& ID,
|
||||
const SymExpr *In, QualType From, QualType To) {
|
||||
ID.AddInteger((unsigned) CastSymbolKind);
|
||||
ID.AddInteger((unsigned) SymbolCastKind);
|
||||
ID.AddPointer(In);
|
||||
ID.Add(From);
|
||||
ID.Add(To);
|
||||
|
@ -337,7 +343,7 @@ public:
|
|||
|
||||
// Implement isa<T> support.
|
||||
static inline bool classof(const SymExpr *SE) {
|
||||
return SE->getKind() == CastSymbolKind;
|
||||
return SE->getKind() == SymbolCastKind;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -372,7 +378,7 @@ class SymIntExpr : public BinarySymExpr {
|
|||
public:
|
||||
SymIntExpr(const SymExpr *lhs, BinaryOperator::Opcode op,
|
||||
const llvm::APSInt& rhs, QualType t)
|
||||
: BinarySymExpr(SymIntKind, op, t), LHS(lhs), RHS(rhs) {}
|
||||
: BinarySymExpr(SymIntExprKind, op, t), LHS(lhs), RHS(rhs) {}
|
||||
|
||||
void dumpToStream(raw_ostream &os) const override;
|
||||
|
||||
|
@ -382,7 +388,7 @@ public:
|
|||
static void Profile(llvm::FoldingSetNodeID& ID, const SymExpr *lhs,
|
||||
BinaryOperator::Opcode op, const llvm::APSInt& rhs,
|
||||
QualType t) {
|
||||
ID.AddInteger((unsigned) SymIntKind);
|
||||
ID.AddInteger((unsigned) SymIntExprKind);
|
||||
ID.AddPointer(lhs);
|
||||
ID.AddInteger(op);
|
||||
ID.AddPointer(&rhs);
|
||||
|
@ -395,7 +401,7 @@ public:
|
|||
|
||||
// Implement isa<T> support.
|
||||
static inline bool classof(const SymExpr *SE) {
|
||||
return SE->getKind() == SymIntKind;
|
||||
return SE->getKind() == SymIntExprKind;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -407,7 +413,7 @@ class IntSymExpr : public BinarySymExpr {
|
|||
public:
|
||||
IntSymExpr(const llvm::APSInt& lhs, BinaryOperator::Opcode op,
|
||||
const SymExpr *rhs, QualType t)
|
||||
: BinarySymExpr(IntSymKind, op, t), LHS(lhs), RHS(rhs) {}
|
||||
: BinarySymExpr(IntSymExprKind, op, t), LHS(lhs), RHS(rhs) {}
|
||||
|
||||
void dumpToStream(raw_ostream &os) const override;
|
||||
|
||||
|
@ -417,7 +423,7 @@ public:
|
|||
static void Profile(llvm::FoldingSetNodeID& ID, const llvm::APSInt& lhs,
|
||||
BinaryOperator::Opcode op, const SymExpr *rhs,
|
||||
QualType t) {
|
||||
ID.AddInteger((unsigned) IntSymKind);
|
||||
ID.AddInteger((unsigned) IntSymExprKind);
|
||||
ID.AddPointer(&lhs);
|
||||
ID.AddInteger(op);
|
||||
ID.AddPointer(rhs);
|
||||
|
@ -430,7 +436,7 @@ public:
|
|||
|
||||
// Implement isa<T> support.
|
||||
static inline bool classof(const SymExpr *SE) {
|
||||
return SE->getKind() == IntSymKind;
|
||||
return SE->getKind() == IntSymExprKind;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -442,7 +448,7 @@ class SymSymExpr : public BinarySymExpr {
|
|||
public:
|
||||
SymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs,
|
||||
QualType t)
|
||||
: BinarySymExpr(SymSymKind, op, t), LHS(lhs), RHS(rhs) {}
|
||||
: BinarySymExpr(SymSymExprKind, op, t), LHS(lhs), RHS(rhs) {}
|
||||
|
||||
const SymExpr *getLHS() const { return LHS; }
|
||||
const SymExpr *getRHS() const { return RHS; }
|
||||
|
@ -451,7 +457,7 @@ public:
|
|||
|
||||
static void Profile(llvm::FoldingSetNodeID& ID, const SymExpr *lhs,
|
||||
BinaryOperator::Opcode op, const SymExpr *rhs, QualType t) {
|
||||
ID.AddInteger((unsigned) SymSymKind);
|
||||
ID.AddInteger((unsigned) SymSymExprKind);
|
||||
ID.AddPointer(lhs);
|
||||
ID.AddInteger(op);
|
||||
ID.AddPointer(rhs);
|
||||
|
@ -464,7 +470,7 @@ public:
|
|||
|
||||
// Implement isa<T> support.
|
||||
static inline bool classof(const SymExpr *SE) {
|
||||
return SE->getKind() == SymSymKind;
|
||||
return SE->getKind() == SymSymExprKind;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -948,15 +948,15 @@ bool CStringChecker::SummarizeRegion(raw_ostream &os, ASTContext &Ctx,
|
|||
const TypedValueRegion *TVR = dyn_cast<TypedValueRegion>(MR);
|
||||
|
||||
switch (MR->getKind()) {
|
||||
case MemRegion::FunctionTextRegionKind: {
|
||||
const NamedDecl *FD = cast<FunctionTextRegion>(MR)->getDecl();
|
||||
case MemRegion::FunctionCodeRegionKind: {
|
||||
const NamedDecl *FD = cast<FunctionCodeRegion>(MR)->getDecl();
|
||||
if (FD)
|
||||
os << "the address of the function '" << *FD << '\'';
|
||||
else
|
||||
os << "the address of a function";
|
||||
return true;
|
||||
}
|
||||
case MemRegion::BlockTextRegionKind:
|
||||
case MemRegion::BlockCodeRegionKind:
|
||||
os << "block text";
|
||||
return true;
|
||||
case MemRegion::BlockDataRegionKind:
|
||||
|
|
|
@ -1513,15 +1513,15 @@ bool MallocChecker::SummarizeValue(raw_ostream &os, SVal V) {
|
|||
bool MallocChecker::SummarizeRegion(raw_ostream &os,
|
||||
const MemRegion *MR) {
|
||||
switch (MR->getKind()) {
|
||||
case MemRegion::FunctionTextRegionKind: {
|
||||
const NamedDecl *FD = cast<FunctionTextRegion>(MR)->getDecl();
|
||||
case MemRegion::FunctionCodeRegionKind: {
|
||||
const NamedDecl *FD = cast<FunctionCodeRegion>(MR)->getDecl();
|
||||
if (FD)
|
||||
os << "the address of the function '" << *FD << '\'';
|
||||
else
|
||||
os << "the address of a function";
|
||||
return true;
|
||||
}
|
||||
case MemRegion::BlockTextRegionKind:
|
||||
case MemRegion::BlockCodeRegionKind:
|
||||
os << "block text";
|
||||
return true;
|
||||
case MemRegion::BlockDataRegionKind:
|
||||
|
|
|
@ -245,7 +245,7 @@ QualType CXXBaseObjectRegion::getValueType() const {
|
|||
// FoldingSet profiling.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void MemSpaceRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
||||
void MemSpaceRegion::Profile(llvm::FoldingSetNodeID &ID) const {
|
||||
ID.AddInteger((unsigned)getKind());
|
||||
}
|
||||
|
||||
|
@ -357,31 +357,31 @@ void ElementRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
|||
ElementRegion::ProfileRegion(ID, ElementType, Index, superRegion);
|
||||
}
|
||||
|
||||
void FunctionTextRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
|
||||
void FunctionCodeRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
|
||||
const NamedDecl *FD,
|
||||
const MemRegion*) {
|
||||
ID.AddInteger(MemRegion::FunctionTextRegionKind);
|
||||
ID.AddInteger(MemRegion::FunctionCodeRegionKind);
|
||||
ID.AddPointer(FD);
|
||||
}
|
||||
|
||||
void FunctionTextRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
||||
FunctionTextRegion::ProfileRegion(ID, FD, superRegion);
|
||||
void FunctionCodeRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
||||
FunctionCodeRegion::ProfileRegion(ID, FD, superRegion);
|
||||
}
|
||||
|
||||
void BlockTextRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
|
||||
void BlockCodeRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
|
||||
const BlockDecl *BD, CanQualType,
|
||||
const AnalysisDeclContext *AC,
|
||||
const MemRegion*) {
|
||||
ID.AddInteger(MemRegion::BlockTextRegionKind);
|
||||
ID.AddInteger(MemRegion::BlockCodeRegionKind);
|
||||
ID.AddPointer(BD);
|
||||
}
|
||||
|
||||
void BlockTextRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
||||
BlockTextRegion::ProfileRegion(ID, BD, locTy, AC, superRegion);
|
||||
void BlockCodeRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
||||
BlockCodeRegion::ProfileRegion(ID, BD, locTy, AC, superRegion);
|
||||
}
|
||||
|
||||
void BlockDataRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
|
||||
const BlockTextRegion *BC,
|
||||
const BlockCodeRegion *BC,
|
||||
const LocationContext *LC,
|
||||
unsigned BlkCount,
|
||||
const MemRegion *sReg) {
|
||||
|
@ -457,11 +457,11 @@ void AllocaRegion::dumpToStream(raw_ostream &os) const {
|
|||
os << "alloca{" << (const void*) Ex << ',' << Cnt << '}';
|
||||
}
|
||||
|
||||
void FunctionTextRegion::dumpToStream(raw_ostream &os) const {
|
||||
void FunctionCodeRegion::dumpToStream(raw_ostream &os) const {
|
||||
os << "code{" << getDecl()->getDeclName().getAsString() << '}';
|
||||
}
|
||||
|
||||
void BlockTextRegion::dumpToStream(raw_ostream &os) const {
|
||||
void BlockCodeRegion::dumpToStream(raw_ostream &os) const {
|
||||
os << "block_code{" << (const void*) this << '}';
|
||||
}
|
||||
|
||||
|
@ -533,6 +533,10 @@ void RegionRawOffset::dumpToStream(raw_ostream &os) const {
|
|||
os << "raw_offset{" << getRegion() << ',' << getOffset().getQuantity() << '}';
|
||||
}
|
||||
|
||||
void CodeSpaceRegion::dumpToStream(raw_ostream &os) const {
|
||||
os << "CodeSpaceRegion";
|
||||
}
|
||||
|
||||
void StaticGlobalSpaceRegion::dumpToStream(raw_ostream &os) const {
|
||||
os << "StaticGlobalsMemSpace{" << CR << '}';
|
||||
}
|
||||
|
@ -711,11 +715,11 @@ const HeapSpaceRegion *MemRegionManager::getHeapRegion() {
|
|||
return LazyAllocate(heap);
|
||||
}
|
||||
|
||||
const MemSpaceRegion *MemRegionManager::getUnknownRegion() {
|
||||
const UnknownSpaceRegion *MemRegionManager::getUnknownRegion() {
|
||||
return LazyAllocate(unknown);
|
||||
}
|
||||
|
||||
const MemSpaceRegion *MemRegionManager::getCodeRegion() {
|
||||
const CodeSpaceRegion *MemRegionManager::getCodeRegion() {
|
||||
return LazyAllocate(code);
|
||||
}
|
||||
|
||||
|
@ -815,11 +819,11 @@ const VarRegion* MemRegionManager::getVarRegion(const VarDecl *D,
|
|||
const Decl *STCD = STC->getDecl();
|
||||
if (isa<FunctionDecl>(STCD) || isa<ObjCMethodDecl>(STCD))
|
||||
sReg = getGlobalsRegion(MemRegion::StaticGlobalSpaceRegionKind,
|
||||
getFunctionTextRegion(cast<NamedDecl>(STCD)));
|
||||
getFunctionCodeRegion(cast<NamedDecl>(STCD)));
|
||||
else if (const BlockDecl *BD = dyn_cast<BlockDecl>(STCD)) {
|
||||
// FIXME: The fallback type here is totally bogus -- though it should
|
||||
// never be queried, it will prevent uniquing with the real
|
||||
// BlockTextRegion. Ideally we'd fix the AST so that we always had a
|
||||
// BlockCodeRegion. Ideally we'd fix the AST so that we always had a
|
||||
// signature.
|
||||
QualType T;
|
||||
if (const TypeSourceInfo *TSI = BD->getSignatureAsWritten())
|
||||
|
@ -830,8 +834,8 @@ const VarRegion* MemRegionManager::getVarRegion(const VarDecl *D,
|
|||
T = getContext().getFunctionNoProtoType(T);
|
||||
T = getContext().getBlockPointerType(T);
|
||||
|
||||
const BlockTextRegion *BTR =
|
||||
getBlockTextRegion(BD, C.getCanonicalType(T),
|
||||
const BlockCodeRegion *BTR =
|
||||
getBlockCodeRegion(BD, C.getCanonicalType(T),
|
||||
STC->getAnalysisDeclContext());
|
||||
sReg = getGlobalsRegion(MemRegion::StaticGlobalSpaceRegionKind,
|
||||
BTR);
|
||||
|
@ -852,7 +856,7 @@ const VarRegion *MemRegionManager::getVarRegion(const VarDecl *D,
|
|||
}
|
||||
|
||||
const BlockDataRegion *
|
||||
MemRegionManager::getBlockDataRegion(const BlockTextRegion *BC,
|
||||
MemRegionManager::getBlockDataRegion(const BlockCodeRegion *BC,
|
||||
const LocationContext *LC,
|
||||
unsigned blockCount) {
|
||||
const MemRegion *sReg = nullptr;
|
||||
|
@ -925,15 +929,15 @@ MemRegionManager::getElementRegion(QualType elementType, NonLoc Idx,
|
|||
return R;
|
||||
}
|
||||
|
||||
const FunctionTextRegion *
|
||||
MemRegionManager::getFunctionTextRegion(const NamedDecl *FD) {
|
||||
return getSubRegion<FunctionTextRegion>(FD, getCodeRegion());
|
||||
const FunctionCodeRegion *
|
||||
MemRegionManager::getFunctionCodeRegion(const NamedDecl *FD) {
|
||||
return getSubRegion<FunctionCodeRegion>(FD, getCodeRegion());
|
||||
}
|
||||
|
||||
const BlockTextRegion *
|
||||
MemRegionManager::getBlockTextRegion(const BlockDecl *BD, CanQualType locTy,
|
||||
const BlockCodeRegion *
|
||||
MemRegionManager::getBlockCodeRegion(const BlockDecl *BD, CanQualType locTy,
|
||||
AnalysisDeclContext *AC) {
|
||||
return getSubRegion<BlockTextRegion>(BD, locTy, AC, getCodeRegion());
|
||||
return getSubRegion<BlockCodeRegion>(BD, locTy, AC, getCodeRegion());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1196,7 +1200,7 @@ RegionOffset MemRegion::getAsOffset() const {
|
|||
|
||||
while (1) {
|
||||
switch (R->getKind()) {
|
||||
case GenericMemSpaceRegionKind:
|
||||
case CodeSpaceRegionKind:
|
||||
case StackLocalsSpaceRegionKind:
|
||||
case StackArgumentsSpaceRegionKind:
|
||||
case HeapSpaceRegionKind:
|
||||
|
@ -1209,8 +1213,8 @@ RegionOffset MemRegion::getAsOffset() const {
|
|||
assert(Offset == 0 && !SymbolicOffsetBase);
|
||||
goto Finish;
|
||||
|
||||
case FunctionTextRegionKind:
|
||||
case BlockTextRegionKind:
|
||||
case FunctionCodeRegionKind:
|
||||
case BlockCodeRegionKind:
|
||||
case BlockDataRegionKind:
|
||||
// These will never have bindings, but may end up having values requested
|
||||
// if the user does some strange casting.
|
||||
|
|
|
@ -536,19 +536,19 @@ bool ScanReachableSymbols::scan(const SymExpr *sym) {
|
|||
|
||||
// TODO: should be rewritten using SymExpr::symbol_iterator.
|
||||
switch (sym->getKind()) {
|
||||
case SymExpr::RegionValueKind:
|
||||
case SymExpr::ConjuredKind:
|
||||
case SymExpr::DerivedKind:
|
||||
case SymExpr::ExtentKind:
|
||||
case SymExpr::MetadataKind:
|
||||
case SymExpr::SymbolRegionValueKind:
|
||||
case SymExpr::SymbolConjuredKind:
|
||||
case SymExpr::SymbolDerivedKind:
|
||||
case SymExpr::SymbolExtentKind:
|
||||
case SymExpr::SymbolMetadataKind:
|
||||
break;
|
||||
case SymExpr::CastSymbolKind:
|
||||
case SymExpr::SymbolCastKind:
|
||||
return scan(cast<SymbolCast>(sym)->getOperand());
|
||||
case SymExpr::SymIntKind:
|
||||
case SymExpr::SymIntExprKind:
|
||||
return scan(cast<SymIntExpr>(sym)->getLHS());
|
||||
case SymExpr::IntSymKind:
|
||||
case SymExpr::IntSymExprKind:
|
||||
return scan(cast<IntSymExpr>(sym)->getRHS());
|
||||
case SymExpr::SymSymKind: {
|
||||
case SymExpr::SymSymExprKind: {
|
||||
const SymSymExpr *x = cast<SymSymExpr>(sym);
|
||||
return scan(x->getLHS()) && scan(x->getRHS());
|
||||
}
|
||||
|
|
|
@ -214,15 +214,15 @@ SValBuilder::getDerivedRegionValueSymbolVal(SymbolRef parentSymbol,
|
|||
}
|
||||
|
||||
DefinedSVal SValBuilder::getFunctionPointer(const FunctionDecl *func) {
|
||||
return loc::MemRegionVal(MemMgr.getFunctionTextRegion(func));
|
||||
return loc::MemRegionVal(MemMgr.getFunctionCodeRegion(func));
|
||||
}
|
||||
|
||||
DefinedSVal SValBuilder::getBlockPointer(const BlockDecl *block,
|
||||
CanQualType locTy,
|
||||
const LocationContext *locContext,
|
||||
unsigned blockCount) {
|
||||
const BlockTextRegion *BC =
|
||||
MemMgr.getBlockTextRegion(block, locTy, locContext->getAnalysisDeclContext());
|
||||
const BlockCodeRegion *BC =
|
||||
MemMgr.getBlockCodeRegion(block, locTy, locContext->getAnalysisDeclContext());
|
||||
const BlockDataRegion *BD = MemMgr.getBlockDataRegion(BC, locContext,
|
||||
blockCount);
|
||||
return loc::MemRegionVal(BD);
|
||||
|
|
|
@ -51,7 +51,7 @@ bool SVal::hasConjuredSymbol() const {
|
|||
const FunctionDecl *SVal::getAsFunctionDecl() const {
|
||||
if (Optional<loc::MemRegionVal> X = getAs<loc::MemRegionVal>()) {
|
||||
const MemRegion* R = X->getRegion();
|
||||
if (const FunctionTextRegion *CTR = R->getAs<FunctionTextRegion>())
|
||||
if (const FunctionCodeRegion *CTR = R->getAs<FunctionCodeRegion>())
|
||||
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CTR->getDecl()))
|
||||
return FD;
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ void SVal::dump() const { dumpToStream(llvm::errs()); }
|
|||
|
||||
void SVal::dumpToStream(raw_ostream &os) const {
|
||||
switch (getBaseKind()) {
|
||||
case UnknownKind:
|
||||
case UnknownValKind:
|
||||
os << "Unknown";
|
||||
break;
|
||||
case NonLocKind:
|
||||
|
@ -249,7 +249,7 @@ void SVal::dumpToStream(raw_ostream &os) const {
|
|||
case LocKind:
|
||||
castAs<Loc>().dumpToStream(os);
|
||||
break;
|
||||
case UndefinedKind:
|
||||
case UndefinedValKind:
|
||||
os << "Undefined";
|
||||
break;
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ void Loc::dumpToStream(raw_ostream &os) const {
|
|||
case loc::GotoLabelKind:
|
||||
os << "&&" << castAs<loc::GotoLabel>().getLabel()->getName();
|
||||
break;
|
||||
case loc::MemRegionKind:
|
||||
case loc::MemRegionValKind:
|
||||
os << '&' << castAs<loc::MemRegionVal>().getRegion()->getString();
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -141,9 +141,9 @@ SVal SimpleSValBuilder::evalCastFromLoc(Loc val, QualType castTy) {
|
|||
// unless this is a weak function or a symbolic region.
|
||||
if (castTy->isBooleanType()) {
|
||||
switch (val.getSubKind()) {
|
||||
case loc::MemRegionKind: {
|
||||
case loc::MemRegionValKind: {
|
||||
const MemRegion *R = val.castAs<loc::MemRegionVal>().getRegion();
|
||||
if (const FunctionTextRegion *FTR = dyn_cast<FunctionTextRegion>(R))
|
||||
if (const FunctionCodeRegion *FTR = dyn_cast<FunctionCodeRegion>(R))
|
||||
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(FTR->getDecl()))
|
||||
if (FD->isWeak())
|
||||
// FIXME: Currently we are using an extent symbol here,
|
||||
|
@ -689,7 +689,7 @@ SVal SimpleSValBuilder::evalBinOpLL(ProgramStateRef state,
|
|||
// completely unknowable.
|
||||
return UnknownVal();
|
||||
}
|
||||
case loc::MemRegionKind: {
|
||||
case loc::MemRegionValKind: {
|
||||
if (Optional<loc::ConcreteInt> rInt = rhs.getAs<loc::ConcreteInt>()) {
|
||||
// If one of the operands is a symbol and the other is a constant,
|
||||
// build an expression for use by the constraint manager.
|
||||
|
@ -718,7 +718,7 @@ SVal SimpleSValBuilder::evalBinOpLL(ProgramStateRef state,
|
|||
|
||||
// Get both values as regions, if possible.
|
||||
const MemRegion *LeftMR = lhs.getAsRegion();
|
||||
assert(LeftMR && "MemRegionKind SVal doesn't have a region!");
|
||||
assert(LeftMR && "MemRegionValKind SVal doesn't have a region!");
|
||||
|
||||
const MemRegion *RightMR = rhs.getAsRegion();
|
||||
if (!RightMR)
|
||||
|
|
|
@ -100,7 +100,7 @@ const MemRegion *StoreManager::castRegion(const MemRegion *R, QualType CastToTy)
|
|||
// Process region cast according to the kind of the region being cast.
|
||||
switch (R->getKind()) {
|
||||
case MemRegion::CXXThisRegionKind:
|
||||
case MemRegion::GenericMemSpaceRegionKind:
|
||||
case MemRegion::CodeSpaceRegionKind:
|
||||
case MemRegion::StackLocalsSpaceRegionKind:
|
||||
case MemRegion::StackArgumentsSpaceRegionKind:
|
||||
case MemRegion::HeapSpaceRegionKind:
|
||||
|
@ -112,8 +112,8 @@ const MemRegion *StoreManager::castRegion(const MemRegion *R, QualType CastToTy)
|
|||
llvm_unreachable("Invalid region cast");
|
||||
}
|
||||
|
||||
case MemRegion::FunctionTextRegionKind:
|
||||
case MemRegion::BlockTextRegionKind:
|
||||
case MemRegion::FunctionCodeRegionKind:
|
||||
case MemRegion::BlockCodeRegionKind:
|
||||
case MemRegion::BlockDataRegionKind:
|
||||
case MemRegion::StringRegionKind:
|
||||
// FIXME: Need to handle arbitrary downcasts.
|
||||
|
@ -393,7 +393,7 @@ SVal StoreManager::getLValueFieldOrIvar(const Decl *D, SVal Base) {
|
|||
const MemRegion* BaseR = nullptr;
|
||||
|
||||
switch (BaseL.getSubKind()) {
|
||||
case loc::MemRegionKind:
|
||||
case loc::MemRegionValKind:
|
||||
BaseR = BaseL.castAs<loc::MemRegionVal>().getRegion();
|
||||
break;
|
||||
|
||||
|
|
|
@ -115,22 +115,22 @@ void SymExpr::symbol_iterator::expand() {
|
|||
const SymExpr *SE = itr.pop_back_val();
|
||||
|
||||
switch (SE->getKind()) {
|
||||
case SymExpr::RegionValueKind:
|
||||
case SymExpr::ConjuredKind:
|
||||
case SymExpr::DerivedKind:
|
||||
case SymExpr::ExtentKind:
|
||||
case SymExpr::MetadataKind:
|
||||
case SymExpr::SymbolRegionValueKind:
|
||||
case SymExpr::SymbolConjuredKind:
|
||||
case SymExpr::SymbolDerivedKind:
|
||||
case SymExpr::SymbolExtentKind:
|
||||
case SymExpr::SymbolMetadataKind:
|
||||
return;
|
||||
case SymExpr::CastSymbolKind:
|
||||
case SymExpr::SymbolCastKind:
|
||||
itr.push_back(cast<SymbolCast>(SE)->getOperand());
|
||||
return;
|
||||
case SymExpr::SymIntKind:
|
||||
case SymExpr::SymIntExprKind:
|
||||
itr.push_back(cast<SymIntExpr>(SE)->getLHS());
|
||||
return;
|
||||
case SymExpr::IntSymKind:
|
||||
case SymExpr::IntSymExprKind:
|
||||
itr.push_back(cast<IntSymExpr>(SE)->getRHS());
|
||||
return;
|
||||
case SymExpr::SymSymKind: {
|
||||
case SymExpr::SymSymExprKind: {
|
||||
const SymSymExpr *x = cast<SymSymExpr>(SE);
|
||||
itr.push_back(x->getLHS());
|
||||
itr.push_back(x->getRHS());
|
||||
|
@ -458,35 +458,35 @@ bool SymbolReaper::isLive(SymbolRef sym) {
|
|||
bool KnownLive;
|
||||
|
||||
switch (sym->getKind()) {
|
||||
case SymExpr::RegionValueKind:
|
||||
case SymExpr::SymbolRegionValueKind:
|
||||
KnownLive = isLiveRegion(cast<SymbolRegionValue>(sym)->getRegion());
|
||||
break;
|
||||
case SymExpr::ConjuredKind:
|
||||
case SymExpr::SymbolConjuredKind:
|
||||
KnownLive = false;
|
||||
break;
|
||||
case SymExpr::DerivedKind:
|
||||
case SymExpr::SymbolDerivedKind:
|
||||
KnownLive = isLive(cast<SymbolDerived>(sym)->getParentSymbol());
|
||||
break;
|
||||
case SymExpr::ExtentKind:
|
||||
case SymExpr::SymbolExtentKind:
|
||||
KnownLive = isLiveRegion(cast<SymbolExtent>(sym)->getRegion());
|
||||
break;
|
||||
case SymExpr::MetadataKind:
|
||||
case SymExpr::SymbolMetadataKind:
|
||||
KnownLive = MetadataInUse.count(sym) &&
|
||||
isLiveRegion(cast<SymbolMetadata>(sym)->getRegion());
|
||||
if (KnownLive)
|
||||
MetadataInUse.erase(sym);
|
||||
break;
|
||||
case SymExpr::SymIntKind:
|
||||
case SymExpr::SymIntExprKind:
|
||||
KnownLive = isLive(cast<SymIntExpr>(sym)->getLHS());
|
||||
break;
|
||||
case SymExpr::IntSymKind:
|
||||
case SymExpr::IntSymExprKind:
|
||||
KnownLive = isLive(cast<IntSymExpr>(sym)->getRHS());
|
||||
break;
|
||||
case SymExpr::SymSymKind:
|
||||
case SymExpr::SymSymExprKind:
|
||||
KnownLive = isLive(cast<SymSymExpr>(sym)->getLHS()) &&
|
||||
isLive(cast<SymSymExpr>(sym)->getRHS());
|
||||
break;
|
||||
case SymExpr::CastSymbolKind:
|
||||
case SymExpr::SymbolCastKind:
|
||||
KnownLive = isLive(cast<SymbolCast>(sym)->getOperand());
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue