forked from qt-creator/qt-creator
Clang: Filter out invalid diagnostic ranges
Apparently libclang might return invalid ranges. Now we discard the invalid ranges. Since there is a diagnostic location (in addition to ranges) the editor will still display an indication for the user. Task-number: QTCREATORBUG-15272 Change-Id: I351e136b9925a53fb2273a394e17873c5533798d Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
@@ -85,9 +85,24 @@ protected:
|
||||
translationUnits};
|
||||
DiagnosticSet diagnosticSet{translationUnit.diagnostics()};
|
||||
Diagnostic diagnostic{diagnosticSet.front()};
|
||||
Diagnostic diagnosticWithFilteredOutInvalidRange{diagnosticSet.at(1)};
|
||||
::SourceRange sourceRange{diagnostic.ranges().front()};
|
||||
};
|
||||
|
||||
TEST_F(SourceRange, IsNull)
|
||||
{
|
||||
::SourceRange sourceRange;
|
||||
|
||||
ASSERT_TRUE(sourceRange.isNull());
|
||||
}
|
||||
|
||||
TEST_F(SourceRange, IsNotNull)
|
||||
{
|
||||
::SourceRange sourceRange = diagnostic.ranges()[0];
|
||||
|
||||
ASSERT_FALSE(sourceRange.isNull());
|
||||
}
|
||||
|
||||
TEST_F(SourceRange, Size)
|
||||
{
|
||||
ASSERT_THAT(diagnostic.ranges().size(), 2);
|
||||
@@ -108,4 +123,10 @@ TEST_F(SourceRange, End)
|
||||
6u,
|
||||
44u));
|
||||
}
|
||||
|
||||
TEST_F(SourceRange, InvalidRangeIsFilteredOut)
|
||||
{
|
||||
ASSERT_TRUE(diagnosticWithFilteredOutInvalidRange.ranges().empty());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user