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.

llvm-svn: 142232
This commit is contained in:
Argyrios Kyrtzidis 2011-10-17 19:48:13 +00:00
parent 690dccd9d4
commit bd8b150dfc
3 changed files with 12 additions and 0 deletions

View 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.

View File

@ -20,3 +20,5 @@ void ASTConsumer::HandleTopLevelDecl(DeclGroupRef D) {}
void ASTConsumer::HandleInterestingDecl(DeclGroupRef D) {
HandleTopLevelDecl(D);
}
void ASTConsumer::HandleTopLevelDeclInObjCContainer(DeclGroupRef D) {}

View 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);
}
}