Extend libclang debugging output for clang_getCursor() to show the definition we found

llvm-svn: 121451
This commit is contained in:
Douglas Gregor 2010-12-10 01:45:00 +00:00
parent c92136ffb6
commit 4a5bd5fec4
1 changed files with 18 additions and 0 deletions

View File

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