From c63e660882ff93841fa234d70ef6757038302b92 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 15 Mar 2008 21:32:50 +0000 Subject: [PATCH] move the ASTContext argument to be first in the argument list of all Create methods. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48398 91177308-0d34-0410-b5e6-96231b3b80d8 --- AST/ASTContext.cpp | 4 ++-- AST/Decl.cpp | 39 ++++++++++++++++++++------------------- Driver/RewriteTest.cpp | 29 ++++++++++++++--------------- Sema/Sema.cpp | 26 ++++++++++++++------------ Sema/SemaDecl.cpp | 24 ++++++++++++------------ Sema/SemaDeclObjC.cpp | 4 ++-- include/clang/AST/Decl.h | 34 ++++++++++++++++------------------ 7 files changed, 80 insertions(+), 80 deletions(-) diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp index ad54010c50..db4d53aa48 100644 --- a/AST/ASTContext.cpp +++ b/AST/ASTContext.cpp @@ -1048,8 +1048,8 @@ QualType ASTContext::maxIntegerType(QualType lhs, QualType rhs) { QualType ASTContext::getCFConstantStringType() { if (!CFConstantStringTypeDecl) { CFConstantStringTypeDecl = - RecordDecl::Create(Decl::Struct, SourceLocation(), - &Idents.get("NSConstantString"), 0, *this); + RecordDecl::Create(*this, Decl::Struct, SourceLocation(), + &Idents.get("NSConstantString"), 0); QualType FieldTypes[4]; // const int *isa; diff --git a/AST/Decl.cpp b/AST/Decl.cpp index 8487efb844..7fa679cbc0 100644 --- a/AST/Decl.cpp +++ b/AST/Decl.cpp @@ -205,24 +205,24 @@ void Decl::addDeclKind(Kind k) { // Decl Allocation/Deallocation Method Implementations //===----------------------------------------------------------------------===// -BlockVarDecl *BlockVarDecl::Create(SourceLocation L, IdentifierInfo *Id, - QualType T, StorageClass S, - ScopedDecl *PrevDecl, ASTContext &C) { +BlockVarDecl *BlockVarDecl::Create(ASTContext &C, SourceLocation L, + IdentifierInfo *Id, QualType T, + StorageClass S, ScopedDecl *PrevDecl) { void *Mem = C.getAllocator().Allocate(); return new (Mem) BlockVarDecl(L, Id, T, S, PrevDecl); } -FileVarDecl *FileVarDecl::Create(SourceLocation L, IdentifierInfo *Id, - QualType T, StorageClass S, - ScopedDecl *PrevDecl, ASTContext &C) { +FileVarDecl *FileVarDecl::Create(ASTContext &C, SourceLocation L, + IdentifierInfo *Id, QualType T, StorageClass S, + ScopedDecl *PrevDecl) { void *Mem = C.getAllocator().Allocate(); return new (Mem) FileVarDecl(L, Id, T, S, PrevDecl); } -ParmVarDecl *ParmVarDecl::Create(SourceLocation L, IdentifierInfo *Id, - QualType T, StorageClass S, - ScopedDecl *PrevDecl, ASTContext &C) { +ParmVarDecl *ParmVarDecl::Create(ASTContext &C, SourceLocation L, + IdentifierInfo *Id, QualType T, StorageClass S, + ScopedDecl *PrevDecl) { void *Mem = C.getAllocator().Allocate(); return new (Mem) ParmVarDecl(L, Id, T, S, PrevDecl); } @@ -236,28 +236,29 @@ FunctionDecl *FunctionDecl::Create(ASTContext &C, SourceLocation L, } -EnumConstantDecl *EnumConstantDecl::Create(SourceLocation L, IdentifierInfo *Id, - QualType T, Expr *E, - const llvm::APSInt &V, - ScopedDecl *PrevDecl, ASTContext &C){ +EnumConstantDecl *EnumConstantDecl::Create(ASTContext &C, SourceLocation L, + IdentifierInfo *Id, QualType T, + Expr *E, const llvm::APSInt &V, + ScopedDecl *PrevDecl){ void *Mem = C.getAllocator().Allocate(); return new (Mem) EnumConstantDecl(L, Id, T, E, V, PrevDecl); } -TypedefDecl *TypedefDecl::Create(SourceLocation L, IdentifierInfo *Id, - QualType T, ScopedDecl *PD, ASTContext &C) { +TypedefDecl *TypedefDecl::Create(ASTContext &C, SourceLocation L, + IdentifierInfo *Id, QualType T, + ScopedDecl *PD) { void *Mem = C.getAllocator().Allocate(); return new (Mem) TypedefDecl(L, Id, T, PD); } -EnumDecl *EnumDecl::Create(SourceLocation L, IdentifierInfo *Id, - ScopedDecl *PrevDecl, ASTContext &C) { +EnumDecl *EnumDecl::Create(ASTContext &C, SourceLocation L, IdentifierInfo *Id, + ScopedDecl *PrevDecl) { void *Mem = C.getAllocator().Allocate(); return new (Mem) EnumDecl(L, Id, PrevDecl); } -RecordDecl *RecordDecl::Create(Kind DK, SourceLocation L, IdentifierInfo *Id, - ScopedDecl *PrevDecl, ASTContext &C) { +RecordDecl *RecordDecl::Create(ASTContext &C, Kind DK, SourceLocation L, + IdentifierInfo *Id, ScopedDecl *PrevDecl) { void *Mem = C.getAllocator().Allocate(); return new (Mem) RecordDecl(DK, L, Id, PrevDecl); } diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp index d2af2bd2e0..b4de21c707 100644 --- a/Driver/RewriteTest.cpp +++ b/Driver/RewriteTest.cpp @@ -796,7 +796,8 @@ Stmt *RewriteTest::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) { std::string RecName = clsDeclared->getIdentifier()->getName(); RecName += "_IMPL"; IdentifierInfo *II = &Context->Idents.get(RecName.c_str()); - RecordDecl *RD = RecordDecl::Create(Decl::Struct, SourceLocation(), II, 0, *Context); + RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, + SourceLocation(), II, 0); assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl"); QualType castT = Context->getPointerType(Context->getTagDeclType(RD)); CastExpr *castExpr = new CastExpr(castT, IV->getBase(), SourceLocation()); @@ -1622,9 +1623,8 @@ void RewriteTest::SynthMsgSendFunctionDecl() { void RewriteTest::SynthMsgSendSuperFunctionDecl() { IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSendSuper"); llvm::SmallVector ArgTys; - RecordDecl *RD = RecordDecl::Create(Decl::Struct, SourceLocation(), - &Context->Idents.get("objc_super"), 0, - *Context); + RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, SourceLocation(), + &Context->Idents.get("objc_super"), 0); QualType argT = Context->getPointerType(Context->getTagDeclType(RD)); assert(!argT.isNull() && "Can't build 'struct objc_super *' type"); ArgTys.push_back(argT); @@ -1663,9 +1663,8 @@ void RewriteTest::SynthMsgSendSuperStretFunctionDecl() { IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSendSuper_stret"); llvm::SmallVector ArgTys; - RecordDecl *RD = RecordDecl::Create(Decl::Struct, SourceLocation(), - &Context->Idents.get("objc_super"), 0, - *Context); + RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, SourceLocation(), + &Context->Idents.get("objc_super"), 0); QualType argT = Context->getPointerType(Context->getTagDeclType(RD)); assert(!argT.isNull() && "Can't build 'struct objc_super *' type"); ArgTys.push_back(argT); @@ -1745,9 +1744,9 @@ Stmt *RewriteTest::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) { InsertText(SourceLocation::getFileLoc(MainFileID, 0), StrObjDecl.c_str(), StrObjDecl.size()); - FileVarDecl *NewVD = FileVarDecl::Create(SourceLocation(), + FileVarDecl *NewVD = FileVarDecl::Create(*Context, SourceLocation(), &Context->Idents.get(S.c_str()), strType, - VarDecl::Static, NULL, *Context); + VarDecl::Static, NULL); DeclRefExpr *DRE = new DeclRefExpr(NewVD, strType, SourceLocation()); Expr *Unop = new UnaryOperator(DRE, UnaryOperator::AddrOf, Context->getPointerType(DRE->getType()), @@ -1793,9 +1792,9 @@ ObjCInterfaceDecl *RewriteTest::isSuperReceiver(Expr *recExpr) { // struct objc_super { struct objc_object *receiver; struct objc_class *super; }; QualType RewriteTest::getSuperStructType() { if (!SuperStructDecl) { - SuperStructDecl = RecordDecl::Create(Decl::Struct, SourceLocation(), - &Context->Idents.get("objc_super"), 0, - *Context); + SuperStructDecl = RecordDecl::Create(*Context, Decl::Struct, + SourceLocation(), + &Context->Idents.get("objc_super"), 0); QualType FieldTypes[2]; // struct objc_object *receiver; @@ -1815,9 +1814,9 @@ QualType RewriteTest::getSuperStructType() { QualType RewriteTest::getConstantStringStructType() { if (!ConstantStringDecl) { - ConstantStringDecl = RecordDecl::Create(Decl::Struct, SourceLocation(), - &Context->Idents.get("__NSConstantStringImpl"), 0, - *Context); + ConstantStringDecl = RecordDecl::Create(*Context, Decl::Struct, + SourceLocation(), + &Context->Idents.get("__NSConstantStringImpl"), 0); QualType FieldTypes[4]; // struct objc_object *receiver; diff --git a/Sema/Sema.cpp b/Sema/Sema.cpp index d8549198be..4bd04e3a1a 100644 --- a/Sema/Sema.cpp +++ b/Sema/Sema.cpp @@ -59,16 +59,17 @@ void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) { TUScope->AddDecl(IDecl); // Synthesize "typedef struct objc_selector *SEL;" - RecordDecl *SelTag = RecordDecl::Create(Decl::Struct, SourceLocation(), + RecordDecl *SelTag = RecordDecl::Create(Context, Decl::Struct, + SourceLocation(), &Context.Idents.get("objc_selector"), - 0, Context); + 0); SelTag->getIdentifier()->setFETokenInfo(SelTag); TUScope->AddDecl(SelTag); QualType SelT = Context.getPointerType(Context.getTagDeclType(SelTag)); - TypedefDecl *SelTypedef = TypedefDecl::Create(SourceLocation(), + TypedefDecl *SelTypedef = TypedefDecl::Create(Context, SourceLocation(), &Context.Idents.get("SEL"), - SelT, 0, Context); + SelT, 0); SelTypedef->getIdentifier()->setFETokenInfo(SelTypedef); TUScope->AddDecl(SelTypedef); Context.setObjCSelType(SelTypedef); @@ -97,12 +98,13 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer) // and make sure the decls get inserted into TUScope! if (PP.getLangOptions().ObjC1) { // Synthesize "typedef struct objc_class *Class;" - RecordDecl *ClassTag = RecordDecl::Create(Decl::Struct, SourceLocation(), - &IT.get("objc_class"), 0,Context); + RecordDecl *ClassTag = RecordDecl::Create(Context, Decl::Struct, + SourceLocation(), + &IT.get("objc_class"), 0); QualType ClassT = Context.getPointerType(Context.getTagDeclType(ClassTag)); TypedefDecl *ClassTypedef = - TypedefDecl::Create(SourceLocation(), &Context.Idents.get("Class"), - ClassT, 0, Context); + TypedefDecl::Create(Context, SourceLocation(), + &Context.Idents.get("Class"), ClassT, 0); Context.setObjCClassType(ClassTypedef); // Synthesize "@class Protocol; @@ -112,15 +114,15 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer) // Synthesize "typedef struct objc_object { Class isa; } *id;" RecordDecl *ObjectTag = - RecordDecl::Create(Decl::Struct, SourceLocation(), &IT.get("objc_object"), - 0, Context); + RecordDecl::Create(Context, Decl::Struct, SourceLocation(), + &IT.get("objc_object"), 0); FieldDecl *IsaDecl = new FieldDecl(SourceLocation(), 0, Context.getObjCClassType()); ObjectTag->defineBody(&IsaDecl, 1); QualType ObjT = Context.getPointerType(Context.getTagDeclType(ObjectTag)); - TypedefDecl *IdTypedef = TypedefDecl::Create(SourceLocation(), + TypedefDecl *IdTypedef = TypedefDecl::Create(Context, SourceLocation(), &Context.Idents.get("id"), - ObjT, 0, Context); + ObjT, 0); Context.setObjCIdType(IdTypedef); } TUScope = 0; diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index a4c1a781ef..7914e86574 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -794,11 +794,11 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) { R.getAsString()); InvalidDecl = true; } - NewVD = FileVarDecl::Create(D.getIdentifierLoc(), II, R, SC, - LastDeclarator, Context); + NewVD = FileVarDecl::Create(Context, D.getIdentifierLoc(), II, R, SC, + LastDeclarator); } else { - NewVD = BlockVarDecl::Create(D.getIdentifierLoc(), II, R, SC, - LastDeclarator, Context); + NewVD = BlockVarDecl::Create(Context, D.getIdentifierLoc(), II, R, SC, + LastDeclarator); } // Handle attributes prior to checking for duplicates in MergeVarDecl HandleDeclAttributes(NewVD, D.getDeclSpec().getAttributes(), @@ -1017,8 +1017,8 @@ Sema::ActOnParamDeclarator(struct DeclaratorChunk::ParamInfo &PI, } else if (parmDeclType->isFunctionType()) parmDeclType = Context.getPointerType(parmDeclType); - ParmVarDecl *New = ParmVarDecl::Create(PI.IdentLoc, II, parmDeclType, - VarDecl::None, 0, Context); + ParmVarDecl *New = ParmVarDecl::Create(Context, PI.IdentLoc, II, parmDeclType, + VarDecl::None, 0); if (PI.InvalidType) New->setInvalidDecl(); @@ -1178,9 +1178,9 @@ TypedefDecl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, QualType T, assert(!T.isNull() && "GetTypeForDeclarator() returned null type"); // Scope manipulation handled by caller. - TypedefDecl *NewTD = TypedefDecl::Create(D.getIdentifierLoc(), + TypedefDecl *NewTD = TypedefDecl::Create(Context, D.getIdentifierLoc(), D.getIdentifier(), - T, LastDeclarator, Context); + T, LastDeclarator); if (D.getInvalidType()) NewTD->setInvalidDecl(); return NewTD; @@ -1259,7 +1259,7 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagType, TagKind TK, case Decl::Enum: // FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.: // enum X { A, B, C } D; D should chain to X. - New = EnumDecl::Create(Loc, Name, 0, Context); + New = EnumDecl::Create(Context, Loc, Name, 0); // If this is an undefined enum, warn. if (TK != TK_Definition) Diag(Loc, diag::ext_forward_ref_enum); break; @@ -1268,7 +1268,7 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagType, TagKind TK, case Decl::Class: // FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.: // struct X { int A; } D; D should chain to X. - New = RecordDecl::Create(Kind, Loc, Name, 0, Context); + New = RecordDecl::Create(Context, Kind, Loc, Name, 0); break; } @@ -1582,8 +1582,8 @@ Sema::DeclTy *Sema::ActOnEnumConstant(Scope *S, DeclTy *theEnumDecl, } EnumConstantDecl *New = - EnumConstantDecl::Create(IdLoc, Id, EltTy, Val, EnumVal, LastEnumConst, - Context); + EnumConstantDecl::Create(Context, IdLoc, Id, EltTy, Val, EnumVal, + LastEnumConst); // Register this decl in the current scope stack. New->setNext(Id->getFETokenInfo()); diff --git a/Sema/SemaDeclObjC.cpp b/Sema/SemaDeclObjC.cpp index 1e60a39647..20d127b31e 100644 --- a/Sema/SemaDeclObjC.cpp +++ b/Sema/SemaDeclObjC.cpp @@ -823,9 +823,9 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration( argType = QualType::getFromOpaquePtr(ArgTypes[i]); else argType = Context.getObjCIdType(); - ParmVarDecl* Param = ParmVarDecl::Create(SourceLocation(/*FIXME*/), + ParmVarDecl* Param = ParmVarDecl::Create(Context, SourceLocation(/*FIXME*/), ArgNames[i], argType, - VarDecl::None, 0, Context); + VarDecl::None, 0); Param->setObjCDeclQualifier( CvtQTToAstBitMask(ArgQT[i].getObjCDeclQualifier())); Params.push_back(Param); diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index cf9290cfbd..b53d5d3bcb 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -354,9 +354,9 @@ class BlockVarDecl : public VarDecl { ScopedDecl *PrevDecl) : VarDecl(BlockVar, L, Id, T, S, PrevDecl) {} public: - static BlockVarDecl *Create(SourceLocation L, IdentifierInfo *Id, QualType T, - StorageClass S, ScopedDecl *PrevDecl, - ASTContext &C); + static BlockVarDecl *Create(ASTContext &C, SourceLocation L, + IdentifierInfo *Id, QualType T, StorageClass S, + ScopedDecl *PrevDecl); // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == BlockVar; } static bool classof(const BlockVarDecl *D) { return true; } @@ -377,9 +377,8 @@ class FileVarDecl : public VarDecl { ScopedDecl *PrevDecl) : VarDecl(FileVar, L, Id, T, S, PrevDecl) {} public: - static FileVarDecl *Create(SourceLocation L, IdentifierInfo *Id, QualType T, - StorageClass S, ScopedDecl *PrevDecl, - ASTContext &C); + static FileVarDecl *Create(ASTContext &C, SourceLocation L,IdentifierInfo *Id, + QualType T, StorageClass S, ScopedDecl *PrevDecl); // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == FileVar; } @@ -404,9 +403,8 @@ class ParmVarDecl : public VarDecl { : VarDecl(ParmVar, L, Id, T, S, PrevDecl), objcDeclQualifier(OBJC_TQ_None) {} public: - static ParmVarDecl *Create(SourceLocation L, IdentifierInfo *Id, QualType T, - StorageClass S, ScopedDecl *PrevDecl, - ASTContext &C); + static ParmVarDecl *Create(ASTContext &C, SourceLocation L,IdentifierInfo *Id, + QualType T, StorageClass S, ScopedDecl *PrevDecl); ObjCDeclQualifier getObjCDeclQualifier() const { return ObjCDeclQualifier(objcDeclQualifier); @@ -559,9 +557,9 @@ protected: ~EnumConstantDecl() {} public: - static EnumConstantDecl *Create(SourceLocation L, IdentifierInfo *Id, - QualType T, Expr *E, const llvm::APSInt &V, - ScopedDecl *PrevDecl, ASTContext &C); + static EnumConstantDecl *Create(ASTContext &C, SourceLocation L, + IdentifierInfo *Id, QualType T, Expr *E, + const llvm::APSInt &V, ScopedDecl *PrevDecl); const Expr *getInitExpr() const { return Init; } Expr *getInitExpr() { return Init; } @@ -615,8 +613,8 @@ class TypedefDecl : public TypeDecl { ~TypedefDecl() {} public: - static TypedefDecl *Create(SourceLocation L, IdentifierInfo *Id, QualType T, - ScopedDecl *PD, ASTContext &C); + static TypedefDecl *Create(ASTContext &C, SourceLocation L,IdentifierInfo *Id, + QualType T, ScopedDecl *PD); QualType getUnderlyingType() const { return UnderlyingType; } void setUnderlyingType(QualType newType) { UnderlyingType = newType; } @@ -691,8 +689,8 @@ class EnumDecl : public TagDecl { } ~EnumDecl() {} public: - static EnumDecl *Create(SourceLocation L, IdentifierInfo *Id, - ScopedDecl *PrevDecl, ASTContext &C); + static EnumDecl *Create(ASTContext &C, SourceLocation L, IdentifierInfo *Id, + ScopedDecl *PrevDecl); /// defineElements - When created, EnumDecl correspond to a forward declared /// enum. This method is used to mark the decl as being defined, with the @@ -754,8 +752,8 @@ class RecordDecl : public TagDecl { ~RecordDecl() {} public: - static RecordDecl *Create(Kind DK, SourceLocation L, IdentifierInfo *Id, - ScopedDecl *PrevDecl, ASTContext &C); + static RecordDecl *Create(ASTContext &C, Kind DK, SourceLocation L, + IdentifierInfo *Id, ScopedDecl *PrevDecl); bool hasFlexibleArrayMember() const { return HasFlexibleArrayMember; } void setHasFlexibleArrayMember(bool V) { HasFlexibleArrayMember = V; } -- 2.40.0