diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-11-17 05:31:58 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-11-17 05:31:58 +0000 |
commit | 4c4d643b6ef543a6a2afeb99fb8aae807ae68446 (patch) | |
tree | 1d8f5a1013706de64d77b44a8b83290940a495ca /clang/tools/c-index-test/c-index-test.c | |
parent | 92d829269929135133c41240a14acf555c167653 (diff) | |
download | bcm5719-llvm-4c4d643b6ef543a6a2afeb99fb8aae807ae68446.tar.gz bcm5719-llvm-4c4d643b6ef543a6a2afeb99fb8aae807ae68446.zip |
Have clang_getCursorSource() return NULL when the source location is invalid or refers to a built-in buffer. Implements <rdar://problem/7296243>.
llvm-svn: 89044
Diffstat (limited to 'clang/tools/c-index-test/c-index-test.c')
-rw-r--r-- | clang/tools/c-index-test/c-index-test.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index 36deb2e6d94..3b0e4c8e9c3 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/tools/c-index-test/c-index-test.c @@ -40,11 +40,18 @@ static void PrintCursor(CXCursor Cursor) { } } +static const char* GetCursorSource(CXCursor Cursor) { + const char *source = clang_getCursorSource(Cursor); + if (!source) + return "<invalid loc>"; + return basename(source); +} + static void DeclVisitor(CXDecl Dcl, CXCursor Cursor, CXClientData Filter) { if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) { CXString string; - printf("// CHECK: %s:%d:%d: ", basename(clang_getCursorSource(Cursor)), + printf("// CHECK: %s:%d:%d: ", GetCursorSource(Cursor), clang_getCursorLine(Cursor), clang_getCursorColumn(Cursor)); PrintCursor(Cursor); @@ -58,7 +65,7 @@ static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor, { if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) { CXString string; - printf("// CHECK: %s:%d:%d: ", basename(clang_getCursorSource(Cursor)), + printf("// CHECK: %s:%d:%d: ", GetCursorSource(Cursor), clang_getCursorLine(Cursor), clang_getCursorColumn(Cursor)); PrintCursor(Cursor); @@ -94,8 +101,8 @@ static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor, /* Nothing found here; that's fine. */ } else if (Ref.kind != CXCursor_FunctionDecl) { CXString string; - printf("// CHECK: %s:%d:%d: ", basename(clang_getCursorSource(Ref)), - curLine, curColumn); + printf("// CHECK: %s:%d:%d: ", GetCursorSource(Ref), + curLine, curColumn); PrintCursor(Ref); string = clang_getDeclSpelling(Ref.decl); printf(" [Context:%s]\n", clang_getCString(string)); |