[PATCH] D68885: Add a Ranges field to Diagnostic struct

Joe Turner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 11 13:24:29 PDT 2019


compositeprimes created this revision.
compositeprimes added reviewers: clang, clang-tools-extra.
compositeprimes added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.

Part 1 of the change:
The goal is instead of dropping all the ranges associated with a Diagnostic when converting them to a ClangTidy error, instead attach them to the ClangTidyError, so they can be consumed by other APIs.

I could move this to the ClangTidyError class itself, but I thought it could be useful here, as Diagnostic could use a concept of ranges not associated with a FixIt


Repository:
  rC Clang

https://reviews.llvm.org/D68885

Files:
  include/clang/Tooling/Core/Diagnostic.h


Index: include/clang/Tooling/Core/Diagnostic.h
===================================================================
--- include/clang/Tooling/Core/Diagnostic.h
+++ include/clang/Tooling/Core/Diagnostic.h
@@ -84,6 +84,13 @@
   ///
   /// Note: it is empty in unittest.
   std::string BuildDirectory;
+
+
+  /// Extra source ranges associated with the diagnostic. By default, the
+  /// diagnostic is only associated with the source location specified in the
+  /// `Message` field, but if `Ranges` is nonempty, they will be preferred
+  /// representation of the source code associated with the diagnostic.
+  ArrayRef<CharSourceRange> Ranges;
 };
 
 /// Collection of Diagnostics generated from a single translation unit.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68885.224665.patch
Type: text/x-patch
Size: 721 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191011/0f1e5a98/attachment.bin>


More information about the cfe-commits mailing list