aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Martins <smartins@kde.org>2019-05-19 13:40:05 +0100
committerSergio Martins <smartins@kde.org>2019-05-19 13:43:29 +0100
commit3e684e046eefff815d62eebd85d087a25944c22f (patch)
tree3c865e8137668ac1ce79a823efc833bd56db1d47
parentea204e3e5e5a1b57db61720a6c2369448b951ec8 (diff)
Fix build with llvm trunk
CCBUG: 407623
-rw-r--r--src/FixItExporter.cpp5
-rw-r--r--src/SourceCompatibilityHelpers.h10
2 files changed, 13 insertions, 2 deletions
diff --git a/src/FixItExporter.cpp b/src/FixItExporter.cpp
index d27dfd2d..c8d6b505 100644
--- a/src/FixItExporter.cpp
+++ b/src/FixItExporter.cpp
@@ -20,6 +20,7 @@
*/
#include "FixItExporter.h"
+#include "SourceCompatibilityHelpers.h"
#include <clang/Frontend/FrontendDiagnostic.h>
#include <clang/Tooling/DiagnosticsYaml.h>
@@ -138,8 +139,8 @@ void FixItExporter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const D
<< Hint.CodeToInsert << "\n";
llvm::errs() << "R: " << replacement.toString() << "\n";
#endif
- auto &Replacements = ToolingDiag.Fix[replacement.getFilePath()];
- auto error = Replacements.add(ConvertFixIt(Hint));
+ clang::tooling::Replacements &Replacements = clazy::DiagnosticFix(ToolingDiag, replacement.getFilePath());
+ llvm::Error error = Replacements.add(ConvertFixIt(Hint));
if (error) {
Diag(Info.getLocation(), diag::note_fixit_failed);
}
diff --git a/src/SourceCompatibilityHelpers.h b/src/SourceCompatibilityHelpers.h
index e120cafe..3397e328 100644
--- a/src/SourceCompatibilityHelpers.h
+++ b/src/SourceCompatibilityHelpers.h
@@ -28,6 +28,8 @@
#include <clang/AST/Decl.h>
#include <clang/Basic/SourceLocation.h>
#include <clang/Basic/SourceManager.h>
+#include <clang/Frontend/FrontendDiagnostic.h>
+#include <clang/Tooling/Core/Diagnostic.h>
namespace clazy {
@@ -81,6 +83,14 @@ inline bool hasUnusedResultAttr(clang::FunctionDecl *func)
}
+inline clang::tooling::Replacements& DiagnosticFix(clang::tooling::Diagnostic &diag, llvm::StringRef filePath)
+{
+#if LLVM_VERSION_MAJOR >= 9
+ return diag.Message.Fix[filePath];
+#else
+ return diag.Fix[filePath];
+#endif
+}
}