Commit 2384b2ba authored by Thomas Schöps's avatar Thomas Schöps
Browse files

clang: Workaround for empty problem ranges at start of document

Sometimes, for some reason we seem to get problem ranges from libclang that
start and end on the first character of the document. As a result, the final
range computed for the ClangProblem will wrongly start from the beginning of the
document and extend until the actual location of the problem. This commit
introduces a workaround which discards the problematic problem ranges.
parent 2dfc85fc
Pipeline #9336 passed with stage
in 49 minutes and 52 seconds
......@@ -139,7 +139,9 @@ ClangProblem::ClangProblem(CXDiagnostic diagnostic, CXTranslationUnit unit)
const uint numRanges = clang_getDiagnosticNumRanges(diagnostic);
for (uint i = 0; i < numRanges; ++i) {
auto range = ClangRange(clang_getDiagnosticRange(diagnostic, i)).toRange();
if(!range.isValid()){
// Note that the second condition is a workaround for seemingly wrong ranges that
// were observed sometimes. In principle, such a range should be valid.
if(!range.isValid() || (range.isEmpty() && range.start().line() == 0 && range.start().column() == 0)){
continue;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment