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:
@@ -106,13 +106,15 @@ DiagnosticSeverity Diagnostic::severity() const
|
||||
std::vector<SourceRange> Diagnostic::ranges() const
|
||||
{
|
||||
std::vector<SourceRange> ranges;
|
||||
|
||||
const uint rangesCount = clang_getDiagnosticNumRanges(cxDiagnostic);
|
||||
|
||||
ranges.reserve(rangesCount);
|
||||
|
||||
for (uint index = 0; index < rangesCount; ++index)
|
||||
ranges.push_back(SourceRange(clang_getDiagnosticRange(cxDiagnostic, index)));
|
||||
for (uint index = 0; index < rangesCount; ++index) {
|
||||
const SourceRange sourceRange(clang_getDiagnosticRange(cxDiagnostic, index));
|
||||
|
||||
if (sourceRange.isValid())
|
||||
ranges.push_back(SourceRange(clang_getDiagnosticRange(cxDiagnostic, index)));
|
||||
}
|
||||
|
||||
return ranges;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user