Make CIndex and c-index-test a little bit more robust. The only
substantive change is that clang_getCursorSource() now returns the
file in which a macro was instantiated when the cursor points into a
macro instantiation, rather than crashing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84275 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index bfc8e62..7376495 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -63,7 +63,9 @@
Ref = clang_getCursor(Unit, clang_getCursorSource(Cursor),
curLine, curColumn);
- if (Ref.kind != CXCursor_FunctionDecl) {
+ if (Ref.kind == CXCursor_NoDeclFound) {
+ // Nothing found here; that's fine.
+ } else if (Ref.kind != CXCursor_FunctionDecl) {
printf("// CHECK: %s:%d:%d: ", basename(clang_getCursorSource(Ref)),
curLine, curColumn);
PrintCursor(Ref);