Page MenuHomePhabricator

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

Authored by steakhal on Fri, Nov 19, 8:59 AM.



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.

Diff Detail

Event Timeline

steakhal created this revision.Fri, Nov 19, 8:59 AM
steakhal requested review of this revision.Fri, Nov 19, 8:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptFri, Nov 19, 8:59 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
xazax.hun accepted this revision.Fri, Nov 19, 12:19 PM
This revision is now accepted and ready to land.Fri, Nov 19, 12:19 PM
whisperity added inline comments.Mon, Nov 22, 1:49 AM

EXPECT_TRUE(Errors[0].Message.Ranges.empty());? But I'm not sure if the data structure used there supports this.

steakhal updated this revision to Diff 388850.Mon, Nov 22, 3:13 AM
steakhal marked an inline comment as done.
  • prefer empty() over size() == 0