Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h =================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h @@ -80,7 +80,7 @@ public: enum Kind { // Memory spaces. - GenericMemSpaceRegionKind, + CodeSpaceRegionKind, StackLocalsSpaceRegionKind, StackArgumentsSpaceRegionKind, HeapSpaceRegionKind, @@ -89,29 +89,29 @@ 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 @@ /// 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 @@ 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 @@ 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 @@ /// 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 @@ return R->getKind() == UnknownSpaceRegionKind; } }; - + class StackSpaceRegion : public MemSpaceRegion { private: const StackFrameContext *SFC; @@ -368,18 +379,18 @@ 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 @@ 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 @@ 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 @@ 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(fd) || isa(fd)); } @@ -577,27 +588,27 @@ 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 @@ 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 @@ 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 @@ 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 @@ HeapSpaceRegion *heap; UnknownSpaceRegion *unknown; - MemSpaceRegion *code; + CodeSpaceRegion *code; public: MemRegionManager(ASTContext &c, llvm::BumpPtrAllocator &a) @@ -1174,9 +1185,9 @@ /// 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 @@ 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 @@ /// 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); Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h =================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h @@ -45,8 +45,8 @@ 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 @@ } 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 @@ 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 @@ 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 @@ namespace loc { -enum Kind { GotoLabelKind, MemRegionKind, ConcreteIntKind }; +enum Kind { GotoLabelKind, MemRegionValKind, ConcreteIntKind }; class GotoLabel : public Loc { public: @@ -490,7 +490,7 @@ 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 @@ 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; } }; Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h =================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h @@ -42,14 +42,22 @@ 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 @@ 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 @@ // Implement isa support. static inline bool classof(const SymExpr *SE) { - return SE->getKind() == RegionValueKind; + return SE->getKind() == SymbolRegionValueKind; } }; @@ -160,11 +168,9 @@ 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 @@ 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 @@ // Implement isa support. static inline bool classof(const SymExpr *SE) { - return SE->getKind() == ConjuredKind; + return SE->getKind() == SymbolConjuredKind; } }; @@ -203,7 +209,7 @@ 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 @@ 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 @@ // Implement isa support. static inline bool classof(const SymExpr *SE) { - return SE->getKind() == DerivedKind; + return SE->getKind() == SymbolDerivedKind; } }; @@ -237,7 +243,7 @@ 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 @@ 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 @@ // Implement isa support. static inline bool classof(const SymExpr *SE) { - return SE->getKind() == ExtentKind; + return SE->getKind() == SymbolExtentKind; } }; @@ -273,7 +279,7 @@ 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 @@ 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 @@ // Implement isa support. static inline bool classof(const SymExpr *SE) { - return SE->getKind() == MetadataKind; + return SE->getKind() == SymbolMetadataKind; } }; @@ -315,7 +321,7 @@ 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 @@ 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 @@ // Implement isa support. static inline bool classof(const SymExpr *SE) { - return SE->getKind() == CastSymbolKind; + return SE->getKind() == SymbolCastKind; } }; @@ -372,7 +378,7 @@ 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 @@ 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 @@ // Implement isa support. static inline bool classof(const SymExpr *SE) { - return SE->getKind() == SymIntKind; + return SE->getKind() == SymIntExprKind; } }; @@ -407,7 +413,7 @@ 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 @@ 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 @@ // Implement isa support. static inline bool classof(const SymExpr *SE) { - return SE->getKind() == IntSymKind; + return SE->getKind() == IntSymExprKind; } }; @@ -442,7 +448,7 @@ 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 @@ 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 @@ // Implement isa support. static inline bool classof(const SymExpr *SE) { - return SE->getKind() == SymSymKind; + return SE->getKind() == SymSymExprKind; } }; Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -948,15 +948,15 @@ const TypedValueRegion *TVR = dyn_cast(MR); switch (MR->getKind()) { - case MemRegion::FunctionTextRegionKind: { - const NamedDecl *FD = cast(MR)->getDecl(); + case MemRegion::FunctionCodeRegionKind: { + const NamedDecl *FD = cast(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: Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -1513,15 +1513,15 @@ bool MallocChecker::SummarizeRegion(raw_ostream &os, const MemRegion *MR) { switch (MR->getKind()) { - case MemRegion::FunctionTextRegionKind: { - const NamedDecl *FD = cast(MR)->getDecl(); + case MemRegion::FunctionCodeRegionKind: { + const NamedDecl *FD = cast(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: Index: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp @@ -245,7 +245,7 @@ // FoldingSet profiling. //===----------------------------------------------------------------------===// -void MemSpaceRegion::Profile(llvm::FoldingSetNodeID& ID) const { +void MemSpaceRegion::Profile(llvm::FoldingSetNodeID &ID) const { ID.AddInteger((unsigned)getKind()); } @@ -357,31 +357,31 @@ 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 @@ 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 @@ 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 @@ 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 Decl *STCD = STC->getDecl(); if (isa(STCD) || isa(STCD)) sReg = getGlobalsRegion(MemRegion::StaticGlobalSpaceRegionKind, - getFunctionTextRegion(cast(STCD))); + getFunctionCodeRegion(cast(STCD))); else if (const BlockDecl *BD = dyn_cast(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 @@ 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 BlockDataRegion * -MemRegionManager::getBlockDataRegion(const BlockTextRegion *BC, +MemRegionManager::getBlockDataRegion(const BlockCodeRegion *BC, const LocationContext *LC, unsigned blockCount) { const MemRegion *sReg = nullptr; @@ -925,15 +929,15 @@ return R; } -const FunctionTextRegion * -MemRegionManager::getFunctionTextRegion(const NamedDecl *FD) { - return getSubRegion(FD, getCodeRegion()); +const FunctionCodeRegion * +MemRegionManager::getFunctionCodeRegion(const NamedDecl *FD) { + return getSubRegion(FD, getCodeRegion()); } -const BlockTextRegion * -MemRegionManager::getBlockTextRegion(const BlockDecl *BD, CanQualType locTy, +const BlockCodeRegion * +MemRegionManager::getBlockCodeRegion(const BlockDecl *BD, CanQualType locTy, AnalysisDeclContext *AC) { - return getSubRegion(BD, locTy, AC, getCodeRegion()); + return getSubRegion(BD, locTy, AC, getCodeRegion()); } @@ -1196,7 +1200,7 @@ while (1) { switch (R->getKind()) { - case GenericMemSpaceRegionKind: + case CodeSpaceRegionKind: case StackLocalsSpaceRegionKind: case StackArgumentsSpaceRegionKind: case HeapSpaceRegionKind: @@ -1209,8 +1213,8 @@ 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. Index: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp @@ -536,19 +536,19 @@ // 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(sym)->getOperand()); - case SymExpr::SymIntKind: + case SymExpr::SymIntExprKind: return scan(cast(sym)->getLHS()); - case SymExpr::IntSymKind: + case SymExpr::IntSymExprKind: return scan(cast(sym)->getRHS()); - case SymExpr::SymSymKind: { + case SymExpr::SymSymExprKind: { const SymSymExpr *x = cast(sym); return scan(x->getLHS()) && scan(x->getRHS()); } Index: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp @@ -214,15 +214,15 @@ } 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); Index: cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp @@ -51,7 +51,7 @@ const FunctionDecl *SVal::getAsFunctionDecl() const { if (Optional X = getAs()) { const MemRegion* R = X->getRegion(); - if (const FunctionTextRegion *CTR = R->getAs()) + if (const FunctionCodeRegion *CTR = R->getAs()) if (const FunctionDecl *FD = dyn_cast(CTR->getDecl())) return FD; } @@ -240,7 +240,7 @@ void SVal::dumpToStream(raw_ostream &os) const { switch (getBaseKind()) { - case UnknownKind: + case UnknownValKind: os << "Unknown"; break; case NonLocKind: @@ -249,7 +249,7 @@ case LocKind: castAs().dumpToStream(os); break; - case UndefinedKind: + case UndefinedValKind: os << "Undefined"; break; } @@ -313,7 +313,7 @@ case loc::GotoLabelKind: os << "&&" << castAs().getLabel()->getName(); break; - case loc::MemRegionKind: + case loc::MemRegionValKind: os << '&' << castAs().getRegion()->getString(); break; default: Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp @@ -141,9 +141,9 @@ // 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().getRegion(); - if (const FunctionTextRegion *FTR = dyn_cast(R)) + if (const FunctionCodeRegion *FTR = dyn_cast(R)) if (const FunctionDecl *FD = dyn_cast(FTR->getDecl())) if (FD->isWeak()) // FIXME: Currently we are using an extent symbol here, @@ -689,7 +689,7 @@ // completely unknowable. return UnknownVal(); } - case loc::MemRegionKind: { + case loc::MemRegionValKind: { if (Optional rInt = rhs.getAs()) { // 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 @@ // 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) Index: cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp @@ -100,7 +100,7 @@ // 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 @@ 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 @@ const MemRegion* BaseR = nullptr; switch (BaseL.getSubKind()) { - case loc::MemRegionKind: + case loc::MemRegionValKind: BaseR = BaseL.castAs().getRegion(); break; Index: cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp @@ -115,22 +115,22 @@ 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(SE)->getOperand()); return; - case SymExpr::SymIntKind: + case SymExpr::SymIntExprKind: itr.push_back(cast(SE)->getLHS()); return; - case SymExpr::IntSymKind: + case SymExpr::IntSymExprKind: itr.push_back(cast(SE)->getRHS()); return; - case SymExpr::SymSymKind: { + case SymExpr::SymSymExprKind: { const SymSymExpr *x = cast(SE); itr.push_back(x->getLHS()); itr.push_back(x->getRHS()); @@ -458,35 +458,35 @@ bool KnownLive; switch (sym->getKind()) { - case SymExpr::RegionValueKind: + case SymExpr::SymbolRegionValueKind: KnownLive = isLiveRegion(cast(sym)->getRegion()); break; - case SymExpr::ConjuredKind: + case SymExpr::SymbolConjuredKind: KnownLive = false; break; - case SymExpr::DerivedKind: + case SymExpr::SymbolDerivedKind: KnownLive = isLive(cast(sym)->getParentSymbol()); break; - case SymExpr::ExtentKind: + case SymExpr::SymbolExtentKind: KnownLive = isLiveRegion(cast(sym)->getRegion()); break; - case SymExpr::MetadataKind: + case SymExpr::SymbolMetadataKind: KnownLive = MetadataInUse.count(sym) && isLiveRegion(cast(sym)->getRegion()); if (KnownLive) MetadataInUse.erase(sym); break; - case SymExpr::SymIntKind: + case SymExpr::SymIntExprKind: KnownLive = isLive(cast(sym)->getLHS()); break; - case SymExpr::IntSymKind: + case SymExpr::IntSymExprKind: KnownLive = isLive(cast(sym)->getRHS()); break; - case SymExpr::SymSymKind: + case SymExpr::SymSymExprKind: KnownLive = isLive(cast(sym)->getLHS()) && isLive(cast(sym)->getRHS()); break; - case SymExpr::CastSymbolKind: + case SymExpr::SymbolCastKind: KnownLive = isLive(cast(sym)->getOperand()); break; }