From: Craig Topper Date: Thu, 22 Aug 2013 04:58:56 +0000 (+0000) Subject: Constify the ASTContext& passed to Expr creation functions. Also constify the context... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9db7a7eb4e23758e041752c9c0c0ec1663d5a0af;p=clang Constify the ASTContext& passed to Expr creation functions. Also constify the context in couple other functions that are called from creation functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188985 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 1d957aa2be..0b25eb49a4 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -906,7 +906,7 @@ class DeclRefExpr : public Expr { return const_cast(this)->getInternalFoundDecl(); } - DeclRefExpr(ASTContext &Ctx, + DeclRefExpr(const ASTContext &Ctx, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool refersToEnclosingLocal, @@ -921,7 +921,7 @@ class DeclRefExpr : public Expr { /// \brief Computes the type- and value-dependence flags for this /// declaration reference expression. - void computeDependence(ASTContext &C); + void computeDependence(const ASTContext &C); public: DeclRefExpr(ValueDecl *D, bool refersToEnclosingLocal, QualType T, @@ -937,7 +937,7 @@ public: computeDependence(D->getASTContext()); } - static DeclRefExpr *Create(ASTContext &Context, + static DeclRefExpr *Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, @@ -947,7 +947,7 @@ public: NamedDecl *FoundD = 0, const TemplateArgumentListInfo *TemplateArgs = 0); - static DeclRefExpr *Create(ASTContext &Context, + static DeclRefExpr *Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, @@ -958,7 +958,7 @@ public: const TemplateArgumentListInfo *TemplateArgs = 0); /// \brief Construct an empty declaration reference expression. - static DeclRefExpr *CreateEmpty(ASTContext &Context, + static DeclRefExpr *CreateEmpty(const ASTContext &Context, bool HasQualifier, bool HasFoundDecl, bool HasTemplateKWAndArgsInfo, diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h index a94c69a115..aeb55da1fb 100644 --- a/include/clang/AST/ExprObjC.h +++ b/include/clang/AST/ExprObjC.h @@ -143,12 +143,13 @@ class ObjCArrayLiteral : public Expr { : Expr(ObjCArrayLiteralClass, Empty), NumElements(NumElements) {} public: - static ObjCArrayLiteral *Create(ASTContext &C, + static ObjCArrayLiteral *Create(const ASTContext &C, ArrayRef Elements, QualType T, ObjCMethodDecl * Method, SourceRange SR); - static ObjCArrayLiteral *CreateEmpty(ASTContext &C, unsigned NumElements); + static ObjCArrayLiteral *CreateEmpty(const ASTContext &C, + unsigned NumElements); SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); } SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); } @@ -289,13 +290,13 @@ class ObjCDictionaryLiteral : public Expr { } public: - static ObjCDictionaryLiteral *Create(ASTContext &C, + static ObjCDictionaryLiteral *Create(const ASTContext &C, ArrayRef VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, SourceRange SR); - static ObjCDictionaryLiteral *CreateEmpty(ASTContext &C, + static ObjCDictionaryLiteral *CreateEmpty(const ASTContext &C, unsigned NumElements, bool HasPackExpansions); @@ -807,7 +808,7 @@ public: explicit ObjCSubscriptRefExpr(EmptyShell Empty) : Expr(ObjCSubscriptRefExprClass, Empty) {} - static ObjCSubscriptRefExpr *Create(ASTContext &C, + static ObjCSubscriptRefExpr *Create(const ASTContext &C, Expr *base, Expr *key, QualType T, ObjCMethodDecl *getMethod, @@ -1003,13 +1004,13 @@ class ObjCMessageExpr : public Expr { return getNumSelectorLocs(); } - static ObjCMessageExpr *alloc(ASTContext &C, + static ObjCMessageExpr *alloc(const ASTContext &C, ArrayRef Args, SourceLocation RBraceLoc, ArrayRef SelLocs, Selector Sel, SelectorLocationsKind &SelLocsK); - static ObjCMessageExpr *alloc(ASTContext &C, + static ObjCMessageExpr *alloc(const ASTContext &C, unsigned NumArgs, unsigned NumStoredSelLocs); @@ -1051,7 +1052,7 @@ public: /// \param Args The message send arguments. /// /// \param RBracLoc The location of the closing square bracket ']'. - static ObjCMessageExpr *Create(ASTContext &Context, QualType T, + static ObjCMessageExpr *Create(const ASTContext &Context, QualType T, ExprValueKind VK, SourceLocation LBracLoc, SourceLocation SuperLoc, @@ -1087,7 +1088,7 @@ public: /// \param Args The message send arguments. /// /// \param RBracLoc The location of the closing square bracket ']'. - static ObjCMessageExpr *Create(ASTContext &Context, QualType T, + static ObjCMessageExpr *Create(const ASTContext &Context, QualType T, ExprValueKind VK, SourceLocation LBracLoc, TypeSourceInfo *Receiver, @@ -1121,7 +1122,7 @@ public: /// \param Args The message send arguments. /// /// \param RBracLoc The location of the closing square bracket ']'. - static ObjCMessageExpr *Create(ASTContext &Context, QualType T, + static ObjCMessageExpr *Create(const ASTContext &Context, QualType T, ExprValueKind VK, SourceLocation LBracLoc, Expr *Receiver, @@ -1139,7 +1140,7 @@ public: /// /// \param NumArgs The number of message arguments, not including /// the receiver. - static ObjCMessageExpr *CreateEmpty(ASTContext &Context, + static ObjCMessageExpr *CreateEmpty(const ASTContext &Context, unsigned NumArgs, unsigned NumStoredSelLocs); diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 4079772b34..9c70383b1e 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -1456,7 +1456,7 @@ public: /// isLiteralType - Return true if this is a literal type /// (C++11 [basic.types]p10) - bool isLiteralType(ASTContext &Ctx) const; + bool isLiteralType(const ASTContext &Ctx) const; /// \brief Test if this type is a standard-layout type. /// (C++0x [basic.type]p9) diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index c2bbda3343..0ba117e3e2 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -238,8 +238,8 @@ SourceLocation Expr::getExprLoc() const { /// \brief Compute the type-, value-, and instantiation-dependence of a /// declaration reference /// based on the declaration being referenced. -static void computeDeclRefDependence(ASTContext &Ctx, NamedDecl *D, QualType T, - bool &TypeDependent, +static void computeDeclRefDependence(const ASTContext &Ctx, NamedDecl *D, + QualType T, bool &TypeDependent, bool &ValueDependent, bool &InstantiationDependent) { TypeDependent = false; @@ -328,7 +328,7 @@ static void computeDeclRefDependence(ASTContext &Ctx, NamedDecl *D, QualType T, } } -void DeclRefExpr::computeDependence(ASTContext &Ctx) { +void DeclRefExpr::computeDependence(const ASTContext &Ctx) { bool TypeDependent = false; bool ValueDependent = false; bool InstantiationDependent = false; @@ -362,7 +362,7 @@ void DeclRefExpr::computeDependence(ASTContext &Ctx) { ExprBits.ContainsUnexpandedParameterPack = true; } -DeclRefExpr::DeclRefExpr(ASTContext &Ctx, +DeclRefExpr::DeclRefExpr(const ASTContext &Ctx, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingLocal, @@ -399,7 +399,7 @@ DeclRefExpr::DeclRefExpr(ASTContext &Ctx, computeDependence(Ctx); } -DeclRefExpr *DeclRefExpr::Create(ASTContext &Context, +DeclRefExpr *DeclRefExpr::Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, @@ -415,7 +415,7 @@ DeclRefExpr *DeclRefExpr::Create(ASTContext &Context, T, VK, FoundD, TemplateArgs); } -DeclRefExpr *DeclRefExpr::Create(ASTContext &Context, +DeclRefExpr *DeclRefExpr::Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, @@ -445,7 +445,7 @@ DeclRefExpr *DeclRefExpr::Create(ASTContext &Context, NameInfo, FoundD, TemplateArgs, T, VK); } -DeclRefExpr *DeclRefExpr::CreateEmpty(ASTContext &Context, +DeclRefExpr *DeclRefExpr::CreateEmpty(const ASTContext &Context, bool HasQualifier, bool HasFoundDecl, bool HasTemplateKWAndArgsInfo, @@ -3378,7 +3378,7 @@ void ObjCMessageExpr::initArgsAndSelLocs(ArrayRef Args, } } -ObjCMessageExpr *ObjCMessageExpr::Create(ASTContext &Context, QualType T, +ObjCMessageExpr *ObjCMessageExpr::Create(const ASTContext &Context, QualType T, ExprValueKind VK, SourceLocation LBracLoc, SourceLocation SuperLoc, @@ -3403,7 +3403,7 @@ ObjCMessageExpr *ObjCMessageExpr::Create(ASTContext &Context, QualType T, Method, Args, RBracLoc, isImplicit); } -ObjCMessageExpr *ObjCMessageExpr::Create(ASTContext &Context, QualType T, +ObjCMessageExpr *ObjCMessageExpr::Create(const ASTContext &Context, QualType T, ExprValueKind VK, SourceLocation LBracLoc, TypeSourceInfo *Receiver, @@ -3426,7 +3426,7 @@ ObjCMessageExpr *ObjCMessageExpr::Create(ASTContext &Context, QualType T, isImplicit); } -ObjCMessageExpr *ObjCMessageExpr::Create(ASTContext &Context, QualType T, +ObjCMessageExpr *ObjCMessageExpr::Create(const ASTContext &Context, QualType T, ExprValueKind VK, SourceLocation LBracLoc, Expr *Receiver, @@ -3449,14 +3449,14 @@ ObjCMessageExpr *ObjCMessageExpr::Create(ASTContext &Context, QualType T, isImplicit); } -ObjCMessageExpr *ObjCMessageExpr::CreateEmpty(ASTContext &Context, +ObjCMessageExpr *ObjCMessageExpr::CreateEmpty(const ASTContext &Context, unsigned NumArgs, unsigned NumStoredSelLocs) { ObjCMessageExpr *Mem = alloc(Context, NumArgs, NumStoredSelLocs); return new (Mem) ObjCMessageExpr(EmptyShell(), NumArgs); } -ObjCMessageExpr *ObjCMessageExpr::alloc(ASTContext &C, +ObjCMessageExpr *ObjCMessageExpr::alloc(const ASTContext &C, ArrayRef Args, SourceLocation RBraceLoc, ArrayRef SelLocs, @@ -3468,7 +3468,7 @@ ObjCMessageExpr *ObjCMessageExpr::alloc(ASTContext &C, return alloc(C, Args.size(), NumStoredSelLocs); } -ObjCMessageExpr *ObjCMessageExpr::alloc(ASTContext &C, +ObjCMessageExpr *ObjCMessageExpr::alloc(const ASTContext &C, unsigned NumArgs, unsigned NumStoredSelLocs) { unsigned Size = sizeof(ObjCMessageExpr) + sizeof(void *) + @@ -3979,7 +3979,7 @@ ObjCArrayLiteral::ObjCArrayLiteral(ArrayRef Elements, } } -ObjCArrayLiteral *ObjCArrayLiteral::Create(ASTContext &C, +ObjCArrayLiteral *ObjCArrayLiteral::Create(const ASTContext &C, ArrayRef Elements, QualType T, ObjCMethodDecl * Method, SourceRange SR) { @@ -3988,7 +3988,7 @@ ObjCArrayLiteral *ObjCArrayLiteral::Create(ASTContext &C, return new (Mem) ObjCArrayLiteral(Elements, T, Method, SR); } -ObjCArrayLiteral *ObjCArrayLiteral::CreateEmpty(ASTContext &C, +ObjCArrayLiteral *ObjCArrayLiteral::CreateEmpty(const ASTContext &C, unsigned NumElements) { void *Mem = C.Allocate(sizeof(ObjCArrayLiteral) @@ -4033,7 +4033,7 @@ ObjCDictionaryLiteral::ObjCDictionaryLiteral( } ObjCDictionaryLiteral * -ObjCDictionaryLiteral::Create(ASTContext &C, +ObjCDictionaryLiteral::Create(const ASTContext &C, ArrayRef VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, @@ -4048,7 +4048,7 @@ ObjCDictionaryLiteral::Create(ASTContext &C, } ObjCDictionaryLiteral * -ObjCDictionaryLiteral::CreateEmpty(ASTContext &C, unsigned NumElements, +ObjCDictionaryLiteral::CreateEmpty(const ASTContext &C, unsigned NumElements, bool HasPackExpansions) { unsigned ExpansionsSize = 0; if (HasPackExpansions) @@ -4059,7 +4059,7 @@ ObjCDictionaryLiteral::CreateEmpty(ASTContext &C, unsigned NumElements, HasPackExpansions); } -ObjCSubscriptRefExpr *ObjCSubscriptRefExpr::Create(ASTContext &C, +ObjCSubscriptRefExpr *ObjCSubscriptRefExpr::Create(const ASTContext &C, Expr *base, Expr *key, QualType T, ObjCMethodDecl *getMethod, diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index bb6d0bf05d..0db4fad042 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -1130,7 +1130,7 @@ bool QualType::isTriviallyCopyableType(ASTContext &Context) const { -bool Type::isLiteralType(ASTContext &Ctx) const { +bool Type::isLiteralType(const ASTContext &Ctx) const { if (isDependentType()) return false;