From da5a428bf3db404fe3c91b689cd87c68789d6db9 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 3 May 2010 20:16:35 +0000 Subject: Workaround: Don't add ObjCMethodDecls to the vector of TopLevelDecls since they don't go in the DeclContext for the translation unit. This is to workaround a fundamental issue in how ObjC decls (within an @implementation) are parsed before the ObjCContainerDecl is available. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102944 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/ASTUnit.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/Frontend/ASTUnit.cpp') diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 0f7dca2d6b..4730bdc2f1 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -265,8 +265,16 @@ public: TopLevelDeclTrackerConsumer(ASTUnit &_Unit) : Unit(_Unit) {} void HandleTopLevelDecl(DeclGroupRef D) { - for (DeclGroupRef::iterator it = D.begin(), ie = D.end(); it != ie; ++it) - Unit.getTopLevelDecls().push_back(*it); + for (DeclGroupRef::iterator it = D.begin(), ie = D.end(); it != ie; ++it) { + Decl *D = *it; + // FIXME: Currently ObjC method declarations are incorrectly being + // reported as top-level declarations, even though their DeclContext + // is the containing ObjC @interface/@implementation. This is a + // fundamental problem in the parser right now. + if (isa(D)) + continue; + Unit.getTopLevelDecls().push_back(D); + } } }; -- cgit v1.2.3-70-g09d2