[libclang] Record ranges skipped by the preprocessor and expose them with libclang.
Patch by Erik Verbruggen!
llvm-svn: 196487
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index 58eb0de..4079430 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -3183,6 +3183,7 @@
CXSourceLocation startLoc, endLoc;
CXFile file = 0;
CXCursor *cursors = 0;
+ CXSkippedRanges *skipped_ranges = 0;
unsigned i;
input += strlen("-test-annotate-tokens=");
@@ -3271,6 +3272,19 @@
goto teardown;
}
+ skipped_ranges = clang_getSkippedRanges(TU, file);
+ for (i = 0; i != skipped_ranges->count; ++i) {
+ unsigned start_line, start_column, end_line, end_column;
+ clang_getSpellingLocation(clang_getRangeStart(skipped_ranges->ranges[i]),
+ 0, &start_line, &start_column, 0);
+ clang_getSpellingLocation(clang_getRangeEnd(skipped_ranges->ranges[i]),
+ 0, &end_line, &end_column, 0);
+ printf("Skipping: ");
+ PrintExtent(stdout, start_line, start_column, end_line, end_column);
+ printf("\n");
+ }
+ clang_disposeSkippedRanges(skipped_ranges);
+
for (i = 0; i != num_tokens; ++i) {
const char *kind = "<unknown>";
CXString spelling = clang_getTokenSpelling(TU, tokens[i]);