[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
This commit is contained in:
Argyrios Kyrtzidis 2013-01-08 18:23:28 +00:00
parent c4c1fb39d8
commit bf1be59dae
1 changed files with 12 additions and 0 deletions

View File

@ -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;
}