From c14a03dffff69b5e1c55cc118fc52d8fd9f3a28d Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Wed, 23 Nov 2011 20:27:36 +0000 Subject: [libclang] Fix operations (token annotation, getting cursor, etc.) with a file region inside an objc container that "contains" other file-level declarations. When getting the array of file-level declarations that overlap with a file region, we failed to report that the region overlaps with an objc container, if the container had other file-level declarations declared lexically inside it. Fix this by marking such declarations as "isTopLevelDeclInObjCContainer" in the AST and handling them appropriately. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145109 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/ASTUnit.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/Frontend/ASTUnit.cpp') diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 6cd0784215..a04a4403ea 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -2546,6 +2546,13 @@ void ASTUnit::findFileRegionDecls(FileID File, unsigned Offset, unsigned Length, if (BeginIt != LocDecls.begin()) --BeginIt; + // If we are pointing at a top-level decl inside an objc container, we need + // to backtrack until we find it otherwise we will fail to report that the + // region overlaps with an objc container. + while (BeginIt != LocDecls.begin() && + BeginIt->second->isTopLevelDeclInObjCContainer()) + --BeginIt; + LocDeclsTy::iterator EndIt = std::upper_bound(LocDecls.begin(), LocDecls.end(), std::make_pair(Offset+Length, (Decl*)0), -- cgit v1.2.3-18-g5258