From 0f5756e2e4065072aa7bc58f6202bd6c2405ff80 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 23 Sep 2014 13:46:24 +0200 Subject: Adapt compilerplugins to Clang trunk towards 3.6 Change-Id: If6ee343bb4d4004e7a95fe1c5adc97210fc0abd0 --- compilerplugins/clang/checkconfigmacros.cxx | 3 ++- compilerplugins/clang/compat.hxx | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'compilerplugins') 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 @@ -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(C)); +#else + preprocessor.addPPCallbacks(C); +#endif +} + } #endif -- cgit