diff options
Diffstat (limited to 'compilerplugins/clang/compat.hxx')
-rw-r--r-- | compilerplugins/clang/compat.hxx | 15 |
1 files changed, 15 insertions, 0 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 |