diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-11-23 20:27:36 +0000 |
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-11-23 20:27:36 +0000 |
| commit | 8ad3bab5057fedbe4cec33e27684d28b22fc97e2 (patch) | |
| tree | fb6d2d4e0928385ccf579d7990cee9e6623d4536 /clang/lib/Frontend/ASTUnit.cpp | |
| parent | e4d082827de840d5e829b48a175f3daf8078993d (diff) | |
| download | bcm5719-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/Frontend/ASTUnit.cpp')
| -rw-r--r-- | clang/lib/Frontend/ASTUnit.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index 6cd07842157..a04a4403eaa 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/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), |

