[PATCH] Record ranges skipped by the preprocessor and expose them with libclang.

Argyrios Kyrtzidis kyrtzidis at apple.com
Wed Oct 30 16:57:34 PDT 2013

Hi Erik, sorry for the delay!

On Oct 12, 2013, at 4:25 AM, Erik Verbruggen <erikjv at me.com> wrote:

> It has been some time since the last time I did a patch...
> Record ranges skipped by the preprocessor and expose them with libclang.


> This requires the use of a detailed preprocessing record. Also bumbed the cindex minor version to reflect adding new functionality (and to be able to detect that during built-time).
> The patch is against r192531, which has the same amount of failures for me on MacOS as trunk (two, both with OpenCL).
> Feedback please! :)

Some nitpicks:

+ * \brief Retrieve all ranges that were skipped by the preprocessor.
+ */
+CINDEX_LINKAGE CXSkippedRanges *clang_getSkippedRanges(CXTranslationUnit tu);

Should we have a function to get all skipped ranges, and another to get the skipped ranges of a particular file ? IMO the latter is much more useful.

+    /// \brief Retrieve all ranges that got skipped while preprocessing.
+    const std::vector<SourceRange> &getSkippedRanges() const {
+      return SkippedRanges;
+    }

Please use ArrayRef here.

Also we would need to serialize the skipped ranges to the preprocessing record of a PCH as well but this can be done later.

+// RUN: env CINDEXTEST_SHOW_SKIPPED_RANGES=1 c-index-test -test-annotate-tokens=%s:1:1:16:1 %s | FileCheck %s
+// CHECK: Skipping: [5:2 - 6:7]
+// CHECK: Skipping: [8:2 - 12:7]
+// CHECK: Skipping: [14:2 - 20:7]

Should we just unconditionally (I mean without the CINDEXTEST_SHOW_SKIPPED_RANGES env variable) show the skipped ranges for the '-test-annotate-tokens' option (and update any test if it breaks) ?
Also the test is not also testing if tokens are properly annotated/not-annotated, could you add some CHECK/CHECK-NOT lines for some of the tokens ?

More information about the cfe-commits mailing list