[cfe-commits] r142232 - in /cfe/trunk: include/clang/AST/ASTConsumer.h lib/AST/ASTConsumer.cpp lib/Sema/SemaDeclObjC.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon Oct 17 12:48:13 PDT 2011


Author: akirtzidis
Date: Mon Oct 17 14:48:13 2011
New Revision: 142232

URL: http://llvm.org/viewvc/llvm-project?rev=142232&view=rev
Log:
Introduce ASTConsumer::HandleTopLevelDeclInObjCContainer which accepts
top-level declarations that occurred inside an ObjC container.

This is useful to keep track of such decls otherwise when e.g. a function
is declared inside an objc interface, it is not passed to HandleTopLevelDecl
and it is not inside the DeclContext of the interface that is returned.

Modified:
    cfe/trunk/include/clang/AST/ASTConsumer.h
    cfe/trunk/lib/AST/ASTConsumer.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/include/clang/AST/ASTConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTConsumer.h?rev=142232&r1=142231&r2=142232&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTConsumer.h (original)
+++ cfe/trunk/include/clang/AST/ASTConsumer.h Mon Oct 17 14:48:13 2011
@@ -65,6 +65,11 @@
   /// can be defined in declspecs).
   virtual void HandleTagDeclDefinition(TagDecl *D) {}
 
+  /// \brief Handle the specified top-level declaration that occurred inside
+  /// and ObjC container.
+  /// The default implementation ignored them.
+  virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D);
+
   /// CompleteTentativeDefinition - Callback invoked at the end of a translation
   /// unit to notify the consumer that the given tentative definition should be
   /// completed.

Modified: cfe/trunk/lib/AST/ASTConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTConsumer.cpp?rev=142232&r1=142231&r2=142232&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTConsumer.cpp (original)
+++ cfe/trunk/lib/AST/ASTConsumer.cpp Mon Oct 17 14:48:13 2011
@@ -20,3 +20,5 @@
 void ASTConsumer::HandleInterestingDecl(DeclGroupRef D) {
   HandleTopLevelDecl(D);
 }
+
+void ASTConsumer::HandleTopLevelDeclInObjCContainer(DeclGroupRef D) {}

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=142232&r1=142231&r2=142232&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Mon Oct 17 14:48:13 2011
@@ -2302,6 +2302,11 @@
     }
   }
   ActOnObjCContainerFinishDefinition();
+
+  for (unsigned i = 0; i != tuvNum; i++) {
+    DeclGroupRef DG = allTUVars[i].getAsVal<DeclGroupRef>();
+    Consumer.HandleTopLevelDeclInObjCContainer(DG);
+  }
 }
 
 





More information about the cfe-commits mailing list