aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-01-08 18:23:28 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-01-08 18:23:28 +0000
commitbf1be59dae9ddd5184ce8bf6fe0b9d25e428dd79 (patch)
treee07ac2d628a653be7aa947277823992fd81d71a6
parentc4c1fb39d8bd4ecd559f2dd3ed1293672cb350f9 (diff)
downloadllvm-bf1be59dae9ddd5184ce8bf6fe0b9d25e428dd79.zip
llvm-bf1be59dae9ddd5184ce8bf6fe0b9d25e428dd79.tar.gz
llvm-bf1be59dae9ddd5184ce8bf6fe0b9d25e428dd79.tar.bz2
[libclang] In clang_equalCursors, clear out the "FirstInDeclGroup" part in a declaration cursor
before doing the comparison. This is because we can't set "FirstInDeclGroup" consistently; for example, when visiting a DeclStmt we will set it but we don't set it on the result of clang_getCursorDefinition for a reference of the same declaration. llvm-svn: 171878
-rw-r--r--clang/tools/libclang/CIndex.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 97fabab..8b29bb4 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -3862,6 +3862,18 @@ CXCursor clang_getNullCursor(void) {
}
unsigned clang_equalCursors(CXCursor X, CXCursor Y) {
+ // Clear out the "FirstInDeclGroup" part in a declaration cursor, since we
+ // can't set consistently. For example, when visiting a DeclStmt we will set
+ // it but we don't set it on the result of clang_getCursorDefinition for
+ // a reference of the same declaration.
+ // FIXME: Setting "FirstInDeclGroup" in CXCursors is a hack that only works
+ // when visiting a DeclStmt currently, the AST should be enhanced to be able
+ // to provide that kind of info.
+ if (clang_isDeclaration(X.kind))
+ X.data[1] = 0;
+ if (clang_isDeclaration(Y.kind))
+ Y.data[1] = 0;
+
return X == Y;
}