]> granicus.if.org Git - clang/commitdiff
Switch over functiondecl. This makes it obvious that the ASTContext
authorChris Lattner <sabre@nondot.org>
Sat, 15 Mar 2008 21:24:04 +0000 (21:24 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 15 Mar 2008 21:24:04 +0000 (21:24 +0000)
argument to Create should be first, not last.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48397 91177308-0d34-0410-b5e6-96231b3b80d8

AST/Decl.cpp
AST/DeclSerialization.cpp
Driver/RewriteTest.cpp
Sema/SemaDecl.cpp
include/clang/AST/Decl.h

index a171589f1358ab8e39e3dd0b6110b71cb0ad1ff4..8487efb8449b406cf43872100e723f120bf76d55 100644 (file)
@@ -227,6 +227,15 @@ ParmVarDecl *ParmVarDecl::Create(SourceLocation L, IdentifierInfo *Id,
   return new (Mem) ParmVarDecl(L, Id, T, S, PrevDecl);
 }
 
+FunctionDecl *FunctionDecl::Create(ASTContext &C, SourceLocation L, 
+                                   IdentifierInfo *Id, QualType T, 
+                                   StorageClass S, bool isInline, 
+                                   ScopedDecl *PrevDecl) {
+  void *Mem = C.getAllocator().Allocate<FunctionDecl>();
+  return new (Mem) FunctionDecl(L, Id, T, S, isInline, PrevDecl);
+}
+
+
 EnumConstantDecl *EnumConstantDecl::Create(SourceLocation L, IdentifierInfo *Id,
                                            QualType T, Expr *E, 
                                            const llvm::APSInt &V, 
index 26b36c2994d7885766cbcade7ee81636b3233351..a7eaed5b2efefc4fcf46c15758e72679714ef9d9 100644 (file)
@@ -338,7 +338,7 @@ FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D) {
   bool IsInline = D.ReadBool();
   
   FunctionDecl* decl =
-    new FunctionDecl(SourceLocation(),NULL,QualType(),SClass,IsInline);
+    new FunctionDecl(SourceLocation(),NULL,QualType(),SClass, IsInline, 0);
   
   decl->ValueDecl::ReadInRec(D);
   D.ReadPtr(decl->DeclChain);
index dfad8ecccf79e7d3f6e5d623c7e3c7fa670e3d8f..d2af2bd2e01a5470c40de745626d5b25e5989b67 100644 (file)
@@ -1554,7 +1554,7 @@ void RewriteTest::SynthSelGetUidFunctionDecl() {
   QualType getFuncType = Context->getFunctionType(Context->getObjCSelType(),
                                                    &ArgTys[0], ArgTys.size(),
                                                    false /*isVariadic*/);
-  SelGetUidFunctionDecl = new FunctionDecl(SourceLocation(), 
+  SelGetUidFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
                                            SelGetUidIdent, getFuncType,
                                            FunctionDecl::Extern, false, 0);
 }
@@ -1568,7 +1568,7 @@ void RewriteTest::SynthGetProtocolFunctionDecl() {
   QualType getFuncType = Context->getFunctionType(Context->getObjCProtoType(),
                                                   &ArgTys[0], ArgTys.size(),
                                                   false /*isVariadic*/);
-  GetProtocolFunctionDecl = new FunctionDecl(SourceLocation(), 
+  GetProtocolFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
                                              SelGetProtoIdent, getFuncType,
                                              FunctionDecl::Extern, false, 0);
 }
@@ -1595,7 +1595,7 @@ void RewriteTest::SynthSuperContructorFunctionDecl() {
   QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
                                                   &ArgTys[0], ArgTys.size(),
                                                   false);
-  SuperContructorFunctionDecl = new FunctionDecl(SourceLocation(), 
+  SuperContructorFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
                                          msgSendIdent, msgSendType,
                                          FunctionDecl::Extern, false, 0);
 }
@@ -1613,7 +1613,7 @@ void RewriteTest::SynthMsgSendFunctionDecl() {
   QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
                                                   &ArgTys[0], ArgTys.size(),
                                                   true /*isVariadic*/);
-  MsgSendFunctionDecl = new FunctionDecl(SourceLocation(), 
+  MsgSendFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
                                          msgSendIdent, msgSendType,
                                          FunctionDecl::Extern, false, 0);
 }
@@ -1634,7 +1634,7 @@ void RewriteTest::SynthMsgSendSuperFunctionDecl() {
   QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
                                                   &ArgTys[0], ArgTys.size(),
                                                   true /*isVariadic*/);
-  MsgSendSuperFunctionDecl = new FunctionDecl(SourceLocation(), 
+  MsgSendSuperFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
                                               msgSendIdent, msgSendType,
                                               FunctionDecl::Extern, false, 0);
 }
@@ -1652,7 +1652,7 @@ void RewriteTest::SynthMsgSendStretFunctionDecl() {
   QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
                                                   &ArgTys[0], ArgTys.size(),
                                                   true /*isVariadic*/);
