[cfe-commits] r171878 - /cfe/trunk/tools/libclang/CIndex.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Jan 8 10:23:28 PST 2013


Author: akirtzidis
Date: Tue Jan  8 12:23:28 2013
New Revision: 171878

URL: http://llvm.org/viewvc/llvm-project?rev=171878&view=rev
Log:
[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.

Modified:
    cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=171878&r1=171877&r2=171878&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jan  8 12:23:28 2013
@@ -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;
 }
 





More information about the cfe-commits mailing list