]> granicus.if.org Git - clang/commitdiff
Make parse-ast-print print the storage class and inline
authorChris Lattner <sabre@nondot.org>
Sun, 26 Aug 2007 04:02:13 +0000 (04:02 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 26 Aug 2007 04:02:13 +0000 (04:02 +0000)
specifier of functions.

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

Driver/ASTStreamers.cpp
Sema/SemaDecl.cpp
include/clang/AST/Decl.h

index 3b6138ae3170cd6a3d77a19b434bae58a8485420..c819623f41e030719b1ed00c3cd18466f50a3820 100644 (file)
@@ -47,6 +47,18 @@ void clang::BuildASTs(Preprocessor &PP, unsigned MainFileID, bool Stats) {
 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 @@ static void PrintFunctionDeclStart(FunctionDecl *FD) {
   }
 
   AFT->getResultType().getAsStringInternal(Proto);
-  fprintf(stderr, "\n%s", Proto.c_str());
+  fprintf(stderr, "%s", Proto.c_str());
   
   if (!FD->getBody())
     fprintf(stderr, ";\n");
index 46e5a108ca5df26b3a321c6837eaddab77680a38..faf016b94481b3fb44706b16f98dd1b336c38e6e 100644 (file)
@@ -156,7 +156,7 @@ Decl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, Scope *S) {
 
   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 @@ Sema::ParseDeclarator(Scope *S, Declarator &D, ExprTy *init,
     }
 
     FunctionDecl *NewFD = new FunctionDecl(D.getIdentifierLoc(), II, R, SC,
+                                           D.getDeclSpec().isInlineSpecified(),
                                            LastDeclarator);
     
     // Merge the decl with the existing one if appropriate.
index 58eb7230788fc03035a6e9c9f5cfd0703a98c716..ca07cbf9727a492e836a2c86ff6909fd4d52a97e 100644 (file)
@@ -239,9 +239,9 @@ public:
     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 @@ public:
     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 @@ private:
   /// function.
   Decl *DeclChain;
 
-  StorageClass SClass;
+  StorageClass SClass : 2;
+  bool IsInline : 1;
 };