[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:
Artem Dergachev 2016-01-13 13:49:29 +00:00
parent 46ff7ec317
commit 73f018e381
12 changed files with 203 additions and 182 deletions

View File

@ -80,7 +80,7 @@ class MemRegion : public llvm::FoldingSetNode {
public: public:
enum Kind { enum Kind {
// Memory spaces. // Memory spaces.
GenericMemSpaceRegionKind, CodeSpaceRegionKind,
StackLocalsSpaceRegionKind, StackLocalsSpaceRegionKind,
StackArgumentsSpaceRegionKind, StackArgumentsSpaceRegionKind,
HeapSpaceRegionKind, HeapSpaceRegionKind,
@ -89,29 +89,29 @@ public:
GlobalInternalSpaceRegionKind, GlobalInternalSpaceRegionKind,
GlobalSystemSpaceRegionKind, GlobalSystemSpaceRegionKind,
GlobalImmutableSpaceRegionKind, GlobalImmutableSpaceRegionKind,
BEG_NON_STATIC_GLOBAL_MEMSPACES = GlobalInternalSpaceRegionKind, BEGIN_NON_STATIC_GLOBAL_MEMSPACES = GlobalInternalSpaceRegionKind,
END_NON_STATIC_GLOBAL_MEMSPACES = GlobalImmutableSpaceRegionKind, END_NON_STATIC_GLOBAL_MEMSPACES = GlobalImmutableSpaceRegionKind,
BEG_GLOBAL_MEMSPACES = StaticGlobalSpaceRegionKind, BEGIN_GLOBAL_MEMSPACES = StaticGlobalSpaceRegionKind,
END_GLOBAL_MEMSPACES = GlobalImmutableSpaceRegionKind, END_GLOBAL_MEMSPACES = GlobalImmutableSpaceRegionKind,
BEG_MEMSPACES = GenericMemSpaceRegionKind, BEGIN_MEMSPACES = CodeSpaceRegionKind,
END_MEMSPACES = GlobalImmutableSpaceRegionKind, END_MEMSPACES = GlobalImmutableSpaceRegionKind,
// Untyped regions. // Untyped regions.
SymbolicRegionKind, SymbolicRegionKind,
AllocaRegionKind, AllocaRegionKind,
// Typed regions. // Typed regions.
BEG_TYPED_REGIONS, BEGIN_TYPED_REGIONS,
FunctionTextRegionKind = BEG_TYPED_REGIONS, FunctionCodeRegionKind = BEGIN_TYPED_REGIONS,
BlockTextRegionKind, BlockCodeRegionKind,
BlockDataRegionKind, BlockDataRegionKind,
BEG_TYPED_VALUE_REGIONS, BEGIN_TYPED_VALUE_REGIONS,
CompoundLiteralRegionKind = BEG_TYPED_VALUE_REGIONS, CompoundLiteralRegionKind = BEGIN_TYPED_VALUE_REGIONS,
CXXThisRegionKind, CXXThisRegionKind,
StringRegionKind, StringRegionKind,
ObjCStringRegionKind, ObjCStringRegionKind,
ElementRegionKind, ElementRegionKind,
// Decl Regions. // Decl Regions.
BEG_DECL_REGIONS, BEGIN_DECL_REGIONS,
VarRegionKind = BEG_DECL_REGIONS, VarRegionKind = BEGIN_DECL_REGIONS,
FieldRegionKind, FieldRegionKind,
ObjCIvarRegionKind, ObjCIvarRegionKind,
END_DECL_REGIONS = ObjCIvarRegionKind, END_DECL_REGIONS = ObjCIvarRegionKind,
@ -193,12 +193,9 @@ public:
/// for example, the set of global variables, the stack frame, etc. /// for example, the set of global variables, the stack frame, etc.
class MemSpaceRegion : public MemRegion { class MemSpaceRegion : public MemRegion {
protected: protected:
friend class MemRegionManager;
MemRegionManager *Mgr; MemRegionManager *Mgr;
MemSpaceRegion(MemRegionManager *mgr, Kind k = GenericMemSpaceRegionKind) MemSpaceRegion(MemRegionManager *mgr, Kind k) : MemRegion(k), Mgr(mgr) {
: MemRegion(k), Mgr(mgr) {
assert(classof(this)); assert(classof(this));
} }
@ -211,10 +208,26 @@ public:
static bool classof(const MemRegion *R) { static bool classof(const MemRegion *R) {
Kind k = R->getKind(); 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 { class GlobalsSpaceRegion : public MemSpaceRegion {
virtual void anchor(); virtual void anchor();
protected: protected:
@ -223,7 +236,7 @@ protected:
public: public:
static bool classof(const MemRegion *R) { static bool classof(const MemRegion *R) {
Kind k = R->getKind(); 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 /// RegionStoreManager::invalidateRegions (instead of finding all the dependent
/// globals, we invalidate the whole parent region). /// globals, we invalidate the whole parent region).
class NonStaticGlobalSpaceRegion : public GlobalsSpaceRegion { class NonStaticGlobalSpaceRegion : public GlobalsSpaceRegion {
friend class MemRegionManager;
protected: protected:
NonStaticGlobalSpaceRegion(MemRegionManager *mgr, Kind k) NonStaticGlobalSpaceRegion(MemRegionManager *mgr, Kind k)
: GlobalsSpaceRegion(mgr, k) {} : GlobalsSpaceRegion(mgr, k) {}
public: public:
static bool classof(const MemRegion *R) { static bool classof(const MemRegion *R) {
Kind k = R->getKind(); Kind k = R->getKind();
return k >= BEG_NON_STATIC_GLOBAL_MEMSPACES && return k >= BEGIN_NON_STATIC_GLOBAL_MEMSPACES &&
k <= END_NON_STATIC_GLOBAL_MEMSPACES; k <= END_NON_STATIC_GLOBAL_MEMSPACES;
} }
}; };
@ -357,7 +368,7 @@ public:
return R->getKind() == UnknownSpaceRegionKind; return R->getKind() == UnknownSpaceRegionKind;
} }
}; };
class StackSpaceRegion : public MemSpaceRegion { class StackSpaceRegion : public MemSpaceRegion {
private: private:
const StackFrameContext *SFC; const StackFrameContext *SFC;
@ -368,18 +379,18 @@ protected:
assert(classof(this)); assert(classof(this));
} }
public: public:
const StackFrameContext *getStackFrame() const { return SFC; } const StackFrameContext *getStackFrame() const { return SFC; }
void Profile(llvm::FoldingSetNodeID &ID) const override; void Profile(llvm::FoldingSetNodeID &ID) const override;
static bool classof(const MemRegion *R) { static bool classof(const MemRegion *R) {
Kind k = R->getKind(); Kind k = R->getKind();
return k >= StackLocalsSpaceRegionKind && return k >= StackLocalsSpaceRegionKind &&
k <= StackArgumentsSpaceRegionKind; k <= StackArgumentsSpaceRegionKind;
} }
}; };
class StackLocalsSpaceRegion : public StackSpaceRegion { class StackLocalsSpaceRegion : public StackSpaceRegion {
virtual void anchor(); virtual void anchor();
friend class MemRegionManager; friend class MemRegionManager;
@ -491,7 +502,7 @@ public:
static bool classof(const MemRegion* R) { static bool classof(const MemRegion* R) {
unsigned k = R->getKind(); 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) { static bool classof(const MemRegion* R) {
unsigned k = R->getKind(); 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) { static bool classof(const MemRegion* R) {
Kind k = R->getKind(); Kind k = R->getKind();
return k >= FunctionTextRegionKind && k <= BlockTextRegionKind; return k >= FunctionCodeRegionKind && k <= BlockCodeRegionKind;
} }
}; };
/// FunctionTextRegion - A region that represents code texts of function. /// FunctionCodeRegion - A region that represents code texts of function.
class FunctionTextRegion : public CodeTextRegion { class FunctionCodeRegion : public CodeTextRegion {
const NamedDecl *FD; const NamedDecl *FD;
public: public:
FunctionTextRegion(const NamedDecl *fd, const MemRegion* sreg) FunctionCodeRegion(const NamedDecl *fd, const MemRegion* sreg)
: CodeTextRegion(sreg, FunctionTextRegionKind), FD(fd) { : CodeTextRegion(sreg, FunctionCodeRegionKind), FD(fd) {
assert(isa<ObjCMethodDecl>(fd) || isa<FunctionDecl>(fd)); assert(isa<ObjCMethodDecl>(fd) || isa<FunctionDecl>(fd));
} }
@ -577,27 +588,27 @@ public:
const MemRegion*); const MemRegion*);
static bool classof(const MemRegion* R) { static bool classof(const MemRegion* R) {
return R->getKind() == FunctionTextRegionKind; return R->getKind() == FunctionCodeRegionKind;
} }
}; };
/// BlockTextRegion - A region that represents code texts of blocks (closures). /// BlockCodeRegion - A region that represents code texts of blocks (closures).
/// 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, /// represent the "code", while BlockDataRegions represent instances of blocks,
/// which correspond to "code+data". The distinction is important, because /// which correspond to "code+data". The distinction is important, because
/// like a closure a block captures the values of externally referenced /// like a closure a block captures the values of externally referenced
/// variables. /// variables.
class BlockTextRegion : public CodeTextRegion { class BlockCodeRegion : public CodeTextRegion {
friend class MemRegionManager; friend class MemRegionManager;
const BlockDecl *BD; const BlockDecl *BD;
AnalysisDeclContext *AC; AnalysisDeclContext *AC;
CanQualType locTy; CanQualType locTy;
BlockTextRegion(const BlockDecl *bd, CanQualType lTy, BlockCodeRegion(const BlockDecl *bd, CanQualType lTy,
AnalysisDeclContext *ac, const MemRegion* sreg) AnalysisDeclContext *ac, const MemRegion* sreg)
: CodeTextRegion(sreg, BlockTextRegionKind), BD(bd), AC(ac), locTy(lTy) {} : CodeTextRegion(sreg, BlockCodeRegionKind), BD(bd), AC(ac), locTy(lTy) {}
public: public:
QualType getLocationType() const override { QualType getLocationType() const override {
@ -619,32 +630,32 @@ public:
const MemRegion*); const MemRegion*);
static bool classof(const MemRegion* R) { static bool classof(const MemRegion* R) {
return R->getKind() == BlockTextRegionKind; return R->getKind() == BlockCodeRegionKind;
} }
}; };
/// BlockDataRegion - A region that represents a block instance. /// 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, /// represent the "code", while BlockDataRegions represent instances of blocks,
/// which correspond to "code+data". The distinction is important, because /// which correspond to "code+data". The distinction is important, because
/// like a closure a block captures the values of externally referenced /// like a closure a block captures the values of externally referenced
/// variables. /// variables.
class BlockDataRegion : public TypedRegion { class BlockDataRegion : public TypedRegion {
friend class MemRegionManager; friend class MemRegionManager;
const BlockTextRegion *BC; const BlockCodeRegion *BC;
const LocationContext *LC; // Can be null */ const LocationContext *LC; // Can be null */
unsigned BlockCount; unsigned BlockCount;
void *ReferencedVars; void *ReferencedVars;
void *OriginalVars; void *OriginalVars;
BlockDataRegion(const BlockTextRegion *bc, const LocationContext *lc, BlockDataRegion(const BlockCodeRegion *bc, const LocationContext *lc,
unsigned count, const MemRegion *sreg) unsigned count, const MemRegion *sreg)
: TypedRegion(sreg, BlockDataRegionKind), BC(bc), LC(lc), : TypedRegion(sreg, BlockDataRegionKind), BC(bc), LC(lc),
BlockCount(count), BlockCount(count),
ReferencedVars(nullptr), OriginalVars(nullptr) {} ReferencedVars(nullptr), OriginalVars(nullptr) {}
public: public:
const BlockTextRegion *getCodeRegion() const { return BC; } const BlockCodeRegion *getCodeRegion() const { return BC; }
const BlockDecl *getDecl() const { return BC->getDecl(); } const BlockDecl *getDecl() const { return BC->getDecl(); }
@ -691,7 +702,7 @@ public:
void Profile(llvm::FoldingSetNodeID& ID) const override; 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 LocationContext *, unsigned,
const MemRegion *); const MemRegion *);
@ -856,7 +867,7 @@ public:
static bool classof(const MemRegion* R) { static bool classof(const MemRegion* R) {
unsigned k = R->getKind(); 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; HeapSpaceRegion *heap;
UnknownSpaceRegion *unknown; UnknownSpaceRegion *unknown;
MemSpaceRegion *code; CodeSpaceRegion *code;
public: public:
MemRegionManager(ASTContext &c, llvm::BumpPtrAllocator &a) MemRegionManager(ASTContext &c, llvm::BumpPtrAllocator &a)
@ -1174,9 +1185,9 @@ public:
/// getUnknownRegion - Retrieve the memory region associated with unknown /// getUnknownRegion - Retrieve the memory region associated with unknown
/// memory space. /// memory space.
const MemSpaceRegion *getUnknownRegion(); const UnknownSpaceRegion *getUnknownRegion();
const MemSpaceRegion *getCodeRegion(); const CodeSpaceRegion *getCodeRegion();
/// getAllocaRegion - Retrieve a region associated with a call to alloca(). /// getAllocaRegion - Retrieve a region associated with a call to alloca().
const AllocaRegion *getAllocaRegion(const Expr *Ex, unsigned Cnt, const AllocaRegion *getAllocaRegion(const Expr *Ex, unsigned Cnt,
@ -1262,8 +1273,8 @@ public:
baseReg->isVirtual()); baseReg->isVirtual());
} }
const FunctionTextRegion *getFunctionTextRegion(const NamedDecl *FD); const FunctionCodeRegion *getFunctionCodeRegion(const NamedDecl *FD);
const BlockTextRegion *getBlockTextRegion(const BlockDecl *BD, const BlockCodeRegion *getBlockCodeRegion(const BlockDecl *BD,
CanQualType locTy, CanQualType locTy,
AnalysisDeclContext *AC); AnalysisDeclContext *AC);
@ -1271,7 +1282,7 @@ public:
/// of a block. Unlike many other MemRegions, the LocationContext* /// of a block. Unlike many other MemRegions, the LocationContext*
/// argument is allowed to be NULL for cases where we have no known /// argument is allowed to be NULL for cases where we have no known
/// context. /// context.
const BlockDataRegion *getBlockDataRegion(const BlockTextRegion *bc, const BlockDataRegion *getBlockDataRegion(const BlockCodeRegion *bc,
const LocationContext *lc, const LocationContext *lc,
unsigned blockCount); unsigned blockCount);

View File

@ -45,8 +45,8 @@ class SVal {
public: public:
enum BaseKind { enum BaseKind {
// The enumerators must be representable using 2 bits. // The enumerators must be representable using 2 bits.
UndefinedKind = 0, // for subclass UndefinedVal (an uninitialized value) UndefinedValKind = 0, // for subclass UndefinedVal (an uninitialized value)
UnknownKind = 1, // for subclass UnknownVal (a void value) UnknownValKind = 1, // for subclass UnknownVal (a void value)
LocKind = 2, // for subclass Loc (an L-value) LocKind = 2, // for subclass Loc (an L-value)
NonLocKind = 3 // for subclass NonLoc (an R-value that's not NonLocKind = 3 // for subclass NonLoc (an R-value that's not
// an L-value) // an L-value)
@ -115,19 +115,19 @@ public:
} }
inline bool isUnknown() const { inline bool isUnknown() const {
return getRawKind() == UnknownKind; return getRawKind() == UnknownValKind;
} }
inline bool isUndef() const { inline bool isUndef() const {
return getRawKind() == UndefinedKind; return getRawKind() == UndefinedValKind;
} }
inline bool isUnknownOrUndef() const { inline bool isUnknownOrUndef() const {
return getRawKind() <= UnknownKind; return getRawKind() <= UnknownValKind;
} }
inline bool isValid() const { inline bool isValid() const {
return getRawKind() > UnknownKind; return getRawKind() > UnknownValKind;
} }
bool isConstant() const; bool isConstant() const;
@ -190,12 +190,12 @@ public:
class UndefinedVal : public SVal { class UndefinedVal : public SVal {
public: public:
UndefinedVal() : SVal(UndefinedKind) {} UndefinedVal() : SVal(UndefinedValKind) {}
private: private:
friend class SVal; friend class SVal;
static bool isKind(const SVal& V) { static bool isKind(const SVal& V) {
return V.getBaseKind() == UndefinedKind; return V.getBaseKind() == UndefinedValKind;
} }
}; };
@ -223,12 +223,12 @@ private:
class UnknownVal : public DefinedOrUnknownSVal { class UnknownVal : public DefinedOrUnknownSVal {
public: public:
explicit UnknownVal() : DefinedOrUnknownSVal(UnknownKind) {} explicit UnknownVal() : DefinedOrUnknownSVal(UnknownValKind) {}
private: private:
friend class SVal; friend class SVal;
static bool isKind(const SVal &V) { static bool isKind(const SVal &V) {
return V.getBaseKind() == UnknownKind; return V.getBaseKind() == UnknownValKind;
} }
}; };
@ -465,7 +465,7 @@ private:
namespace loc { namespace loc {
enum Kind { GotoLabelKind, MemRegionKind, ConcreteIntKind }; enum Kind { GotoLabelKind, MemRegionValKind, ConcreteIntKind };
class GotoLabel : public Loc { class GotoLabel : public Loc {
public: public:
@ -490,7 +490,7 @@ private:
class MemRegionVal : public Loc { class MemRegionVal : public Loc {
public: public:
explicit MemRegionVal(const MemRegion* r) : Loc(MemRegionKind, r) {} explicit MemRegionVal(const MemRegion* r) : Loc(MemRegionValKind, r) {}
/// \brief Get the underlining region. /// \brief Get the underlining region.
const MemRegion* getRegion() const { const MemRegion* getRegion() const {
@ -518,11 +518,11 @@ private:
MemRegionVal() {} MemRegionVal() {}
static bool isKind(const SVal& V) { static bool isKind(const SVal& V) {
return V.getBaseKind() == LocKind && return V.getBaseKind() == LocKind &&
V.getSubKind() == MemRegionKind; V.getSubKind() == MemRegionValKind;
} }
static bool isKind(const Loc& V) { static bool isKind(const Loc& V) {
return V.getSubKind() == MemRegionKind; return V.getSubKind() == MemRegionValKind;
} }
}; };

View File

@ -42,14 +42,22 @@ namespace ento {
class SymExpr : public llvm::FoldingSetNode { class SymExpr : public llvm::FoldingSetNode {
virtual void anchor(); virtual void anchor();
public: public:
enum Kind { RegionValueKind, ConjuredKind, DerivedKind, ExtentKind, enum Kind {
MetadataKind, SymbolRegionValueKind,
BEGIN_SYMBOLS = RegionValueKind, SymbolConjuredKind,
END_SYMBOLS = MetadataKind, SymbolDerivedKind,
SymIntKind, IntSymKind, SymSymKind, SymbolExtentKind,
BEGIN_BINARYSYMEXPRS = SymIntKind, SymbolMetadataKind,
END_BINARYSYMEXPRS = SymSymKind, BEGIN_SYMBOLS = SymbolRegionValueKind,
CastSymbolKind }; END_SYMBOLS = SymbolMetadataKind,
SymIntExprKind,
IntSymExprKind,
SymSymExprKind,
BEGIN_BINARYSYMEXPRS = SymIntExprKind,
END_BINARYSYMEXPRS = SymSymExprKind,
SymbolCastKind
};
private: private:
Kind K; Kind K;
@ -126,12 +134,12 @@ class SymbolRegionValue : public SymbolData {
public: public:
SymbolRegionValue(SymbolID sym, const TypedValueRegion *r) SymbolRegionValue(SymbolID sym, const TypedValueRegion *r)
: SymbolData(RegionValueKind, sym), R(r) {} : SymbolData(SymbolRegionValueKind, sym), R(r) {}
const TypedValueRegion* getRegion() const { return R; } const TypedValueRegion* getRegion() const { return R; }
static void Profile(llvm::FoldingSetNodeID& profile, const TypedValueRegion* R) { static void Profile(llvm::FoldingSetNodeID& profile, const TypedValueRegion* R) {
profile.AddInteger((unsigned) RegionValueKind); profile.AddInteger((unsigned) SymbolRegionValueKind);
profile.AddPointer(R); profile.AddPointer(R);
} }
@ -145,7 +153,7 @@ public:
// Implement isa<T> support. // Implement isa<T> support.
static inline bool classof(const SymExpr *SE) { static inline bool classof(const SymExpr *SE) {
return SE->getKind() == RegionValueKind; return SE->getKind() == SymbolRegionValueKind;
} }
}; };
@ -160,11 +168,9 @@ class SymbolConjured : public SymbolData {
public: public:
SymbolConjured(SymbolID sym, const Stmt *s, const LocationContext *lctx, SymbolConjured(SymbolID sym, const Stmt *s, const LocationContext *lctx,
QualType t, unsigned count, QualType t, unsigned count, const void *symbolTag)
const void *symbolTag) : SymbolData(SymbolConjuredKind, sym), S(s), T(t), Count(count),
: SymbolData(ConjuredKind, sym), S(s), T(t), Count(count), LCtx(lctx), SymbolTag(symbolTag) {}
LCtx(lctx),
SymbolTag(symbolTag) {}
const Stmt *getStmt() const { return S; } const Stmt *getStmt() const { return S; }
unsigned getCount() const { return Count; } unsigned getCount() const { return Count; }
@ -177,7 +183,7 @@ public:
static void Profile(llvm::FoldingSetNodeID& profile, const Stmt *S, static void Profile(llvm::FoldingSetNodeID& profile, const Stmt *S,
QualType T, unsigned Count, const LocationContext *LCtx, QualType T, unsigned Count, const LocationContext *LCtx,
const void *SymbolTag) { const void *SymbolTag) {
profile.AddInteger((unsigned) ConjuredKind); profile.AddInteger((unsigned) SymbolConjuredKind);
profile.AddPointer(S); profile.AddPointer(S);
profile.AddPointer(LCtx); profile.AddPointer(LCtx);
profile.Add(T); profile.Add(T);
@ -191,7 +197,7 @@ public:
// Implement isa<T> support. // Implement isa<T> support.
static inline bool classof(const SymExpr *SE) { static inline bool classof(const SymExpr *SE) {
return SE->getKind() == ConjuredKind; return SE->getKind() == SymbolConjuredKind;
} }
}; };
@ -203,7 +209,7 @@ class SymbolDerived : public SymbolData {
public: public:
SymbolDerived(SymbolID sym, SymbolRef parent, const TypedValueRegion *r) 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; } SymbolRef getParentSymbol() const { return parentSymbol; }
const TypedValueRegion *getRegion() const { return R; } const TypedValueRegion *getRegion() const { return R; }
@ -214,7 +220,7 @@ public:
static void Profile(llvm::FoldingSetNodeID& profile, SymbolRef parent, static void Profile(llvm::FoldingSetNodeID& profile, SymbolRef parent,
const TypedValueRegion *r) { const TypedValueRegion *r) {
profile.AddInteger((unsigned) DerivedKind); profile.AddInteger((unsigned) SymbolDerivedKind);
profile.AddPointer(r); profile.AddPointer(r);
profile.AddPointer(parent); profile.AddPointer(parent);
} }
@ -225,7 +231,7 @@ public:
// Implement isa<T> support. // Implement isa<T> support.
static inline bool classof(const SymExpr *SE) { static inline bool classof(const SymExpr *SE) {
return SE->getKind() == DerivedKind; return SE->getKind() == SymbolDerivedKind;
} }
}; };
@ -237,7 +243,7 @@ class SymbolExtent : public SymbolData {
public: public:
SymbolExtent(SymbolID sym, const SubRegion *r) SymbolExtent(SymbolID sym, const SubRegion *r)
: SymbolData(ExtentKind, sym), R(r) {} : SymbolData(SymbolExtentKind, sym), R(r) {}
const SubRegion *getRegion() const { return R; } const SubRegion *getRegion() const { return R; }
@ -246,7 +252,7 @@ public:
void dumpToStream(raw_ostream &os) const override; void dumpToStream(raw_ostream &os) const override;
static void Profile(llvm::FoldingSetNodeID& profile, const SubRegion *R) { static void Profile(llvm::FoldingSetNodeID& profile, const SubRegion *R) {
profile.AddInteger((unsigned) ExtentKind); profile.AddInteger((unsigned) SymbolExtentKind);
profile.AddPointer(R); profile.AddPointer(R);
} }
@ -256,7 +262,7 @@ public:
// Implement isa<T> support. // Implement isa<T> support.
static inline bool classof(const SymExpr *SE) { static inline bool classof(const SymExpr *SE) {
return SE->getKind() == ExtentKind; return SE->getKind() == SymbolExtentKind;
} }
}; };
@ -273,7 +279,7 @@ class SymbolMetadata : public SymbolData {
public: public:
SymbolMetadata(SymbolID sym, const MemRegion* r, const Stmt *s, QualType t, SymbolMetadata(SymbolID sym, const MemRegion* r, const Stmt *s, QualType t,
unsigned count, const void *tag) 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 MemRegion *getRegion() const { return R; }
const Stmt *getStmt() const { return S; } const Stmt *getStmt() const { return S; }
@ -287,7 +293,7 @@ public:
static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion *R, static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion *R,
const Stmt *S, QualType T, unsigned Count, const Stmt *S, QualType T, unsigned Count,
const void *Tag) { const void *Tag) {
profile.AddInteger((unsigned) MetadataKind); profile.AddInteger((unsigned) SymbolMetadataKind);
profile.AddPointer(R); profile.AddPointer(R);
profile.AddPointer(S); profile.AddPointer(S);
profile.Add(T); profile.Add(T);
@ -301,7 +307,7 @@ public:
// Implement isa<T> support. // Implement isa<T> support.
static inline bool classof(const SymExpr *SE) { static inline bool classof(const SymExpr *SE) {
return SE->getKind() == MetadataKind; return SE->getKind() == SymbolMetadataKind;
} }
}; };
@ -315,7 +321,7 @@ class SymbolCast : public SymExpr {
public: public:
SymbolCast(const SymExpr *In, QualType From, QualType To) : 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; } QualType getType() const override { return ToTy; }
@ -325,7 +331,7 @@ public:
static void Profile(llvm::FoldingSetNodeID& ID, static void Profile(llvm::FoldingSetNodeID& ID,
const SymExpr *In, QualType From, QualType To) { const SymExpr *In, QualType From, QualType To) {
ID.AddInteger((unsigned) CastSymbolKind); ID.AddInteger((unsigned) SymbolCastKind);
ID.AddPointer(In); ID.AddPointer(In);
ID.Add(From); ID.Add(From);
ID.Add(To); ID.Add(To);
@ -337,7 +343,7 @@ public:
// Implement isa<T> support. // Implement isa<T> support.
static inline bool classof(const SymExpr *SE) { static inline bool classof(const SymExpr *SE) {
return SE->getKind() == CastSymbolKind; return SE->getKind() == SymbolCastKind;
} }
}; };
@ -372,7 +378,7 @@ class SymIntExpr : public BinarySymExpr {
public: public:
SymIntExpr(const SymExpr *lhs, BinaryOperator::Opcode op, SymIntExpr(const SymExpr *lhs, BinaryOperator::Opcode op,
const llvm::APSInt& rhs, QualType t) 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; void dumpToStream(raw_ostream &os) const override;
@ -382,7 +388,7 @@ public:
static void Profile(llvm::FoldingSetNodeID& ID, const SymExpr *lhs, static void Profile(llvm::FoldingSetNodeID& ID, const SymExpr *lhs,
BinaryOperator::Opcode op, const llvm::APSInt& rhs, BinaryOperator::Opcode op, const llvm::APSInt& rhs,
QualType t) { QualType t) {
ID.AddInteger((unsigned) SymIntKind); ID.AddInteger((unsigned) SymIntExprKind);
ID.AddPointer(lhs); ID.AddPointer(lhs);
ID.AddInteger(op); ID.AddInteger(op);
ID.AddPointer(&rhs); ID.AddPointer(&rhs);
@ -395,7 +401,7 @@ public:
// Implement isa<T> support. // Implement isa<T> support.
static inline bool classof(const SymExpr *SE) { static inline bool classof(const SymExpr *SE) {
return SE->getKind() == SymIntKind; return SE->getKind() == SymIntExprKind;
} }
}; };
@ -407,7 +413,7 @@ class IntSymExpr : public BinarySymExpr {
public: public:
IntSymExpr(const llvm::APSInt& lhs, BinaryOperator::Opcode op, IntSymExpr(const llvm::APSInt& lhs, BinaryOperator::Opcode op,
const SymExpr *rhs, QualType t) 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; void dumpToStream(raw_ostream &os) const override;
@ -417,7 +423,7 @@ public:
static void Profile(llvm::FoldingSetNodeID& ID, const llvm::APSInt& lhs, static void Profile(llvm::FoldingSetNodeID& ID, const llvm::APSInt& lhs,
BinaryOperator::Opcode op, const SymExpr *rhs, BinaryOperator::Opcode op, const SymExpr *rhs,
QualType t) { QualType t) {
ID.AddInteger((unsigned) IntSymKind); ID.AddInteger((unsigned) IntSymExprKind);
ID.AddPointer(&lhs); ID.AddPointer(&lhs);
ID.AddInteger(op); ID.AddInteger(op);
ID.AddPointer(rhs); ID.AddPointer(rhs);
@ -430,7 +436,7 @@ public:
// Implement isa<T> support. // Implement isa<T> support.
static inline bool classof(const SymExpr *SE) { static inline bool classof(const SymExpr *SE) {
return SE->getKind() == IntSymKind; return SE->getKind() == IntSymExprKind;
} }
}; };
@ -442,7 +448,7 @@ class SymSymExpr : public BinarySymExpr {
public: public:
SymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs, SymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs,
QualType t) 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 *getLHS() const { return LHS; }
const SymExpr *getRHS() const { return RHS; } const SymExpr *getRHS() const { return RHS; }
@ -451,7 +457,7 @@ public:
static void Profile(llvm::FoldingSetNodeID& ID, const SymExpr *lhs, static void Profile(llvm::FoldingSetNodeID& ID, const SymExpr *lhs,
BinaryOperator::Opcode op, const SymExpr *rhs, QualType t) { BinaryOperator::Opcode op, const SymExpr *rhs, QualType t) {
ID.AddInteger((unsigned) SymSymKind); ID.AddInteger((unsigned) SymSymExprKind);
ID.AddPointer(lhs); ID.AddPointer(lhs);
ID.AddInteger(op); ID.AddInteger(op);
ID.AddPointer(rhs); ID.AddPointer(rhs);
@ -464,7 +470,7 @@ public:
// Implement isa<T> support. // Implement isa<T> support.
static inline bool classof(const SymExpr *SE) { static inline bool classof(const SymExpr *SE) {
return SE->getKind() == SymSymKind; return SE->getKind() == SymSymExprKind;
} }
}; };

View File

@ -948,15 +948,15 @@ bool CStringChecker::SummarizeRegion(raw_ostream &os, ASTContext &Ctx,
const TypedValueRegion *TVR = dyn_cast<TypedValueRegion>(MR); const TypedValueRegion *TVR = dyn_cast<TypedValueRegion>(MR);
switch (MR->getKind()) { switch (MR->getKind()) {
case MemRegion::FunctionTextRegionKind: { case MemRegion::FunctionCodeRegionKind: {
const NamedDecl *FD = cast<FunctionTextRegion>(MR)->getDecl(); const NamedDecl *FD = cast<FunctionCodeRegion>(MR)->getDecl();
if (FD) if (FD)
os << "the address of the function '" << *FD << '\''; os << "the address of the function '" << *FD << '\'';
else else
os << "the address of a function"; os << "the address of a function";
return true; return true;
} }
case MemRegion::BlockTextRegionKind: case MemRegion::BlockCodeRegionKind:
os << "block text"; os << "block text";
return true; return true;
case MemRegion::BlockDataRegionKind: case MemRegion::BlockDataRegionKind:

View File

@ -1513,15 +1513,15 @@ bool MallocChecker::SummarizeValue(raw_ostream &os, SVal V) {
bool MallocChecker::SummarizeRegion(raw_ostream &os, bool MallocChecker::SummarizeRegion(raw_ostream &os,
const MemRegion *MR) { const MemRegion *MR) {
switch (MR->getKind()) { switch (MR->getKind()) {
case MemRegion::FunctionTextRegionKind: { case MemRegion::FunctionCodeRegionKind: {
const NamedDecl *FD = cast<FunctionTextRegion>(MR)->getDecl(); const NamedDecl *FD = cast<FunctionCodeRegion>(MR)->getDecl();
if (FD) if (FD)
os << "the address of the function '" << *FD << '\''; os << "the address of the function '" << *FD << '\'';
else else
os << "the address of a function"; os << "the address of a function";
return true; return true;
} }
case MemRegion::BlockTextRegionKind: case MemRegion::BlockCodeRegionKind:
os << "block text"; os << "block text";
return true; return true;
case MemRegion::BlockDataRegionKind: case MemRegion::BlockDataRegionKind:

View File

@ -245,7 +245,7 @@ QualType CXXBaseObjectRegion::getValueType() const {
// FoldingSet profiling. // FoldingSet profiling.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
void MemSpaceRegion::Profile(llvm::FoldingSetNodeID& ID) const { void MemSpaceRegion::Profile(llvm::FoldingSetNodeID &ID) const {
ID.AddInteger((unsigned)getKind()); ID.AddInteger((unsigned)getKind());
} }
@ -357,31 +357,31 @@ void ElementRegion::Profile(llvm::FoldingSetNodeID& ID) const {
ElementRegion::ProfileRegion(ID, ElementType, Index, superRegion); ElementRegion::ProfileRegion(ID, ElementType, Index, superRegion);
} }
void FunctionTextRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, void FunctionCodeRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
const NamedDecl *FD, const NamedDecl *FD,
const MemRegion*) { const MemRegion*) {
ID.AddInteger(MemRegion::FunctionTextRegionKind); ID.AddInteger(MemRegion::FunctionCodeRegionKind);
ID.AddPointer(FD); ID.AddPointer(FD);
} }
void FunctionTextRegion::Profile(llvm::FoldingSetNodeID& ID) const { void FunctionCodeRegion::Profile(llvm::FoldingSetNodeID& ID) const {
FunctionTextRegion::ProfileRegion(ID, FD, superRegion); FunctionCodeRegion::ProfileRegion(ID, FD, superRegion);
} }
void BlockTextRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, void BlockCodeRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
const BlockDecl *BD, CanQualType, const BlockDecl *BD, CanQualType,
const AnalysisDeclContext *AC, const AnalysisDeclContext *AC,
const MemRegion*) { const MemRegion*) {
ID.AddInteger(MemRegion::BlockTextRegionKind); ID.AddInteger(MemRegion::BlockCodeRegionKind);
ID.AddPointer(BD); ID.AddPointer(BD);
} }
void BlockTextRegion::Profile(llvm::FoldingSetNodeID& ID) const { void BlockCodeRegion::Profile(llvm::FoldingSetNodeID& ID) const {
BlockTextRegion::ProfileRegion(ID, BD, locTy, AC, superRegion); BlockCodeRegion::ProfileRegion(ID, BD, locTy, AC, superRegion);
} }
void BlockDataRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, void BlockDataRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
const BlockTextRegion *BC, const BlockCodeRegion *BC,
const LocationContext *LC, const LocationContext *LC,
unsigned BlkCount, unsigned BlkCount,
const MemRegion *sReg) { const MemRegion *sReg) {
@ -457,11 +457,11 @@ void AllocaRegion::dumpToStream(raw_ostream &os) const {
os << "alloca{" << (const void*) Ex << ',' << Cnt << '}'; 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() << '}'; 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 << '}'; os << "block_code{" << (const void*) this << '}';
} }
@ -533,6 +533,10 @@ void RegionRawOffset::dumpToStream(raw_ostream &os) const {
os << "raw_offset{" << getRegion() << ',' << getOffset().getQuantity() << '}'; os << "raw_offset{" << getRegion() << ',' << getOffset().getQuantity() << '}';
} }
void CodeSpaceRegion::dumpToStream(raw_ostream &os) const {
os << "CodeSpaceRegion";
}
void StaticGlobalSpaceRegion::dumpToStream(raw_ostream &os) const { void StaticGlobalSpaceRegion::dumpToStream(raw_ostream &os) const {
os << "StaticGlobalsMemSpace{" << CR << '}'; os << "StaticGlobalsMemSpace{" << CR << '}';
} }
@ -711,11 +715,11 @@ const HeapSpaceRegion *MemRegionManager::getHeapRegion() {
return LazyAllocate(heap); return LazyAllocate(heap);
} }
const MemSpaceRegion *MemRegionManager::getUnknownRegion() { const UnknownSpaceRegion *MemRegionManager::getUnknownRegion() {
return LazyAllocate(unknown); return LazyAllocate(unknown);
} }
const MemSpaceRegion *MemRegionManager::getCodeRegion() { const CodeSpaceRegion *MemRegionManager::getCodeRegion() {
return LazyAllocate(code); return LazyAllocate(code);
} }
@ -815,11 +819,11 @@ const VarRegion* MemRegionManager::getVarRegion(const VarDecl *D,
const Decl *STCD = STC->getDecl(); const Decl *STCD = STC->getDecl();
if (isa<FunctionDecl>(STCD) || isa<ObjCMethodDecl>(STCD)) if (isa<FunctionDecl>(STCD) || isa<ObjCMethodDecl>(STCD))
sReg = getGlobalsRegion(MemRegion::StaticGlobalSpaceRegionKind, sReg = getGlobalsRegion(MemRegion::StaticGlobalSpaceRegionKind,
getFunctionTextRegion(cast<NamedDecl>(STCD))); getFunctionCodeRegion(cast<NamedDecl>(STCD)));
else if (const BlockDecl *BD = dyn_cast<BlockDecl>(STCD)) { else if (const BlockDecl *BD = dyn_cast<BlockDecl>(STCD)) {
// FIXME: The fallback type here is totally bogus -- though it should // FIXME: The fallback type here is totally bogus -- though it should
// never be queried, it will prevent uniquing with the real // 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. // signature.
QualType T; QualType T;
if (const TypeSourceInfo *TSI = BD->getSignatureAsWritten()) if (const TypeSourceInfo *TSI = BD->getSignatureAsWritten())
@ -830,8 +834,8 @@ const VarRegion* MemRegionManager::getVarRegion(const VarDecl *D,
T = getContext().getFunctionNoProtoType(T); T = getContext().getFunctionNoProtoType(T);
T = getContext().getBlockPointerType(T); T = getContext().getBlockPointerType(T);
const BlockTextRegion *BTR = const BlockCodeRegion *BTR =
getBlockTextRegion(BD, C.getCanonicalType(T), getBlockCodeRegion(BD, C.getCanonicalType(T),
STC->getAnalysisDeclContext()); STC->getAnalysisDeclContext());
sReg = getGlobalsRegion(MemRegion::StaticGlobalSpaceRegionKind, sReg = getGlobalsRegion(MemRegion::StaticGlobalSpaceRegionKind,
BTR); BTR);
@ -852,7 +856,7 @@ const VarRegion *MemRegionManager::getVarRegion(const VarDecl *D,
} }
const BlockDataRegion * const BlockDataRegion *
MemRegionManager::getBlockDataRegion(const BlockTextRegion *BC, MemRegionManager::getBlockDataRegion(const BlockCodeRegion *BC,
const LocationContext *LC, const LocationContext *LC,
unsigned blockCount) { unsigned blockCount) {
const MemRegion *sReg = nullptr; const MemRegion *sReg = nullptr;
@ -925,15 +929,15 @@ MemRegionManager::getElementRegion(QualType elementType, NonLoc Idx,
return R; return R;
} }
const FunctionTextRegion * const FunctionCodeRegion *
MemRegionManager::getFunctionTextRegion(const NamedDecl *FD) { MemRegionManager::getFunctionCodeRegion(const NamedDecl *FD) {
return getSubRegion<FunctionTextRegion>(FD, getCodeRegion()); return getSubRegion<FunctionCodeRegion>(FD, getCodeRegion());
} }
const BlockTextRegion * const BlockCodeRegion *
MemRegionManager::getBlockTextRegion(const BlockDecl *BD, CanQualType locTy, MemRegionManager::getBlockCodeRegion(const BlockDecl *BD, CanQualType locTy,
AnalysisDeclContext *AC) { 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) { while (1) {
switch (R->getKind()) { switch (R->getKind()) {
case GenericMemSpaceRegionKind: case CodeSpaceRegionKind:
case StackLocalsSpaceRegionKind: case StackLocalsSpaceRegionKind:
case StackArgumentsSpaceRegionKind: case StackArgumentsSpaceRegionKind:
case HeapSpaceRegionKind: case HeapSpaceRegionKind:
@ -1209,8 +1213,8 @@ RegionOffset MemRegion::getAsOffset() const {
assert(Offset == 0 && !SymbolicOffsetBase); assert(Offset == 0 && !SymbolicOffsetBase);
goto Finish; goto Finish;
case FunctionTextRegionKind: case FunctionCodeRegionKind:
case BlockTextRegionKind: case BlockCodeRegionKind:
case BlockDataRegionKind: case BlockDataRegionKind:
// These will never have bindings, but may end up having values requested // These will never have bindings, but may end up having values requested
// if the user does some strange casting. // if the user does some strange casting.

View File

@ -536,19 +536,19 @@ bool ScanReachableSymbols::scan(const SymExpr *sym) {
// TODO: should be rewritten using SymExpr::symbol_iterator. // TODO: should be rewritten using SymExpr::symbol_iterator.
switch (sym->getKind()) { switch (sym->getKind()) {
case SymExpr::RegionValueKind: case SymExpr::SymbolRegionValueKind:
case SymExpr::ConjuredKind: case SymExpr::SymbolConjuredKind:
case SymExpr::DerivedKind: case SymExpr::SymbolDerivedKind:
case SymExpr::ExtentKind: case SymExpr::SymbolExtentKind:
case SymExpr::MetadataKind: case SymExpr::SymbolMetadataKind:
break; break;
case SymExpr::CastSymbolKind: case SymExpr::SymbolCastKind:
return scan(cast<SymbolCast>(sym)->getOperand()); return scan(cast<SymbolCast>(sym)->getOperand());
case SymExpr::SymIntKind: case SymExpr::SymIntExprKind:
return scan(cast<SymIntExpr>(sym)->getLHS()); return scan(cast<SymIntExpr>(sym)->getLHS());
case SymExpr::IntSymKind: case SymExpr::IntSymExprKind:
return scan(cast<IntSymExpr>(sym)->getRHS()); return scan(cast<IntSymExpr>(sym)->getRHS());
case SymExpr::SymSymKind: { case SymExpr::SymSymExprKind: {
const SymSymExpr *x = cast<SymSymExpr>(sym); const SymSymExpr *x = cast<SymSymExpr>(sym);
return scan(x->getLHS()) && scan(x->getRHS()); return scan(x->getLHS()) && scan(x->getRHS());
} }

View File

@ -214,15 +214,15 @@ SValBuilder::getDerivedRegionValueSymbolVal(SymbolRef parentSymbol,
} }
DefinedSVal SValBuilder::getFunctionPointer(const FunctionDecl *func) { DefinedSVal SValBuilder::getFunctionPointer(const FunctionDecl *func) {
return loc::MemRegionVal(MemMgr.getFunctionTextRegion(func)); return loc::MemRegionVal(MemMgr.getFunctionCodeRegion(func));
} }
DefinedSVal SValBuilder::getBlockPointer(const BlockDecl *block, DefinedSVal SValBuilder::getBlockPointer(const BlockDecl *block,
CanQualType locTy, CanQualType locTy,
const LocationContext *locContext, const LocationContext *locContext,
unsigned blockCount) { unsigned blockCount) {
const BlockTextRegion *BC = const BlockCodeRegion *BC =
MemMgr.getBlockTextRegion(block, locTy, locContext->getAnalysisDeclContext()); MemMgr.getBlockCodeRegion(block, locTy, locContext->getAnalysisDeclContext());
const BlockDataRegion *BD = MemMgr.getBlockDataRegion(BC, locContext, const BlockDataRegion *BD = MemMgr.getBlockDataRegion(BC, locContext,
blockCount); blockCount);
return loc::MemRegionVal(BD); return loc::MemRegionVal(BD);

View File

@ -51,7 +51,7 @@ bool SVal::hasConjuredSymbol() const {
const FunctionDecl *SVal::getAsFunctionDecl() const { const FunctionDecl *SVal::getAsFunctionDecl() const {
if (Optional<loc::MemRegionVal> X = getAs<loc::MemRegionVal>()) { if (Optional<loc::MemRegionVal> X = getAs<loc::MemRegionVal>()) {
const MemRegion* R = X->getRegion(); 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())) if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CTR->getDecl()))
return FD; return FD;
} }
@ -240,7 +240,7 @@ void SVal::dump() const { dumpToStream(llvm::errs()); }
void SVal::dumpToStream(raw_ostream &os) const { void SVal::dumpToStream(raw_ostream &os) const {
switch (getBaseKind()) { switch (getBaseKind()) {
case UnknownKind: case UnknownValKind:
os << "Unknown"; os << "Unknown";
break; break;
case NonLocKind: case NonLocKind:
@ -249,7 +249,7 @@ void SVal::dumpToStream(raw_ostream &os) const {
case LocKind: case LocKind:
castAs<Loc>().dumpToStream(os); castAs<Loc>().dumpToStream(os);
break; break;
case UndefinedKind: case UndefinedValKind:
os << "Undefined"; os << "Undefined";
break; break;
} }
@ -313,7 +313,7 @@ void Loc::dumpToStream(raw_ostream &os) const {
case loc::GotoLabelKind: case loc::GotoLabelKind:
os << "&&" << castAs<loc::GotoLabel>().getLabel()->getName(); os << "&&" << castAs<loc::GotoLabel>().getLabel()->getName();
break; break;
case loc::MemRegionKind: case loc::MemRegionValKind:
os << '&' << castAs<loc::MemRegionVal>().getRegion()->getString(); os << '&' << castAs<loc::MemRegionVal>().getRegion()->getString();
break; break;
default: default:

View File

@ -141,9 +141,9 @@ SVal SimpleSValBuilder::evalCastFromLoc(Loc val, QualType castTy) {
// unless this is a weak function or a symbolic region. // unless this is a weak function or a symbolic region.
if (castTy->isBooleanType()) { if (castTy->isBooleanType()) {
switch (val.getSubKind()) { switch (val.getSubKind()) {
case loc::MemRegionKind: { case loc::MemRegionValKind: {
const MemRegion *R = val.castAs<loc::MemRegionVal>().getRegion(); 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 (const FunctionDecl *FD = dyn_cast<FunctionDecl>(FTR->getDecl()))
if (FD->isWeak()) if (FD->isWeak())
// FIXME: Currently we are using an extent symbol here, // FIXME: Currently we are using an extent symbol here,
@ -689,7 +689,7 @@ SVal SimpleSValBuilder::evalBinOpLL(ProgramStateRef state,
// completely unknowable. // completely unknowable.
return UnknownVal(); return UnknownVal();
} }
case loc::MemRegionKind: { case loc::MemRegionValKind: {
if (Optional<loc::ConcreteInt> rInt = rhs.getAs<loc::ConcreteInt>()) { if (Optional<loc::ConcreteInt> rInt = rhs.getAs<loc::ConcreteInt>()) {
// If one of the operands is a symbol and the other is a constant, // If one of the operands is a symbol and the other is a constant,
// build an expression for use by the constraint manager. // 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. // Get both values as regions, if possible.
const MemRegion *LeftMR = lhs.getAsRegion(); 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(); const MemRegion *RightMR = rhs.getAsRegion();
if (!RightMR) if (!RightMR)

View File

@ -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. // Process region cast according to the kind of the region being cast.
switch (R->getKind()) { switch (R->getKind()) {
case MemRegion::CXXThisRegionKind: case MemRegion::CXXThisRegionKind:
case MemRegion::GenericMemSpaceRegionKind: case MemRegion::CodeSpaceRegionKind:
case MemRegion::StackLocalsSpaceRegionKind: case MemRegion::StackLocalsSpaceRegionKind:
case MemRegion::StackArgumentsSpaceRegionKind: case MemRegion::StackArgumentsSpaceRegionKind:
case MemRegion::HeapSpaceRegionKind: case MemRegion::HeapSpaceRegionKind:
@ -112,8 +112,8 @@ const MemRegion *StoreManager::castRegion(const MemRegion *R, QualType CastToTy)
llvm_unreachable("Invalid region cast"); llvm_unreachable("Invalid region cast");
} }
case MemRegion::FunctionTextRegionKind: case MemRegion::FunctionCodeRegionKind:
case MemRegion::BlockTextRegionKind: case MemRegion::BlockCodeRegionKind:
case MemRegion::BlockDataRegionKind: case MemRegion::BlockDataRegionKind:
case MemRegion::StringRegionKind: case MemRegion::StringRegionKind:
// FIXME: Need to handle arbitrary downcasts. // FIXME: Need to handle arbitrary downcasts.
@ -393,7 +393,7 @@ SVal StoreManager::getLValueFieldOrIvar(const Decl *D, SVal Base) {
const MemRegion* BaseR = nullptr; const MemRegion* BaseR = nullptr;
switch (BaseL.getSubKind()) { switch (BaseL.getSubKind()) {
case loc::MemRegionKind: case loc::MemRegionValKind:
BaseR = BaseL.castAs<loc::MemRegionVal>().getRegion(); BaseR = BaseL.castAs<loc::MemRegionVal>().getRegion();
break; break;

View File

@ -115,22 +115,22 @@ void SymExpr::symbol_iterator::expand() {
const SymExpr *SE = itr.pop_back_val(); const SymExpr *SE = itr.pop_back_val();
switch (SE->getKind()) { switch (SE->getKind()) {
case SymExpr::RegionValueKind: case SymExpr::SymbolRegionValueKind:
case SymExpr::ConjuredKind: case SymExpr::SymbolConjuredKind:
case SymExpr::DerivedKind: case SymExpr::SymbolDerivedKind:
case SymExpr::ExtentKind: case SymExpr::SymbolExtentKind:
case SymExpr::MetadataKind: case SymExpr::SymbolMetadataKind:
return; return;
case SymExpr::CastSymbolKind: case SymExpr::SymbolCastKind:
itr.push_back(cast<SymbolCast>(SE)->getOperand()); itr.push_back(cast<SymbolCast>(SE)->getOperand());
return; return;
case SymExpr::SymIntKind: case SymExpr::SymIntExprKind:
itr.push_back(cast<SymIntExpr>(SE)->getLHS()); itr.push_back(cast<SymIntExpr>(SE)->getLHS());
return; return;
case SymExpr::IntSymKind: case SymExpr::IntSymExprKind:
itr.push_back(cast<IntSymExpr>(SE)->getRHS()); itr.push_back(cast<IntSymExpr>(SE)->getRHS());
return; return;
case SymExpr::SymSymKind: { case SymExpr::SymSymExprKind: {
const SymSymExpr *x = cast<SymSymExpr>(SE); const SymSymExpr *x = cast<SymSymExpr>(SE);
itr.push_back(x->getLHS()); itr.push_back(x->getLHS());
itr.push_back(x->getRHS()); itr.push_back(x->getRHS());
@ -458,35 +458,35 @@ bool SymbolReaper::isLive(SymbolRef sym) {
bool KnownLive; bool KnownLive;
switch (sym->getKind()) { switch (sym->getKind()) {
case SymExpr::RegionValueKind: case SymExpr::SymbolRegionValueKind:
KnownLive = isLiveRegion(cast<SymbolRegionValue>(sym)->getRegion()); KnownLive = isLiveRegion(cast<SymbolRegionValue>(sym)->getRegion());
break; break;
case SymExpr::ConjuredKind: case SymExpr::SymbolConjuredKind:
KnownLive = false; KnownLive = false;
break; break;
case SymExpr::DerivedKind: case SymExpr::SymbolDerivedKind:
KnownLive = isLive(cast<SymbolDerived>(sym)->getParentSymbol()); KnownLive = isLive(cast<SymbolDerived>(sym)->getParentSymbol());
break; break;
case SymExpr::ExtentKind: case SymExpr::SymbolExtentKind:
KnownLive = isLiveRegion(cast<SymbolExtent>(sym)->getRegion()); KnownLive = isLiveRegion(cast<SymbolExtent>(sym)->getRegion());
break; break;
case SymExpr::MetadataKind: case SymExpr::SymbolMetadataKind:
KnownLive = MetadataInUse.count(sym) && KnownLive = MetadataInUse.count(sym) &&
isLiveRegion(cast<SymbolMetadata>(sym)->getRegion()); isLiveRegion(cast<SymbolMetadata>(sym)->getRegion());
if (KnownLive) if (KnownLive)
MetadataInUse.erase(sym); MetadataInUse.erase(sym);
break; break;
case SymExpr::SymIntKind: case SymExpr::SymIntExprKind:
KnownLive = isLive(cast<SymIntExpr>(sym)->getLHS()); KnownLive = isLive(cast<SymIntExpr>(sym)->getLHS());
break; break;
case SymExpr::IntSymKind: case SymExpr::IntSymExprKind:
KnownLive = isLive(cast<IntSymExpr>(sym)->getRHS()); KnownLive = isLive(cast<IntSymExpr>(sym)->getRHS());
break; break;
case SymExpr::SymSymKind: case SymExpr::SymSymExprKind:
KnownLive = isLive(cast<SymSymExpr>(sym)->getLHS()) && KnownLive = isLive(cast<SymSymExpr>(sym)->getLHS()) &&
isLive(cast<SymSymExpr>(sym)->getRHS()); isLive(cast<SymSymExpr>(sym)->getRHS());
break; break;
case SymExpr::CastSymbolKind: case SymExpr::SymbolCastKind:
KnownLive = isLive(cast<SymbolCast>(sym)->getOperand()); KnownLive = isLive(cast<SymbolCast>(sym)->getOperand());
break; break;
} }