summaryrefslogtreecommitdiffstats
path: root/clang/tools/libclang
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-12-10 01:45:00 +0000
committerDouglas Gregor <dgregor@apple.com>2010-12-10 01:45:00 +0000
commit4a5bd5fec4b4b7110e7dd03dca319c877908bb8a (patch)
treefaa2cdf84ae9e818478944fa36687e96d000d459 /clang/tools/libclang
parentc92136ffb6ef85b8ac024ce499c6c5706807ff7b (diff)
downloadbcm5719-llvm-4a5bd5fec4b4b7110e7dd03dca319c877908bb8a.tar.gz
bcm5719-llvm-4a5bd5fec4b4b7110e7dd03dca319c877908bb8a.zip
Extend libclang debugging output for clang_getCursor() to show the definition we found
llvm-svn: 121451
Diffstat (limited to 'clang/tools/libclang')
-rw-r--r--clang/tools/libclang/CIndex.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index d85e801d387..a74a7a9895f 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -3130,6 +3130,24 @@ CXCursor clang_getCursor(CXTranslationUnit TU, CXSourceLocation Loc) {
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;
OpenPOWER on IntegriCloud