Date: Tue, 23 Jun 2009 14:50:21 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r194711 - in vendor/clang/dist: include/clang/AST include/clang/Analysis/PathSensitive include/clang/Basic include/clang/Parse lib/AST lib/Analysis lib/Basic lib/CodeGen lib/Frontend li... Message-ID: <200906231450.n5NEoLv7079417@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Tue Jun 23 14:50:21 2009 New Revision: 194711 URL: http://svn.freebsd.org/changeset/base/194711 Log: Import Clang r73954. Added: vendor/clang/dist/lib/Analysis/ValueManager.cpp vendor/clang/dist/test/CodeGenCXX/implicit-instantiation-1.cpp vendor/clang/dist/test/SemaTemplate/implicit-instantiation-1.cpp Modified: vendor/clang/dist/include/clang/AST/Decl.h vendor/clang/dist/include/clang/AST/DeclCXX.h vendor/clang/dist/include/clang/AST/DeclTemplate.h vendor/clang/dist/include/clang/Analysis/PathSensitive/Environment.h vendor/clang/dist/include/clang/Analysis/PathSensitive/GRExprEngine.h vendor/clang/dist/include/clang/Analysis/PathSensitive/GRState.h vendor/clang/dist/include/clang/Analysis/PathSensitive/MemRegion.h vendor/clang/dist/include/clang/Analysis/PathSensitive/SVals.h vendor/clang/dist/include/clang/Analysis/PathSensitive/ValueManager.h vendor/clang/dist/include/clang/Basic/DiagnosticFrontendKinds.td vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td vendor/clang/dist/include/clang/Basic/SourceLocation.h vendor/clang/dist/include/clang/Parse/Action.h vendor/clang/dist/include/clang/Parse/Parser.h vendor/clang/dist/lib/AST/Decl.cpp vendor/clang/dist/lib/AST/DeclCXX.cpp vendor/clang/dist/lib/AST/DeclTemplate.cpp vendor/clang/dist/lib/Analysis/BasicStore.cpp vendor/clang/dist/lib/Analysis/CFRefCount.cpp vendor/clang/dist/lib/Analysis/Environment.cpp vendor/clang/dist/lib/Analysis/GRExprEngine.cpp vendor/clang/dist/lib/Analysis/GRExprEngineInternalChecks.cpp vendor/clang/dist/lib/Analysis/GRSimpleVals.cpp vendor/clang/dist/lib/Analysis/MemRegion.cpp vendor/clang/dist/lib/Analysis/RegionStore.cpp vendor/clang/dist/lib/Analysis/SVals.cpp vendor/clang/dist/lib/Basic/SourceManager.cpp vendor/clang/dist/lib/Basic/Targets.cpp vendor/clang/dist/lib/CodeGen/CGCall.cpp vendor/clang/dist/lib/Frontend/InitPreprocessor.cpp vendor/clang/dist/lib/Frontend/Warnings.cpp vendor/clang/dist/lib/Lex/Lexer.cpp vendor/clang/dist/lib/Parse/ParseDecl.cpp vendor/clang/dist/lib/Parse/ParseExpr.cpp vendor/clang/dist/lib/Parse/ParseExprCXX.cpp vendor/clang/dist/lib/Parse/ParseTemplate.cpp vendor/clang/dist/lib/Sema/Sema.cpp vendor/clang/dist/lib/Sema/Sema.h vendor/clang/dist/lib/Sema/SemaDecl.cpp vendor/clang/dist/lib/Sema/SemaDeclCXX.cpp vendor/clang/dist/lib/Sema/SemaExpr.cpp vendor/clang/dist/lib/Sema/SemaExprCXX.cpp vendor/clang/dist/lib/Sema/SemaTemplate.cpp vendor/clang/dist/lib/Sema/SemaTemplateDeduction.cpp vendor/clang/dist/lib/Sema/SemaTemplateInstantiate.cpp vendor/clang/dist/lib/Sema/SemaTemplateInstantiateDecl.cpp vendor/clang/dist/lib/Sema/SemaTemplateInstantiateExpr.cpp vendor/clang/dist/lib/Sema/SemaTemplateInstantiateStmt.cpp vendor/clang/dist/test/CodeGen/functions.c vendor/clang/dist/test/SemaCXX/default-constructor-initializers.cpp vendor/clang/dist/test/SemaTemplate/class-template-decl.cpp vendor/clang/dist/test/SemaTemplate/example-dynarray.cpp Modified: vendor/clang/dist/include/clang/AST/Decl.h ============================================================================== --- vendor/clang/dist/include/clang/AST/Decl.h Tue Jun 23 14:50:01 2009 (r194710) +++ vendor/clang/dist/include/clang/AST/Decl.h Tue Jun 23 14:50:21 2009 (r194711) @@ -647,6 +647,13 @@ private: // Move to DeclGroup when it is implemented. SourceLocation TypeSpecStartLoc; + /// \brief End part of this FunctionDecl's source range. + /// + /// We could compute the full range in getSourceRange(). However, when we're + /// dealing with a function definition deserialized from a PCH/AST file, + /// we can only compute the full range once the function body has been + /// de-serialized, so it's far better to have the (sometimes-redundant) + /// EndRangeLoc. SourceLocation EndRangeLoc; /// \brief The template or declaration that this declaration @@ -687,7 +694,6 @@ public: return SourceRange(getLocation(), EndRangeLoc); } void setLocEnd(SourceLocation E) { - assert(getLocation() <= E && "Invalid end location"); EndRangeLoc = E; } Modified: vendor/clang/dist/include/clang/AST/DeclCXX.h ============================================================================== --- vendor/clang/dist/include/clang/AST/DeclCXX.h Tue Jun 23 14:50:01 2009 (r194710) +++ vendor/clang/dist/include/clang/AST/DeclCXX.h Tue Jun 23 14:50:21 2009 (r194711) @@ -283,6 +283,10 @@ public: /// copy constructor that accepts a const-qualified argument. bool hasConstCopyConstructor(ASTContext &Context) const; + /// getCopyConstructor - Returns the copy constructor for this class + CXXConstructorDecl *getCopyConstructor(ASTContext &Context, + unsigned TypeQuals) const; + /// hasConstCopyAssignment - Determines whether this class has a /// copy assignment operator that accepts a const-qualified argument. bool hasConstCopyAssignment(ASTContext &Context) const; @@ -642,18 +646,13 @@ class CXXConstructorDecl : public CXXMet /// @c !Implicit && ImplicitlyDefined. bool ImplicitlyDefined : 1; - /// ImplicitMustBeDefined - Implicit constructor was used to create an - /// object of its class type. It must be defined. - bool ImplicitMustBeDefined : 1; - /// FIXME: Add support for base and member initializers. CXXConstructorDecl(CXXRecordDecl *RD, SourceLocation L, DeclarationName N, QualType T, bool isExplicit, bool isInline, bool isImplicitlyDeclared) : CXXMethodDecl(CXXConstructor, RD, L, N, T, false, isInline), - Explicit(isExplicit), ImplicitlyDefined(false), - ImplicitMustBeDefined(false) { + Explicit(isExplicit), ImplicitlyDefined(false) { setImplicit(isImplicitlyDeclared); } @@ -683,17 +682,6 @@ public: "Can only set the implicit-definition flag once the constructor has been defined"); ImplicitlyDefined = ID; } - - /// isImplicitMustBeDefined - Whether a definition must be synthesized for - /// the implicit constructor. - bool isImplicitMustBeDefined() const { - return isImplicit() && ImplicitMustBeDefined; - } - - /// setImplicitMustBeDefined - constructor must be implicitly defined. - void setImplicitMustBeDefined() { - ImplicitMustBeDefined = true; - } /// isDefaultConstructor - Whether this constructor is a default /// constructor (C++ [class.ctor]p5), which can be used to Modified: vendor/clang/dist/include/clang/AST/DeclTemplate.h ============================================================================== --- vendor/clang/dist/include/clang/AST/DeclTemplate.h Tue Jun 23 14:50:01 2009 (r194710) +++ vendor/clang/dist/include/clang/AST/DeclTemplate.h Tue Jun 23 14:50:21 2009 (r194711) @@ -469,10 +469,6 @@ public: /// occur in a non-dependent, canonical template argument list. TemplateArgument(Expr *E); - /// \brief Construct a template argument pack. - TemplateArgument(SourceLocation Loc, TemplateArgument *Args, - unsigned NumArgs, bool CopyArgs); - /// \brief Copy constructor for a template argument. TemplateArgument(const TemplateArgument &Other) : Kind(Other.Kind) { if (Kind == Integral) { @@ -587,6 +583,9 @@ public: /// \brief Retrieve the location where the template argument starts. SourceLocation getLocation() const { return StartLoc; } + /// \brief Construct a template argument pack. + void setArgumentPack(TemplateArgument *Args, unsigned NumArgs, bool CopyArgs); + /// \brief Used to insert TemplateArguments into FoldingSets. void Profile(llvm::FoldingSetNodeID &ID) const { ID.AddInteger(Kind); @@ -622,47 +621,51 @@ public: /// \brief A helper class for making template argument lists. class TemplateArgumentListBuilder { - /// FlatArgs - contains the template arguments in flat form. - llvm::SmallVector<TemplateArgument, 16> FlatArgs; - - llvm::SmallVector<TemplateArgument, 16> StructuredArgs; - - ASTContext &Context; + TemplateArgument *StructuredArgs; + unsigned MaxStructuredArgs; + unsigned NumStructuredArgs; + + TemplateArgument *FlatArgs; + unsigned MaxFlatArgs; + unsigned NumFlatArgs; + bool AddingToPack; unsigned PackBeginIndex; - - /// isAddingFromParameterPack - Returns whether we're adding arguments from - /// a parameter pack. - bool isAddingFromParameterPack() const { - return PackBeginIndex != std::numeric_limits<unsigned>::max(); - } public: - TemplateArgumentListBuilder(ASTContext &Context) : Context(Context), - PackBeginIndex(std::numeric_limits<unsigned>::max()) { } + TemplateArgumentListBuilder(const TemplateParameterList *Parameters, + unsigned NumTemplateArgs) + : StructuredArgs(0), MaxStructuredArgs(Parameters->size()), + NumStructuredArgs(0), FlatArgs(0), + MaxFlatArgs(std::max(MaxStructuredArgs, NumTemplateArgs)), NumFlatArgs(0), + AddingToPack(false), PackBeginIndex(0) { } - size_t structuredSize() const { - assert(!isAddingFromParameterPack() && - "Size is not valid when adding from a parameter pack"); - - return StructuredArgs.size(); - } - - size_t flatSize() const { return FlatArgs.size(); } + void Append(const TemplateArgument& Arg); + void BeginPack(); + void EndPack(); - void push_back(const TemplateArgument& Arg); - - /// BeginParameterPack - Start adding arguments from a parameter pack. - void BeginParameterPack(); + void ReleaseArgs(); - /// EndParameterPack - Finish adding arguments from a parameter pack. - void EndParameterPack(); + unsigned flatSize() const { + return NumFlatArgs; + } + const TemplateArgument *getFlatArguments() const { + return FlatArgs; + } - const TemplateArgument *getFlatArgumentList() const { - return FlatArgs.data(); + unsigned structuredSize() const { + // If we don't have any structured args, just reuse the flat size. + if (!StructuredArgs) + return flatSize(); + + return NumStructuredArgs; } - TemplateArgument *getFlatArgumentList() { - return FlatArgs.data(); + const TemplateArgument *getStructuredArguments() const { + // If we don't have any structured args, just reuse the flat args. + if (!StructuredArgs) + return getFlatArguments(); + + return StructuredArgs; } }; @@ -676,22 +679,25 @@ class TemplateArgumentList { /// /// The integer value will be non-zero to indicate that this /// template argument list does not own the pointer. - llvm::PointerIntPair<TemplateArgument *, 1> Arguments; + llvm::PointerIntPair<const TemplateArgument *, 1> FlatArguments; /// \brief The number of template arguments in this template /// argument list. - unsigned NumArguments; + unsigned NumFlatArguments; + llvm::PointerIntPair<const TemplateArgument *, 1> StructuredArguments; + unsigned NumStructuredArguments; + public: TemplateArgumentList(ASTContext &Context, TemplateArgumentListBuilder &Builder, - bool CopyArgs, bool FlattenArgs); + bool TakeArgs); ~TemplateArgumentList(); /// \brief Retrieve the template argument at a given index. const TemplateArgument &get(unsigned Idx) const { - assert(Idx < NumArguments && "Invalid template argument index"); + assert(Idx < NumFlatArguments && "Invalid template argument index"); return getFlatArgumentList()[Idx]; } @@ -700,15 +706,15 @@ public: /// \brief Retrieve the number of template arguments in this /// template argument list. - unsigned size() const { return NumArguments; } + unsigned size() const { return NumFlatArguments; } /// \brief Retrieve the number of template arguments in the /// flattened template argument list. - unsigned flat_size() const { return NumArguments; } + unsigned flat_size() const { return NumFlatArguments; } /// \brief Retrieve the flattened template argument list. const TemplateArgument *getFlatArgumentList() const { - return Arguments.getPointer(); + return FlatArguments.getPointer(); } }; Modified: vendor/clang/dist/include/clang/Analysis/PathSensitive/Environment.h ============================================================================== --- vendor/clang/dist/include/clang/Analysis/PathSensitive/Environment.h Tue Jun 23 14:50:01 2009 (r194710) +++ vendor/clang/dist/include/clang/Analysis/PathSensitive/Environment.h Tue Jun 23 14:50:21 2009 (r194711) @@ -27,7 +27,7 @@ namespace clang { class EnvironmentManager; -class BasicValueFactory; +class ValueManager; class LiveVariables; class Environment { @@ -71,8 +71,8 @@ public: return X ? *X : UnknownVal(); } - SVal GetSVal(const Stmt* Ex, BasicValueFactory& BasicVals) const; - SVal GetBlkExprSVal(const Stmt* Ex, BasicValueFactory& BasicVals) const; + SVal GetSVal(const Stmt* Ex, ValueManager& ValMgr) const; + SVal GetBlkExprSVal(const Stmt* Ex, ValueManager& ValMgr) const; /// Profile - Profile the contents of an Environment object for use /// in a FoldingSet. Modified: vendor/clang/dist/include/clang/Analysis/PathSensitive/GRExprEngine.h ============================================================================== --- vendor/clang/dist/include/clang/Analysis/PathSensitive/GRExprEngine.h Tue Jun 23 14:50:01 2009 (r194710) +++ vendor/clang/dist/include/clang/Analysis/PathSensitive/GRExprEngine.h Tue Jun 23 14:50:21 2009 (r194711) @@ -481,11 +481,6 @@ protected: return N == EntryNode ? CleanedState : N->getState(); } -public: - inline NonLoc MakeConstantVal(uint64_t X, Expr* Ex) { - return NonLoc::MakeVal(getBasicVals(), X, Ex->getType()); - } - public: NodeTy* MakeNode(NodeSet& Dst, Stmt* S, NodeTy* Pred, const GRState* St, ProgramPoint::Kind K = ProgramPoint::PostStmtKind, Modified: vendor/clang/dist/include/clang/Analysis/PathSensitive/GRState.h ============================================================================== --- vendor/clang/dist/include/clang/Analysis/PathSensitive/GRState.h Tue Jun 23 14:50:01 2009 (r194710) +++ vendor/clang/dist/include/clang/Analysis/PathSensitive/GRState.h Tue Jun 23 14:50:21 2009 (r194711) @@ -532,7 +532,7 @@ private: // Methods that query & manipulate the Environment. SVal GetSVal(const GRState* St, const Stmt* Ex) { - return St->getEnvironment().GetSVal(Ex, getBasicVals()); + return St->getEnvironment().GetSVal(Ex, ValueMgr); } SVal GetSValAsScalarOrLoc(const GRState* state, const Stmt *S) { @@ -546,7 +546,7 @@ private: } SVal GetBlkExprSVal(const GRState* St, const Stmt* Ex) { - return St->getEnvironment().GetBlkExprSVal(Ex, getBasicVals()); + return St->getEnvironment().GetBlkExprSVal(Ex, ValueMgr); } const GRState* BindExpr(const GRState* St, const Stmt* Ex, SVal V, @@ -613,7 +613,7 @@ public: // We only want to do fetches from regions that we can actually bind // values. For example, SymbolicRegions of type 'id<...>' cannot // have direct bindings (but their can be bindings on their subregions). - if (!R->isBoundable(getContext())) + if (!R->isBoundable()) return UnknownVal(); if (const TypedRegion *TR = dyn_cast<TypedRegion>(R)) { Modified: vendor/clang/dist/include/clang/Analysis/PathSensitive/MemRegion.h ============================================================================== --- vendor/clang/dist/include/clang/Analysis/PathSensitive/MemRegion.h Tue Jun 23 14:50:01 2009 (r194710) +++ vendor/clang/dist/include/clang/Analysis/PathSensitive/MemRegion.h Tue Jun 23 14:50:21 2009 (r194711) @@ -59,11 +59,14 @@ private: protected: MemRegion(Kind k) : kind(k) {} virtual ~MemRegion(); + ASTContext &getContext() const; public: // virtual MemExtent getExtent(MemRegionManager& mrm) const = 0; virtual void Profile(llvm::FoldingSetNodeID& ID) const = 0; - + + virtual MemRegionManager* getMemRegionManager() const = 0; + std::string getString() const; virtual void print(llvm::raw_ostream& os) const; @@ -72,7 +75,7 @@ public: template<typename RegionTy> const RegionTy* getAs() const; - virtual bool isBoundable(ASTContext&) const { return true; } + virtual bool isBoundable() const { return true; } static bool classof(const MemRegion*) { return true; } }; @@ -81,14 +84,23 @@ public: /// for example, the set of global variables, the stack frame, etc. class MemSpaceRegion : public MemRegion { friend class MemRegionManager; - MemSpaceRegion() : MemRegion(MemSpaceRegionKind) {} + +protected: + MemRegionManager *Mgr; + + MemSpaceRegion(MemRegionManager *mgr) : MemRegion(MemSpaceRegionKind), + Mgr(mgr) {} + MemRegionManager* getMemRegionManager() const { + return Mgr; + } + public: //RegionExtent getExtent() const { return UndefinedExtent(); } void Profile(llvm::FoldingSetNodeID& ID) const; - bool isBoundable(ASTContext &) const { return false; } + bool isBoundable() const { return false; } static bool classof(const MemRegion* R) { return R->getKind() == MemSpaceRegionKind; @@ -101,11 +113,12 @@ class SubRegion : public MemRegion { protected: const MemRegion* superRegion; SubRegion(const MemRegion* sReg, Kind k) : MemRegion(k), superRegion(sReg) {} - public: const MemRegion* getSuperRegion() const { return superRegion; } + + MemRegionManager* getMemRegionManager() const; bool isSubRegionOf(const MemRegion* R) const; @@ -123,7 +136,7 @@ protected: // memory allocated by alloca at the same call site. const Expr* Ex; - AllocaRegion(const Expr* ex, unsigned cnt, const MemRegion* superRegion) + AllocaRegion(const Expr* ex, unsigned cnt, const MemRegion *superRegion) : SubRegion(superRegion, AllocaRegionKind), Cnt(cnt), Ex(ex) {} public: @@ -133,7 +146,7 @@ public: void Profile(llvm::FoldingSetNodeID& ID) const; static void ProfileRegion(llvm::FoldingSetNodeID& ID, const Expr* Ex, - unsigned Cnt); + unsigned Cnt, const MemRegion *superRegion); void print(llvm::raw_ostream& os) const; @@ -164,8 +177,8 @@ public: return getLocationType(C)->getDesugaredType(); } - bool isBoundable(ASTContext &C) const { - return !getValueType(C).isNull(); + bool isBoundable() const { + return !getValueType(getContext()).isNull(); } static bool classof(const MemRegion* R) { @@ -229,14 +242,14 @@ public: return const_cast<SymbolRef>(static_cast<const SymbolRef>(Data)); } - bool isBoundable(ASTContext&) const { return false; } + bool isBoundable() const { return false; } virtual void print(llvm::raw_ostream& os) const; void Profile(llvm::FoldingSetNodeID& ID) const; static void ProfileRegion(llvm::FoldingSetNodeID& ID, - const void* data, QualType t); + const void* data, QualType t, const MemRegion*); static bool classof(const MemRegion* R) { return R->getKind() == CodeTextRegionKind; @@ -262,7 +275,9 @@ public: void Profile(llvm::FoldingSetNodeID& ID) const; - static void ProfileRegion(llvm::FoldingSetNodeID& ID, SymbolRef sym); + static void ProfileRegion(llvm::FoldingSetNodeID& ID, + SymbolRef sym, + const MemRegion* superRegion); void print(llvm::raw_ostream& os) const; @@ -277,7 +292,7 @@ class StringRegion : public TypedRegion const StringLiteral* Str; protected: - StringRegion(const StringLiteral* str, MemRegion* sreg) + StringRegion(const StringLiteral* str, const MemRegion* sreg) : TypedRegion(sreg, StringRegionKind), Str(str) {} static void ProfileRegion(llvm::FoldingSetNodeID& ID, @@ -327,7 +342,7 @@ public: return PTy->getPointeeType(); } - bool isBoundable(ASTContext &C) const { + bool isBoundable() const { return isa<PointerType>(LValueType); } @@ -399,8 +414,8 @@ class VarRegion : public DeclRegion { VarRegion(const VarDecl* vd, const MemRegion* sReg) : DeclRegion(vd, sReg, VarRegionKind) {} - static void ProfileRegion(llvm::FoldingSetNodeID& ID, VarDecl* VD, - const MemRegion* superRegion) { + static void ProfileRegion(llvm::FoldingSetNodeID& ID, const VarDecl* VD, + const MemRegion* superRegion) { DeclRegion::ProfileRegion(ID, VD, superRegion, VarRegionKind); } @@ -436,8 +451,8 @@ public: return C.getCanonicalType(getDecl()->getType()); } - static void ProfileRegion(llvm::FoldingSetNodeID& ID, FieldDecl* FD, - const MemRegion* superRegion) { + static void ProfileRegion(llvm::FoldingSetNodeID& ID, const FieldDecl* FD, + const MemRegion* superRegion) { DeclRegion::ProfileRegion(ID, FD, superRegion, FieldRegionKind); } @@ -453,7 +468,8 @@ class ObjCObjectRegion : public DeclRegi ObjCObjectRegion(const ObjCInterfaceDecl* ivd, const MemRegion* sReg) : DeclRegion(ivd, sReg, ObjCObjectRegionKind) {} - static void ProfileRegion(llvm::FoldingSetNodeID& ID, ObjCInterfaceDecl* ivd, + static void ProfileRegion(llvm::FoldingSetNodeID& ID, + const ObjCInterfaceDecl* ivd, const MemRegion* superRegion) { DeclRegion::ProfileRegion(ID, ivd, superRegion, ObjCObjectRegionKind); } @@ -479,8 +495,8 @@ class ObjCIvarRegion : public DeclRegion ObjCIvarRegion(const ObjCIvarDecl* ivd, const MemRegion* sReg) : DeclRegion(ivd, sReg, ObjCIvarRegionKind) {} - static void ProfileRegion(llvm::FoldingSetNodeID& ID, ObjCIvarDecl* ivd, - const MemRegion* superRegion) { + static void ProfileRegion(llvm::FoldingSetNodeID& ID, const ObjCIvarDecl* ivd, + const MemRegion* superRegion) { DeclRegion::ProfileRegion(ID, ivd, superRegion, ObjCIvarRegionKind); } @@ -556,6 +572,7 @@ const RegionTy* MemRegion::getAs() const //===----------------------------------------------------------------------===// class MemRegionManager { + ASTContext &C; llvm::BumpPtrAllocator& A; llvm::FoldingSet<MemRegion> Regions; @@ -566,11 +583,13 @@ class MemRegionManager { MemSpaceRegion* code; public: - MemRegionManager(llvm::BumpPtrAllocator& a) - : A(a), globals(0), stack(0), heap(0), unknown(0), code(0) {} + MemRegionManager(ASTContext &c, llvm::BumpPtrAllocator& a) + : C(c), A(a), globals(0), stack(0), heap(0), unknown(0), code(0) {} ~MemRegionManager() {} + ASTContext &getContext() { return C; } + /// getStackRegion - Retrieve the memory region associated with the /// current stack frame. MemSpaceRegion* getStackRegion(); @@ -589,17 +608,6 @@ public: MemSpaceRegion* getCodeRegion(); - bool isGlobalsRegion(const MemRegion* R) { - assert(R); - return R == globals; - } - - /// onStack - check if the region is allocated on the stack. - bool onStack(const MemRegion* R); - - /// onHeap - check if the region is allocated on the heap, usually by malloc. - bool onHeap(const MemRegion* R); - /// getAllocaRegion - Retrieve a region associated with a call to alloca(). AllocaRegion* getAllocaRegion(const Expr* Ex, unsigned Cnt); @@ -646,14 +654,164 @@ public: CodeTextRegion* getCodeTextRegion(SymbolRef sym, QualType t); CodeTextRegion* getCodeTextRegion(const FunctionDecl* fd, QualType t); + + template <typename RegionTy, typename A1> + RegionTy* getRegion(const A1 a1); + + template <typename RegionTy, typename A1> + RegionTy* getRegion(const A1 a1, const MemRegion* superRegion); + + template <typename RegionTy, typename A1, typename A2> + RegionTy* getRegion(const A1 a1, const A2 a2); + + bool isGlobalsRegion(const MemRegion* R) { + assert(R); + return R == globals; + } bool hasStackStorage(const MemRegion* R); + bool hasHeapStorage(const MemRegion* R); + private: MemSpaceRegion* LazyAllocate(MemSpaceRegion*& region); }; + +//===----------------------------------------------------------------------===// +// Out-of-line member definitions. +//===----------------------------------------------------------------------===// + +inline ASTContext& MemRegion::getContext() const { + return getMemRegionManager()->getContext(); +} + +template<typename RegionTy> struct MemRegionManagerTrait; + +template <typename RegionTy, typename A1> +RegionTy* MemRegionManager::getRegion(const A1 a1) { + + const typename MemRegionManagerTrait<RegionTy>::SuperRegionTy *superRegion = + MemRegionManagerTrait<RegionTy>::getSuperRegion(*this, a1); + + llvm::FoldingSetNodeID ID; + RegionTy::ProfileRegion(ID, a1, superRegion); + void* InsertPos; + RegionTy* R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID, + InsertPos)); + + if (!R) { + R = (RegionTy*) A.Allocate<RegionTy>(); + new (R) RegionTy(a1, superRegion); + Regions.InsertNode(R, InsertPos); + } + + return R; +} + +template <typename RegionTy, typename A1> +RegionTy* MemRegionManager::getRegion(const A1 a1, const MemRegion *superRegion) +{ + llvm::FoldingSetNodeID ID; + RegionTy::ProfileRegion(ID, a1, superRegion); + void* InsertPos; + RegionTy* R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID, + InsertPos)); + + if (!R) { + R = (RegionTy*) A.Allocate<RegionTy>(); + new (R) RegionTy(a1, superRegion); + Regions.InsertNode(R, InsertPos); + } + + return R; +} + +template <typename RegionTy, typename A1, typename A2> +RegionTy* MemRegionManager::getRegion(const A1 a1, const A2 a2) { + + const typename MemRegionManagerTrait<RegionTy>::SuperRegionTy *superRegion = + MemRegionManagerTrait<RegionTy>::getSuperRegion(*this, a1, a2); + + llvm::FoldingSetNodeID ID; + RegionTy::ProfileRegion(ID, a1, a2, superRegion); + void* InsertPos; + RegionTy* R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID, + InsertPos)); + + if (!R) { + R = (RegionTy*) A.Allocate<RegionTy>(); + new (R) RegionTy(a1, a2, superRegion); + Regions.InsertNode(R, InsertPos); + } + + return R; +} + +//===----------------------------------------------------------------------===// +// Traits for constructing regions. +//===----------------------------------------------------------------------===// + +template <> struct MemRegionManagerTrait<AllocaRegion> { + typedef MemRegion SuperRegionTy; + static const SuperRegionTy* getSuperRegion(MemRegionManager& MRMgr, + const Expr *, unsigned) { + return MRMgr.getStackRegion(); + } +}; + +template <> struct MemRegionManagerTrait<CompoundLiteralRegion> { + typedef MemRegion SuperRegionTy; + static const SuperRegionTy* getSuperRegion(MemRegionManager& MRMgr, + const CompoundLiteralExpr *CL) { + + return CL->isFileScope() ? MRMgr.getGlobalsRegion() + : MRMgr.getStackRegion(); + } +}; + +template <> struct MemRegionManagerTrait<StringRegion> { + typedef MemSpaceRegion SuperRegionTy; + static const SuperRegionTy* getSuperRegion(MemRegionManager& MRMgr, + const StringLiteral*) { + return MRMgr.getGlobalsRegion(); + } +}; + +template <> struct MemRegionManagerTrait<VarRegion> { + typedef MemRegion SuperRegionTy; + static const SuperRegionTy* getSuperRegion(MemRegionManager& MRMgr, + const VarDecl *d) { + return d->hasLocalStorage() ? MRMgr.getStackRegion() + : MRMgr.getGlobalsRegion(); + } +}; + +template <> struct MemRegionManagerTrait<SymbolicRegion> { + typedef MemRegion SuperRegionTy; + static const SuperRegionTy* getSuperRegion(MemRegionManager& MRMgr, + SymbolRef) { + return MRMgr.getUnknownRegion(); + } +}; + +template<> struct MemRegionManagerTrait<CodeTextRegion> { + typedef MemSpaceRegion SuperRegionTy; + static const SuperRegionTy* getSuperRegion(MemRegionManager& MRMgr, + const FunctionDecl*, QualType) { + return MRMgr.getCodeRegion(); + } + static const SuperRegionTy* getSuperRegion(MemRegionManager& MRMgr, + SymbolRef, QualType) { + return MRMgr.getCodeRegion(); + } +}; + } // end clang namespace +//===----------------------------------------------------------------------===// +// Pretty-printing regions. +//===----------------------------------------------------------------------===// + namespace llvm { static inline raw_ostream& operator<<(raw_ostream& O, const clang::MemRegion* R) { Modified: vendor/clang/dist/include/clang/Analysis/PathSensitive/SVals.h ============================================================================== --- vendor/clang/dist/include/clang/Analysis/PathSensitive/SVals.h Tue Jun 23 14:50:01 2009 (r194710) +++ vendor/clang/dist/include/clang/Analysis/PathSensitive/SVals.h Tue Jun 23 14:50:21 2009 (r194711) @@ -30,6 +30,7 @@ class BasicValueFactory; class MemRegion; class MemRegionManager; class GRStateManager; +class ValueManager; class SVal { public: @@ -171,28 +172,6 @@ protected: public: void print(llvm::raw_ostream& Out) const; - // Utility methods to create NonLocs. - - static NonLoc MakeIntVal(BasicValueFactory& BasicVals, uint64_t X, - bool isUnsigned); - - static NonLoc MakeVal(BasicValueFactory& BasicVals, uint64_t X, - unsigned BitWidth, bool isUnsigned); - - static NonLoc MakeVal(BasicValueFactory& BasicVals, uint64_t X, QualType T); - - static NonLoc MakeVal(BasicValueFactory& BasicVals, const IntegerLiteral *I); - - static NonLoc MakeVal(BasicValueFactory& BasicVals, const llvm::APInt& I, - bool isUnsigned); - - static NonLoc MakeVal(BasicValueFactory& BasicVals, const llvm::APSInt& I); - - static NonLoc MakeIntTruthVal(BasicValueFactory& BasicVals, bool b); - - static NonLoc MakeCompoundVal(QualType T, llvm::ImmutableList<SVal> Vals, - BasicValueFactory& BasicVals); - // Implement isa<T> support. static inline bool classof(const SVal* V) { return V->getBaseKind() == NonLocKind; @@ -210,12 +189,6 @@ public: Loc(const Loc& X) : SVal(X.Data, true, X.getSubKind()) {} Loc& operator=(const Loc& X) { memcpy(this, &X, sizeof(Loc)); return *this; } - static Loc MakeVal(const MemRegion* R); - - static Loc MakeVal(const AddrLabelExpr* E); - - static Loc MakeNull(BasicValueFactory &BasicVals); - // Implement isa<T> support. static inline bool classof(const SVal* V) { return V->getBaseKind() == LocKind; @@ -301,6 +274,8 @@ public: }; class LocAsInteger : public NonLoc { + friend class clang::ValueManager; + LocAsInteger(const std::pair<SVal, uintptr_t>& data) : NonLoc(LocAsIntegerKind, &data) { assert (isa<Loc>(data.first)); @@ -330,12 +305,10 @@ public: static inline bool classof(const NonLoc* V) { return V->getSubKind() == LocAsIntegerKind; } - - static LocAsInteger Make(BasicValueFactory& Vals, Loc V, unsigned Bits); }; class CompoundVal : public NonLoc { - friend class NonLoc; + friend class clang::ValueManager; CompoundVal(const CompoundValData* D) : NonLoc(CompoundValKind, D) {} Modified: vendor/clang/dist/include/clang/Analysis/PathSensitive/ValueManager.h ============================================================================== --- vendor/clang/dist/include/clang/Analysis/PathSensitive/ValueManager.h Tue Jun 23 14:50:01 2009 (r194710) +++ vendor/clang/dist/include/clang/Analysis/PathSensitive/ValueManager.h Tue Jun 23 14:50:21 2009 (r194711) @@ -9,7 +9,7 @@ // // This file defines ValueManager, a class that manages symbolic values // and SVals created for use by GRExprEngine and related classes. It -// wraps SymbolManager, MemRegionManager, and BasicValueFactory. +// wraps and owns SymbolManager, MemRegionManager, and BasicValueFactory. // //===----------------------------------------------------------------------===// @@ -39,7 +39,7 @@ public: ValueManager(llvm::BumpPtrAllocator &alloc, ASTContext &context) : Context(context), BasicVals(Context, alloc), SymMgr(Context, BasicVals, alloc), - MemMgr(alloc) {} + MemMgr(Context, alloc) {} // Accessors to submanagers. @@ -68,17 +68,8 @@ public: return SymMgr.getConjuredSymbol(E, VisitCount, SymbolTag); } - // Aggregation methods that use multiple submanagers. - - Loc makeRegionVal(SymbolRef Sym) { - return Loc::MakeVal(MemMgr.getSymbolicRegion(Sym)); - } - /// makeZeroVal - Construct an SVal representing '0' for the specified type. SVal makeZeroVal(QualType T); - /// makeZeroArrayIndex - Construct an SVal representing '0' index for array - /// elements. - SVal makeZeroArrayIndex(); /// GetRegionValueSymbolVal - make a unique symbol for value of R. SVal getRegionValueSymbolVal(const MemRegion* R, QualType T = QualType()); @@ -87,16 +78,77 @@ public: SVal getConjuredSymbolVal(const Expr* E, QualType T, unsigned Count); SVal getFunctionPointer(const FunctionDecl* FD); - - NonLoc makeNonLoc(SymbolRef sym); - + + NonLoc makeCompoundVal(QualType T, llvm::ImmutableList<SVal> Vals) { + return nonloc::CompoundVal(BasicVals.getCompoundValData(T, Vals)); + } + + NonLoc makeZeroArrayIndex() { + return nonloc::ConcreteInt(BasicVals.getZeroWithPtrWidth(false)); + } + + NonLoc makeIntVal(const IntegerLiteral* I) { + return nonloc::ConcreteInt(BasicVals.getValue(I->getValue(), + I->getType()->isUnsignedIntegerType())); + } + + NonLoc makeIntVal(const llvm::APSInt& V) { + return nonloc::ConcreteInt(BasicVals.getValue(V)); + } + + NonLoc makeIntVal(const llvm::APInt& V, bool isUnsigned) { + return nonloc::ConcreteInt(BasicVals.getValue(V, isUnsigned)); + } + + NonLoc makeIntVal(uint64_t X, QualType T) { + return nonloc::ConcreteInt(BasicVals.getValue(X, T)); + } + + NonLoc makeIntVal(uint64_t X, bool isUnsigned) { + return nonloc::ConcreteInt(BasicVals.getIntValue(X, isUnsigned)); + } + + NonLoc makeIntVal(uint64_t X, unsigned BitWidth, bool isUnsigned) { + return nonloc::ConcreteInt(BasicVals.getValue(X, BitWidth, isUnsigned)); + } + + NonLoc makeLocAsInteger(Loc V, unsigned Bits) { + return nonloc::LocAsInteger(BasicVals.getPersistentSValWithData(V, Bits)); + } + NonLoc makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op, const llvm::APSInt& rhs, QualType T); NonLoc makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType T); - NonLoc makeTruthVal(bool b, QualType T); + NonLoc makeTruthVal(bool b, QualType T) { + return nonloc::ConcreteInt(BasicVals.getTruthValue(b, T)); + } + + NonLoc makeTruthVal(bool b) { + return nonloc::ConcreteInt(BasicVals.getTruthValue(b)); + } + + Loc makeNull() { + return loc::ConcreteInt(BasicVals.getZeroWithPtrWidth()); + } + + Loc makeLoc(SymbolRef Sym) { + return loc::MemRegionVal(MemMgr.getSymbolicRegion(Sym)); + } + + Loc makeLoc(const MemRegion* R) { + return loc::MemRegionVal(R); + } + + Loc makeLoc(const AddrLabelExpr* E) { + return loc::GotoLabel(E->getLabel()); + } + + Loc makeLoc(const llvm::APSInt& V) { + return loc::ConcreteInt(BasicVals.getValue(V)); + } }; } // end clang namespace #endif Modified: vendor/clang/dist/include/clang/Basic/DiagnosticFrontendKinds.td ============================================================================== --- vendor/clang/dist/include/clang/Basic/DiagnosticFrontendKinds.td Tue Jun 23 14:50:01 2009 (r194710) +++ vendor/clang/dist/include/clang/Basic/DiagnosticFrontendKinds.td Tue Jun 23 14:50:21 2009 (r194711) @@ -136,4 +136,7 @@ def warn_pch_char_signed : Error< def err_not_a_pch_file : Error< "'%0' does not appear to be a precompiled header file">, DefaultFatal; +def warn_unknown_warning_option : Warning< + "unknown warning option '%0'">, + InGroup<DiagGroup<"unknown-warning-option"> >; } Modified: vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td ============================================================================== --- vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td Tue Jun 23 14:50:01 2009 (r194710) +++ vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td Tue Jun 23 14:50:21 2009 (r194711) @@ -580,8 +580,8 @@ def err_param_default_argument_nonfunc : "default arguments can only be specified for parameters in a function " "declaration">; def err_defining_default_ctor : Error< - "cannot define the default constructor for %0, because %select{base class|member}1 " - "%2 does not have any implicit default constructor">; + "cannot define the implicit default constructor for %0, because %select{base class|member}1 " + "%2 does not have any default constructor">; def note_previous_class_decl : Note< "%0 declared here">; def err_unintialized_member : Error< @@ -870,7 +870,8 @@ def err_undeclared_var_use : Error<"use def err_undeclared_use : Error<"use of undeclared '%0'">; def warn_deprecated : Warning<"%0 is deprecated">, InGroup<DiagGroup<"deprecated-declarations">>; -def warn_unavailable : Warning<"%0 is unavailable">; +def warn_unavailable : Warning<"%0 is unavailable">, + InGroup<DiagGroup<"unavailable-declarations">>; def note_unavailable_here : Note< "function has been explicitly marked %select{unavailable|deleted}0 here">; def warn_not_enough_argument : Warning< Modified: vendor/clang/dist/include/clang/Basic/SourceLocation.h ============================================================================== --- vendor/clang/dist/include/clang/Basic/SourceLocation.h Tue Jun 23 14:50:01 2009 (r194710) +++ vendor/clang/dist/include/clang/Basic/SourceLocation.h Tue Jun 23 14:50:21 2009 (r194711) @@ -145,10 +145,6 @@ inline bool operator<(const SourceLocati return LHS.getRawEncoding() < RHS.getRawEncoding(); } -inline bool operator<=(const SourceLocation &LHS, const SourceLocation &RHS) { - return LHS.getRawEncoding() <= RHS.getRawEncoding(); -} - /// SourceRange - a trival tuple used to represent a source range. class SourceRange { SourceLocation B; Modified: vendor/clang/dist/include/clang/Parse/Action.h ============================================================================== --- vendor/clang/dist/include/clang/Parse/Action.h Tue Jun 23 14:50:01 2009 (r194710) +++ vendor/clang/dist/include/clang/Parse/Action.h Tue Jun 23 14:50:21 2009 (r194711) @@ -637,18 +637,50 @@ public: // Expression Parsing Callbacks. //===--------------------------------------------------------------------===// - /// \brief Notifies the action when the parser is processing an unevaluated - /// operand. + /// \brief Describes how the expressions currently being parsed are + /// evaluated at run-time, if at all. + enum ExpressionEvaluationContext { + /// \brief The current expression and its subexpressions occur within an + /// unevaluated operand (C++0x [expr]p8), such as a constant expression + /// or the subexpression of \c sizeof, where the type or the value of the + /// expression may be significant but no code will be generated to evaluate + /// the value of the expression at run time. + Unevaluated, + + /// \brief The current expression is potentially evaluated at run time, + /// which means that code may be generated to evaluate the value of the + /// expression at run time. + PotentiallyEvaluated, + + /// \brief The current expression may be potentially evaluated or it may + /// be unevaluated, but it is impossible to tell from the lexical context. + /// This evaluation context is used primary for the operand of the C++ + /// \c typeid expression, whose argument is potentially evaluated only when + /// it is an lvalue of polymorphic class type (C++ [basic.def.odr]p2). + PotentiallyPotentiallyEvaluated + }; + + /// \brief The parser is entering a new expression evaluation context. /// - /// \param UnevaluatedOperand true to indicate that the parser is processing - /// an unevaluated operand, or false otherwise. + /// \param NewContext is the new expression evaluation context. /// - /// \returns whether the the action module was previously in an unevaluated - /// operand. - virtual bool setUnevaluatedOperand(bool UnevaluatedOperand) { - return false; + /// \returns the previous expression evaluation context. + virtual ExpressionEvaluationContext + PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext) { + return PotentiallyEvaluated; } + /// \brief The parser is existing an expression evaluation context. + /// + /// \param OldContext the expression evaluation context that the parser is + /// leaving. + /// + /// \param NewContext the expression evaluation context that the parser is + /// returning to. + virtual void + PopExpressionEvaluationContext(ExpressionEvaluationContext OldContext, + ExpressionEvaluationContext NewContext) { } + // Primary Expressions. /// \brief Retrieve the source range that corresponds to the given @@ -1891,6 +1923,29 @@ public: virtual void print(llvm::raw_ostream &OS) const; }; +/// \brief RAII object that enters a new expression evaluation context. +class EnterExpressionEvaluationContext { + /// \brief The action object. + Action &Actions; + + /// \brief The previous expression evaluation context. *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906231450.n5NEoLv7079417>