HomePhabricator

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

Authored by steakhal on Nov 29 2021, 12:56 AM.

Description

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

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.

Reviewed-By: xazax.hun

Differential Revision: https://reviews.llvm.org/D114254