[cfe-commits] r121451 - /cfe/trunk/tools/libclang/CIndex.cpp
Douglas Gregor
dgregor at apple.com
Thu Dec 9 17:45:00 PST 2010
Author: dgregor
Date: Thu Dec 9 19:45:00 2010
New Revision: 121451
URL: http://llvm.org/viewvc/llvm-project?rev=121451&view=rev
Log:
Extend libclang debugging output for clang_getCursor() to show the definition we found
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=121451&r1=121450&r2=121451&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Dec 9 19:45:00 2010
@@ -3130,6 +3130,24 @@
clang_disposeString(ResultFileName);
clang_disposeString(KindSpelling);
clang_disposeString(USR);
+
+ CXCursor Definition = clang_getCursorDefinition(Result);
+ if (!clang_equalCursors(Definition, clang_getNullCursor())) {
+ CXSourceLocation DefinitionLoc = clang_getCursorLocation(Definition);
+ CXString DefinitionKindSpelling
+ = clang_getCursorKindSpelling(Definition.kind);
+ CXFile DefinitionFile;
+ unsigned DefinitionLine, DefinitionColumn;
+ clang_getInstantiationLocation(DefinitionLoc, &DefinitionFile,
+ &DefinitionLine, &DefinitionColumn, 0);
+ CXString DefinitionFileName = clang_getFileName(DefinitionFile);
+ fprintf(stderr, " -> %s(%s:%d:%d)\n",
+ clang_getCString(DefinitionKindSpelling),
+ clang_getCString(DefinitionFileName),
+ DefinitionLine, DefinitionColumn);
+ clang_disposeString(DefinitionFileName);
+ clang_disposeString(DefinitionKindSpelling);
+ }
}
return Result;
More information about the cfe-commits
mailing list