[lldb][NFC] Refactor Fix-It filter for warnings

LLDB only automatically applies Fix-Its from errors, but not from warnings.

Currently we only store Fix-Its from errors and then later apply all Fix-Its
we stored. This moves the filter to the application phase, so that we now
store *all* Fix-Its but only apply Fix-Its from errors later on.

This is NFC preparation for an upcoming patch.
This commit is contained in:
Raphael Isemann 2020-03-30 11:52:20 +02:00
parent 3b20970de8
commit 11a5caee2a
1 changed files with 8 additions and 8 deletions

View File

@ -214,16 +214,12 @@ public:
auto new_diagnostic = std::make_unique<ClangDiagnostic>( auto new_diagnostic = std::make_unique<ClangDiagnostic>(
stripped_output, severity, Info.getID()); stripped_output, severity, Info.getID());
// Don't store away warning fixits, since the compiler doesn't have
// enough context in an expression for the warning to be useful.
// FIXME: Should we try to filter out FixIts that apply to our generated // FIXME: Should we try to filter out FixIts that apply to our generated
// code, and not the user's expression? // code, and not the user's expression?
if (severity == eDiagnosticSeverityError) { for (const clang::FixItHint &fixit : Info.getFixItHints()) {
for (const clang::FixItHint &fixit : Info.getFixItHints()) { if (fixit.isNull())
if (fixit.isNull()) continue;
continue; new_diagnostic->AddFixitHint(fixit);
new_diagnostic->AddFixitHint(fixit);
}
} }
m_manager->AddDiagnostic(std::move(new_diagnostic)); m_manager->AddDiagnostic(std::move(new_diagnostic));
@ -1127,6 +1123,10 @@ bool ClangExpressionParser::RewriteExpression(
continue; continue;
if (!diagnostic->HasFixIts()) if (!diagnostic->HasFixIts())
continue; continue;
// Don't apply warning Fix-Its, since the compiler doesn't have enough
// context in an expression for the warning to be useful.
if (diagnostic->GetSeverity() != eDiagnosticSeverityError)
continue;
for (const FixItHint &fixit : diagnostic->FixIts()) for (const FixItHint &fixit : diagnostic->FixIts())
ApplyFixIt(fixit, commit); ApplyFixIt(fixit, commit);
} }