summaryrefslogtreecommitdiffstats
path: root/clang/tools/libclang/CIndex.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-06-27 19:42:20 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-06-27 19:42:20 +0000
commit66cd1dacbc4c2b58e356295261fb571db79706b1 (patch)
tree3ad6151ab65704416b87e5c505486c34b75de2e2 /clang/tools/libclang/CIndex.cpp
parentc8b39c7952d86738dd0bb84d59a8c3a14fde9b12 (diff)
downloadbcm5719-llvm-66cd1dacbc4c2b58e356295261fb571db79706b1.tar.gz
bcm5719-llvm-66cd1dacbc4c2b58e356295261fb571db79706b1.zip
[libclang] Avoid having the cursor of an expression "overwrite" the annotation of the
variable declaration that it belongs to. This can happen for C++ constructor expressions whose range generally include the variable declaration, e.g.: MyCXXClass foo; // Make sure we don't annotate 'foo' as a CallExpr cursor. rdar://9124499. llvm-svn: 133929
Diffstat (limited to 'clang/tools/libclang/CIndex.cpp')
-rw-r--r--clang/tools/libclang/CIndex.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index f9cd40820d7..3acf8908a0f 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -4627,6 +4627,24 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) {
break;
}
+ // Avoid having the cursor of an expression "overwrite" the annotation of the
+ // variable declaration that it belongs to.
+ // This can happen for C++ constructor expressions whose range generally
+ // include the variable declaration, e.g.:
+ // MyCXXClass foo; // Make sure we don't annotate 'foo' as a CallExpr cursor.
+ if (clang_isExpression(cursorK)) {
+ Expr *E = getCursorExpr(cursor);
+ if (Decl *D = getCursorDecl(cursor)) {
+ const unsigned I = NextToken();
+ if (E->getLocStart().isValid() && D->getLocation().isValid() &&
+ E->getLocStart() == D->getLocation() &&
+ E->getLocStart() == GetTokenLoc(I)) {
+ Cursors[I] = updateC;
+ AdvanceToken();
+ }
+ }
+ }
+
// Visit children to get their cursor information.
const unsigned BeforeChildren = NextToken();
VisitChildren(cursor);
OpenPOWER on IntegriCloud