From 9db7a7eb4e23758e041752c9c0c0ec1663d5a0af Mon Sep 17 00:00:00 2001 From: Craig Topper <craig.topper@gmail.com> Date: Thu, 22 Aug 2013 04:58:56 +0000 Subject: [PATCH] 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 --- include/clang/AST/Expr.h | 10 +++++----- include/clang/AST/ExprObjC.h | 23 ++++++++++++----------- include/clang/AST/Type.h | 2 +- lib/AST/Expr.cpp | 36 ++++++++++++++++++------------------ lib/AST/Type.cpp | 2 +- 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 1d957aa2be3..0b25eb49a4a 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -906,7 +906,7 @@ class DeclRefExpr : public Expr { return const_cast<DeclRefExpr *>(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 a94c69a115d..aeb55da1fb9 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<Expr *> 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<ObjCDictionaryElement> 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<Expr *> Args, SourceLocation RBraceLoc, ArrayRef<SourceLocation> 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 4079772b34c..9c70383b1ef 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 c2bbda33433..0ba117e3e2a 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<Expr *> 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<Expr *> Args, SourceLocation RBraceLoc, ArrayRef<SourceLocation> 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<Expr *> Elements, } } -ObjCArrayLiteral *ObjCArrayLiteral::Create(ASTContext &C, +ObjCArrayLiteral *ObjCArrayLiteral::Create(const ASTContext &C, ArrayRef<Expr *> 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<ObjCDictionaryElement> 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 bb6d0bf05d1..0db4fad0429 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; -- GitLab