forked from qt-creator/qt-creator
ClangCodeModel: Try harder to catch bogus AST ranges
String literals that are adjacent after preprocessing are reported as a single AST node, leading to potentially wrong highlighting. We can catch this condition at least for the case where there are semantic tokens in between the string components. Fixes: QTCREATORBUG-27601 Change-Id: If023d06db74bd6cfefa670649f0e733ceaaede2d Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -482,6 +482,15 @@ void ExtraHighlightingResultsCollector::insertResult(const HighlightingResult &r
|
||||
return;
|
||||
}
|
||||
|
||||
// Bogus ranges; e.g. QTCREATORBUG-27601
|
||||
if (it != m_results.end()) {
|
||||
const int nextStartPos = Utils::Text::positionInText(m_doc, it->line, it->column);
|
||||
const int resultEndPos = Utils::Text::positionInText(m_doc, result.line, result.column)
|
||||
+ result.length;
|
||||
if (resultEndPos > nextStartPos)
|
||||
return;
|
||||
}
|
||||
|
||||
qCDebug(clangdLogHighlight) << "adding additional highlighting result"
|
||||
<< result.line << result.column << result.length;
|
||||
m_results.insert(it, result);
|
||||
|
Reference in New Issue
Block a user