[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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171878 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 97fabab..8b29bb4 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -3862,6 +3862,18 @@
}
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;
}