summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReader.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-23 20:27:36 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-23 20:27:36 +0000
commit8ad3bab5057fedbe4cec33e27684d28b22fc97e2 (patch)
treefb6d2d4e0928385ccf579d7990cee9e6623d4536 /clang/lib/Serialization/ASTReader.cpp
parente4d082827de840d5e829b48a175f3daf8078993d (diff)
downloadbcm5719-llvm-8ad3bab5057fedbe4cec33e27684d28b22fc97e2.tar.gz
bcm5719-llvm-8ad3bab5057fedbe4cec33e27684d28b22fc97e2.zip
[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. llvm-svn: 145109
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r--clang/lib/Serialization/ASTReader.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index de90c7b929f..2569e225b55 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -4293,6 +4293,14 @@ void ASTReader::FindFileRegionDecls(FileID File,
if (BeginIt != DInfo.Decls.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 != DInfo.Decls.begin() &&
+ GetDecl(getGlobalDeclID(*DInfo.Mod, *BeginIt))
+ ->isTopLevelDeclInObjCContainer())
+ --BeginIt;
+
ArrayRef<serialization::LocalDeclID>::iterator
EndIt = std::upper_bound(DInfo.Decls.begin(), DInfo.Decls.end(),
EndLoc, DIDComp);
OpenPOWER on IntegriCloud