aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSergio Martins <smartins@kde.org>2019-09-01 15:39:52 +0100
committerSergio Martins <smartins@kde.org>2019-09-01 15:39:52 +0100
commitafc877b17297aedf9621bd61d850f60b34aece8f (patch)
treeeb519822ead51d09cce66900954bc5f0282d535e /src
parentf3da2721a9a7e8aa7feaf77025f4f4bc41676798 (diff)
Fix exporting built-in warnings to yaml
The message didn't have the [checkName] tags BUG: 411440
Diffstat (limited to 'src')
-rw-r--r--src/FixItExporter.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/FixItExporter.cpp b/src/FixItExporter.cpp
index d3a55806..958f7a7e 100644
--- a/src/FixItExporter.cpp
+++ b/src/FixItExporter.cpp
@@ -89,16 +89,27 @@ tooling::Diagnostic FixItExporter::ConvertDiagnostic(const Diagnostic &Info)
Info.FormatDiagnostic(TmpMessageText);
// TODO: This returns an empty string: DiagEngine->getDiagnosticIDs()->getWarningOptionForDiag(Info.getID());
// HACK: capture it at the end of the message: Message text [check-name]
- const auto MessageText = TmpMessageText.slice(0, TmpMessageText.find_last_of('[') - 1).str();
- const auto CheckName = TmpMessageText.slice(TmpMessageText.find_last_of('[') + 3,
- TmpMessageText.find_last_of(']')).str();
+
+ std::string checkName = DiagEngine.getDiagnosticIDs()->getWarningOptionForDiag(Info.getID());
+ std::string messageText;
+
+ if (checkName.empty()) {
+ messageText = TmpMessageText.slice(0, TmpMessageText.find_last_of('[') - 1).str();
+
+ checkName = TmpMessageText.slice(TmpMessageText.find_last_of('[') + 3,
+ TmpMessageText.find_last_of(']')).str();
+ } else {
+ messageText = TmpMessageText.c_str();
+ }
+
+
llvm::StringRef CurrentBuildDir; // Not needed?
- tooling::Diagnostic ToolingDiag(CheckName,
+ tooling::Diagnostic ToolingDiag(checkName,
tooling::Diagnostic::Warning,
CurrentBuildDir);
// FIXME: Sometimes the file path is an empty string.
- ToolingDiag.Message = tooling::DiagnosticMessage(MessageText, SourceMgr, Info.getLocation());
+ ToolingDiag.Message = tooling::DiagnosticMessage(messageText, SourceMgr, Info.getLocation());
return ToolingDiag;
}