-  MsgSendStretFunctionDecl = new FunctionDecl(SourceLocation(), 
+  MsgSendStretFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
                                          msgSendIdent, msgSendType,
                                          FunctionDecl::Extern, false, 0);
 }
@@ -1675,7 +1675,8 @@ void RewriteTest::SynthMsgSendSuperStretFunctionDecl() {
   QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
                                                   &ArgTys[0], ArgTys.size(),
                                                   true /*isVariadic*/);
-  MsgSendSuperStretFunctionDecl = new FunctionDecl(SourceLocation(), 
+  MsgSendSuperStretFunctionDecl = FunctionDecl::Create(*Context,
+                                                       SourceLocation(), 
                                               msgSendIdent, msgSendType,
                                               FunctionDecl::Extern, false, 0);
 }
@@ -1693,7 +1694,7 @@ void RewriteTest::SynthMsgSendFpretFunctionDecl() {
   QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
                                                   &ArgTys[0], ArgTys.size(),
                                                   true /*isVariadic*/);
-  MsgSendFpretFunctionDecl = new FunctionDecl(SourceLocation(), 
+  MsgSendFpretFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
                                               msgSendIdent, msgSendType,
                                               FunctionDecl::Extern, false, 0);
 }
@@ -1707,7 +1708,7 @@ void RewriteTest::SynthGetClassFunctionDecl() {
   QualType getClassType = Context->getFunctionType(Context->getObjCIdType(),
                                                    &ArgTys[0], ArgTys.size(),
                                                    false /*isVariadic*/);
-  GetClassFunctionDecl = new FunctionDecl(SourceLocation(), 
+  GetClassFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
                                           getClassIdent, getClassType,
                                           FunctionDecl::Extern, false, 0);
 }
@@ -1721,7 +1722,7 @@ void RewriteTest::SynthGetMetaClassFunctionDecl() {
   QualType getClassType = Context->getFunctionType(Context->getObjCIdType(),
                                                    &ArgTys[0], ArgTys.size(),
                                                    false /*isVariadic*/);
-  GetMetaClassFunctionDecl = new FunctionDecl(SourceLocation(), 
+  GetMetaClassFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
                                               getClassIdent, getClassType,
                                               FunctionDecl::Extern, false, 0);
 }
index 13d49b09800c96c5b2657a076e9b2bed6f2921b3..a4c1a781ef67d4cc453421f9f65765385a36147d 100644 (file)
@@ -166,8 +166,8 @@ ScopedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid,
     InitBuiltinVaListType();
     
   QualType R = Context.BuiltinInfo.GetBuiltinType(BID, Context);  
-  FunctionDecl *New = new FunctionDecl(SourceLocation(), II, R,
-                                       FunctionDecl::Extern, false, 0);
+  FunctionDecl *New = FunctionDecl::Create(Context, SourceLocation(), II, R,
+                                           FunctionDecl::Extern, false, 0);
   
   // Find translation-unit scope to insert this function into.
   if (Scope *FnS = S->getFnParent())
@@ -753,9 +753,10 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) {
       case DeclSpec::SCS_private_extern: SC = FunctionDecl::PrivateExtern;break;
     }
 
-    FunctionDecl *NewFD = new FunctionDecl(D.getIdentifierLoc(), II, R, SC,
-                                           D.getDeclSpec().isInlineSpecified(),
-                                           LastDeclarator);
+    bool isInline = D.getDeclSpec().isInlineSpecified();
+    FunctionDecl *NewFD = FunctionDecl::Create(Context, D.getIdentifierLoc(),
+                                               II, R, SC, isInline,
+                                               LastDeclarator);
     // Handle attributes.
     HandleDeclAttributes(NewFD, D.getDeclSpec().getAttributes(),
                          D.getAttributes());
index df484fbca98dd23eeff1b5472ff67ca1fe5764c5..cf9290cfbde9868d0308ac16c1d89a9f0223a623 100644 (file)
@@ -435,13 +435,18 @@ public:
   enum StorageClass {
     None, Extern, Static, PrivateExtern
   };
+private:
   FunctionDecl(SourceLocation L, IdentifierInfo *Id, QualType T,
-               StorageClass S = None, bool isInline = false, 
-               ScopedDecl *PrevDecl = 0)
+               StorageClass S, bool isInline, ScopedDecl *PrevDecl)
     : ValueDecl(Function, L, Id, T, PrevDecl), 
       ParamInfo(0), Body(0), DeclChain(0), SClass(S), IsInline(isInline) {}
   virtual ~FunctionDecl();
-
+public:
+  static FunctionDecl *Create(ASTContext &C, SourceLocation L,
+                              IdentifierInfo *Id, QualType T, 
+                              StorageClass S = None, bool isInline = false, 
+                              ScopedDecl *PrevDecl = 0);
+  
   Stmt *getBody() const { return Body; }
   void setBody(Stmt *B) { Body = B; }