]> granicus.if.org Git - clang/commitdiff
Introduce ASTConsumer::HandleTopLevelDeclInObjCContainer which accepts
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 17 Oct 2011 19:48:13 +0000 (19:48 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 17 Oct 2011 19:48:13 +0000 (19:48 +0000)
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.

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

include/clang/AST/ASTConsumer.h
lib/AST/ASTConsumer.cpp
lib/Sema/SemaDeclObjC.cpp

index fcc91768dac3ca498c6282eef0f2ceed9a2ad383..300e4f26d3323f2d82e71fe036068405fba42906 100644 (file)
@@ -65,6 +65,11 @@ public:
   /// 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.
index 04a084a06a44029eb9d0057581b2be84c4714e98..062f1103e91f3a9a52367866732986b600152e15 100644 (file)
@@ -20,3 +20,5 @@ void ASTConsumer::HandleTopLevelDecl(DeclGroupRef D) {}
 void ASTConsumer::HandleInterestingDecl(DeclGroupRef D) {
   HandleTopLevelDecl(D);
 }
+
+void ASTConsumer::HandleTopLevelDeclInObjCContainer(DeclGroupRef D) {}
index 1de17d2131816ac4c70c4bb6070689aa3e5132f7..669ea8f32a93cae604b979390c0bda8748e0a01e 100644 (file)
@@ -2302,6 +2302,11 @@ void Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd,
     }
   }
   ActOnObjCContainerFinishDefinition();
+
+  for (unsigned i = 0; i != tuvNum; i++) {
+    DeclGroupRef DG = allTUVars[i].getAsVal<DeclGroupRef>();
+    Consumer.HandleTopLevelDeclInObjCContainer(DG);
+  }
 }