summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compilerplugins/clang/compat.hxx15
-rw-r--r--compilerplugins/clang/pluginhandler.cxx5
2 files changed, 18 insertions, 2 deletions
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx
index 9e35049e5f75..d4d92a0ad122 100644
--- a/compilerplugins/clang/compat.hxx
+++ b/compilerplugins/clang/compat.hxx
@@ -12,6 +12,9 @@
#include "clang/AST/Decl.h"
#include "clang/AST/Type.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticIDs.h"
+#include "llvm/ADT/StringRef.h"
// Compatibility wrapper to abstract over (trivial) chanes in the Clang API:
namespace compat {
@@ -42,6 +45,18 @@ inline clang::QualType getParamType(
#endif
}
+inline unsigned getCustomDiagID(
+ clang::DiagnosticsEngine const & engine, clang::DiagnosticsEngine::Level L,
+ llvm::StringRef FormatString)
+{
+#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
+ return engine.getDiagnosticIDs()->getCustomDiagID(
+ static_cast<clang::DiagnosticIDs::Level>(L), FormatString);
+#else
+ return engine.getCustomDiagID(L, FormatString);
+#endif
+}
+
}
#endif
diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx
index 440df1cf07fb..345363b0a90f 100644
--- a/compilerplugins/clang/pluginhandler.cxx
+++ b/compilerplugins/clang/pluginhandler.cxx
@@ -9,6 +9,7 @@
*
*/
+#include "compat.hxx"
#include "pluginhandler.hxx"
#include <clang/Frontend/CompilerInstance.h>
@@ -161,9 +162,9 @@ DiagnosticBuilder PluginHandler::report( DiagnosticsEngine::Level level, const c
}
fullMessage += "]";
if( loc.isValid())
- return diag.Report( loc, diag.getCustomDiagID( level, fullMessage ));
+ return diag.Report( loc, compat::getCustomDiagID(diag, level, fullMessage) );
else
- return diag.Report( diag.getCustomDiagID( level, fullMessage ));
+ return diag.Report( compat::getCustomDiagID(diag, level, fullMessage) );
}
DiagnosticBuilder PluginHandler::report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc )