Introduce clang_getCursorLocation(), which supercedes
clang_getCursorLine(), clang_getCursorColumn(),
clang_getCursorSource(), and clang_getCursorSourceFile(). Mark those 4
functions as deprecated and stop using them ourselves.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93800 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 e3d6ad8..a2d4fe9 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -61,7 +61,7 @@
}
static const char* GetCursorSource(CXCursor Cursor) {
- const char *source = clang_getCursorSource(Cursor);
+ const char *source = clang_getFileName(clang_getCursorLocation(Cursor).file);
if (!source)
return "<invalid loc>";
return basename(source);
@@ -84,10 +84,11 @@
static void DeclVisitor(CXDecl Dcl, CXCursor Cursor, CXClientData Filter) {
if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) {
- printf("// %s: %s:%d:%d: ", FileCheckPrefix,
- GetCursorSource(Cursor),
- clang_getCursorLine(Cursor),
- clang_getCursorColumn(Cursor));
+ CXSourceLocation Loc = clang_getCursorLocation(Cursor);
+ const char *source = clang_getFileName(Loc.file);
+ if (!source)
+ source = "<invalid loc>";
+ printf("// %s: %s:%d:%d: ", FileCheckPrefix, source, Loc.line, Loc.column);
PrintCursor(Cursor);
PrintDeclExtent(clang_getCursorDecl(Cursor));
@@ -99,9 +100,9 @@
CXClientData Filter) {
if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) {
CXDecl D;
+ CXSourceLocation Loc = clang_getCursorLocation(Cursor);
printf("// %s: %s:%d:%d: ", FileCheckPrefix,
- GetCursorSource(Cursor), clang_getCursorLine(Cursor),
- clang_getCursorColumn(Cursor));
+ GetCursorSource(Cursor), Loc.line, Loc.column);
PrintCursor(Cursor);
D = clang_getCursorDecl(Cursor);
@@ -133,6 +134,9 @@
curColumn = startColumn;
while (startBuf < endBuf) {
+ CXSourceLocation Loc;
+ const char *source = 0;
+
if (*startBuf == '\n') {
startBuf++;
curLine++;
@@ -140,15 +144,18 @@
} else if (*startBuf != '\t')
curColumn++;
- Ref = clang_getCursor(Unit, clang_getCursorSource(Cursor),
- curLine, curColumn);
- if (Ref.kind == CXCursor_NoDeclFound) {
- /* Nothing found here; that's fine. */
- } else if (Ref.kind != CXCursor_FunctionDecl) {
- printf("// %s: %s:%d:%d: ", FileCheckPrefix, GetCursorSource(Ref),
- curLine, curColumn);
- PrintCursor(Ref);
- printf("\n");
+ Loc = clang_getCursorLocation(Cursor);
+ source = clang_getFileName(Loc.file);
+ if (source) {
+ Ref = clang_getCursor(Unit, source, curLine, curColumn);
+ if (Ref.kind == CXCursor_NoDeclFound) {
+ /* Nothing found here; that's fine. */
+ } else if (Ref.kind != CXCursor_FunctionDecl) {
+ printf("// %s: %s:%d:%d: ", FileCheckPrefix, GetCursorSource(Ref),
+ curLine, curColumn);
+ PrintCursor(Ref);
+ printf("\n");
+ }
}
startBuf++;
}