diff options
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r-- | compilerplugins/clang/checkconfigmacros.cxx | 3 | ||||
-rw-r--r-- | compilerplugins/clang/compat.hxx | 12 |
2 files changed, 14 insertions, 1 deletions
diff --git a/compilerplugins/clang/checkconfigmacros.cxx b/compilerplugins/clang/checkconfigmacros.cxx index 608800db2642..fff7967e49e8 100644 --- a/compilerplugins/clang/checkconfigmacros.cxx +++ b/compilerplugins/clang/checkconfigmacros.cxx @@ -9,6 +9,7 @@ * */ +#include "compat.hxx" #include "plugin.hxx" #include <clang/Lex/Preprocessor.h> @@ -59,7 +60,7 @@ class CheckConfigMacros CheckConfigMacros::CheckConfigMacros( const InstantiationData& data ) : Plugin( data ) { - compiler.getPreprocessor().addPPCallbacks( this ); + compat::addPPCallbacks(compiler.getPreprocessor(), this); } void CheckConfigMacros::run() diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index e6ce98ea64bd..e0e3cbbc7d92 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -23,6 +23,8 @@ #include "clang/Basic/Linkage.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/Visibility.h" +#include "clang/Lex/PPCallbacks.h" +#include "clang/Lex/Preprocessor.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/raw_ostream.h" @@ -186,6 +188,16 @@ inline clang::NamedDecl * const * end( #endif } +inline void addPPCallbacks( + clang::Preprocessor & preprocessor, clang::PPCallbacks * C) +{ +#if (__clang_major__ == 3 && __clang_minor__ >= 6) || __clang_major__ > 3 + preprocessor.addPPCallbacks(std::unique_ptr<clang::PPCallbacks>(C)); +#else + preprocessor.addPPCallbacks(C); +#endif +} + } #endif |