[cfe-commits] r41416 - in /cfe/trunk: Driver/ASTStreamers.cpp Sema/SemaDecl.cpp include/clang/AST/Decl.h

Chris Lattner sabre at nondot.org
Sat Aug 25 21:02:13 PDT 2007


Author: lattner
Date: Sat Aug 25 23:02:13 2007
New Revision: 41416

URL: http://llvm.org/viewvc/llvm-project?rev=41416&view=rev
Log:
Make parse-ast-print print the storage class and inline 
specifier of functions.


Modified:
    cfe/trunk/Driver/ASTStreamers.cpp
    cfe/trunk/Sema/SemaDecl.cpp
    cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/Driver/ASTStreamers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTStreamers.cpp?rev=41416&r1=41415&r2=41416&view=diff

==============================================================================
--- cfe/trunk/Driver/ASTStreamers.cpp (original)
+++ cfe/trunk/Driver/ASTStreamers.cpp Sat Aug 25 23:02:13 2007
@@ -47,6 +47,18 @@
 static void PrintFunctionDeclStart(FunctionDecl *FD) {
   bool HasBody = FD->getBody();
   
+  fprintf(stderr, "\n");
+
+  switch (FD->getStorageClass()) {
+  default: assert(0 && "Unknown storage class");
+  case FunctionDecl::None: break;
+  case FunctionDecl::Extern: fprintf(stderr, "extern "); break;
+  case FunctionDecl::Static: fprintf(stderr, "static "); break;
+  }
+  
+  if (FD->isInline())
+    fprintf(stderr, "inline ");
+  
   std::string Proto = FD->getName();
   FunctionType *AFT = cast<FunctionType>(FD->getType());
 
@@ -72,7 +84,7 @@
   }
 
   AFT->getResultType().getAsStringInternal(Proto);
-  fprintf(stderr, "\n%s", Proto.c_str());
+  fprintf(stderr, "%s", Proto.c_str());
   
   if (!FD->getBody())
     fprintf(stderr, ";\n");

Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=41416&r1=41415&r2=41416&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Sat Aug 25 23:02:13 2007
@@ -156,7 +156,7 @@
 
   QualType R = Context.BuiltinInfo.GetBuiltinType(BID, Context);
   FunctionDecl *New = new FunctionDecl(SourceLocation(), II, R,
-                                       FunctionDecl::Extern, 0);
+                                       FunctionDecl::Extern, false, 0);
   
   // Find translation-unit scope to insert this function into.
   while (S->getParent())
@@ -334,6 +334,7 @@
     }
 
     FunctionDecl *NewFD = new FunctionDecl(D.getIdentifierLoc(), II, R, SC,
+                                           D.getDeclSpec().isInlineSpecified(),
                                            LastDeclarator);
     
     // Merge the decl with the existing one if appropriate.

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=41416&r1=41415&r2=41416&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sat Aug 25 23:02:13 2007
@@ -239,9 +239,9 @@
     None, Extern, Static
   };
   FunctionDecl(SourceLocation L, IdentifierInfo *Id, QualType T,
-               StorageClass S = None, Decl *PrevDecl = 0)
+               StorageClass S = None, bool isInline, Decl *PrevDecl = 0)
     : ValueDecl(Function, L, Id, T, PrevDecl), 
-      ParamInfo(0), Body(0), DeclChain(0), SClass(S) {}
+      ParamInfo(0), Body(0), DeclChain(0), SClass(S), IsInline(isInline) {}
   virtual ~FunctionDecl();
 
   Stmt *getBody() const { return Body; }
@@ -265,6 +265,7 @@
     return cast<FunctionType>(getType())->getResultType();
   }
   StorageClass getStorageClass() const { return SClass; }
+  bool isInline() const { return IsInline; }
     
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return D->getKind() == Function; }
@@ -282,7 +283,8 @@
   /// function.
   Decl *DeclChain;
 
-  StorageClass SClass;
+  StorageClass SClass : 2;
+  bool IsInline : 1;
 };
 
 





More information about the cfe-commits mailing list