diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-17 19:48:13 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-17 19:48:13 +0000 |
commit | b4a686df4de21ec4eeca69211b21f7fe716abeae (patch) | |
tree | d75c935d95140cdb38c4a9e551584c6feb9d2124 | |
parent | 6d4740e740f9c109c76c111cc90a63f6a24f6357 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142232 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/ASTConsumer.h | 5 | ||||
-rw-r--r-- | lib/AST/ASTConsumer.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 5 |
3 files changed, 12 insertions, 0 deletions
diff --git a/include/clang/AST/ASTConsumer.h b/include/clang/AST/ASTConsumer.h index fcc91768da..300e4f26d3 100644 --- a/include/clang/AST/ASTConsumer.h +++ b/include/clang/AST/ASTConsumer.h @@ -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. diff --git a/lib/AST/ASTConsumer.cpp b/lib/AST/ASTConsumer.cpp index 04a084a06a..062f1103e9 100644 --- a/lib/AST/ASTConsumer.cpp +++ b/lib/AST/ASTConsumer.cpp @@ -20,3 +20,5 @@ void ASTConsumer::HandleTopLevelDecl(DeclGroupRef D) {} void ASTConsumer::HandleInterestingDecl(DeclGroupRef D) { HandleTopLevelDecl(D); } + +void ASTConsumer::HandleTopLevelDeclInObjCContainer(DeclGroupRef D) {} diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 1de17d2131..669ea8f32a 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -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); + } } |