[PATCH] D114254: [libtooling][clang-tidy] Fix crashing on rendering invalid SourceRanges

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 19 08:59:15 PST 2021


steakhal created this revision.
steakhal added reviewers: aaron.ballman, njames93, klimek, alexfh.
Herald added subscribers: carlosgalvezp, martong, xazax.hun.
steakhal requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Invalid SourceRanges can occur generally if the code does not compile,
thus we expect clang error diagnostics.
Unlike `clang`, `clang-tidy` did not swallow invalid source ranges, but
tried to highlight them, and blow various assertions.

The following two examples produce invalid source ranges, but this is
not a complete list:

  void test(x); // error: unknown type name 'x'
  struct Foo {
    member; // error: C++ requires a type specifier for all declarations
  };

Thanks @Whisperity helping me fix this.


https://reviews.llvm.org/D114254

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/export-diagnostics.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114254.388522.patch
Type: text/x-patch
Size: 5961 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211119/dde735a0/attachment.bin>


More information about the cfe-commits mailing list