[cfe-commits] r72555 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td include/clang/Parse/Action.h include/clang/Parse/DeclSpec.h lib/Frontend/PrintParserCallbacks.cpp lib/Parse/DeclSpec.cpp lib/Parse/ParseDecl.cpp lib/Parse/ParseDeclC

Eli Friedman eli.friedman at gmail.com
Thu May 28 17:33:31 PDT 2009


On Thu, May 28, 2009 at 4:31 PM, Douglas Gregor<dgregor at apple.com> wrote:
>  2) We can extend DeclGroups to contain information about any tags
>  that are declared/defined within the declaration specifiers of a
>  variable, e.g.,
>
>    struct Point { int x, y, z; } p;
>
>  This will help improve AST printing and template instantiation,
>  among other things.

Does the attached look like a reasonable step in that direction?

-Eli
-------------- next part --------------
Index: include/clang/Parse/Action.h
===================================================================
--- include/clang/Parse/Action.h	(revision 72557)
+++ include/clang/Parse/Action.h	(working copy)
@@ -291,7 +291,8 @@
 
   /// FinalizeDeclaratorGroup - After a sequence of declarators are parsed, this
   /// gives the actions implementation a chance to process the group as a whole.
-  virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, DeclPtrTy *Group,
+  virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec& DS,
+                                                 DeclPtrTy *Group,
                                                  unsigned NumDecls) {
     return DeclGroupPtrTy();
   }
Index: lib/Frontend/PrintParserCallbacks.cpp
===================================================================
--- lib/Frontend/PrintParserCallbacks.cpp	(revision 72557)
+++ lib/Frontend/PrintParserCallbacks.cpp	(working copy)
@@ -116,7 +116,8 @@
     /// FinalizeDeclaratorGroup - After a sequence of declarators are parsed,
     /// this gives the actions implementation a chance to process the group as
     /// a whole.
-    virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, DeclPtrTy *Group,
+    virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec& DS,
+                                                   DeclPtrTy *Group,
                                                    unsigned NumDecls) {
       Out << __FUNCTION__ << "\n";
       return DeclGroupPtrTy();
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp	(revision 72557)
+++ lib/Sema/SemaDecl.cpp	(working copy)
@@ -2754,10 +2754,14 @@
   }
 }
 
-Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, DeclPtrTy *Group,
+Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
+                                                   DeclPtrTy *Group,
                                                    unsigned NumDecls) {
   llvm::SmallVector<Decl*, 8> Decls;
-  
+
+  if (DS.isTypeSpecOwned())
+    Decls.push_back((Decl*)DS.getTypeRep());
+
   for (unsigned i = 0; i != NumDecls; ++i)
     if (Decl *D = Group[i].getAs<Decl>())
       Decls.push_back(D);
Index: lib/Sema/Sema.h
===================================================================
--- lib/Sema/Sema.h	(revision 72557)
+++ lib/Sema/Sema.h	(working copy)
@@ -410,7 +410,8 @@
   void AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit);
   void ActOnUninitializedDecl(DeclPtrTy dcl);
   virtual void SetDeclDeleted(DeclPtrTy dcl, SourceLocation DelLoc);
-  virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, DeclPtrTy *Group,
+  virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
+                                                 DeclPtrTy *Group,
                                                  unsigned NumDecls);
   virtual void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
                                                SourceLocation LocAfterDecls);
Index: lib/Parse/ParseDecl.cpp
===================================================================
--- lib/Parse/ParseDecl.cpp	(revision 72557)
+++ lib/Parse/ParseDecl.cpp	(working copy)
@@ -437,7 +437,8 @@
     ParseDeclarator(D);
   }
   
-  return Actions.FinalizeDeclaratorGroup(CurScope, DeclsInGroup.data(),
+  return Actions.FinalizeDeclaratorGroup(CurScope, D.getDeclSpec(),
+                                         DeclsInGroup.data(),
                                          DeclsInGroup.size());
 }
 
Index: lib/Parse/ParseDeclCXX.cpp
===================================================================
--- lib/Parse/ParseDeclCXX.cpp	(revision 72557)
+++ lib/Parse/ParseDeclCXX.cpp	(working copy)
@@ -970,7 +970,7 @@
 
   if (Tok.is(tok::semi)) {
     ConsumeToken();
-    Actions.FinalizeDeclaratorGroup(CurScope, DeclsInGroup.data(),
+    Actions.FinalizeDeclaratorGroup(CurScope, DS, DeclsInGroup.data(),
                                     DeclsInGroup.size());
     return;
   }


More information about the cfe-commits mailing list