summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-02-26 12:50:16 +0100
committerStephan Bergmann <sbergman@redhat.com>2016-02-26 14:34:29 +0100
commit01f3b95884ab652a61a621a0c9dc3e2e0b7c3e4b (patch)
tree29d0d6743a03ec87fbae7dc82fd0b13c7de79800
parentcd2725de90517cd63a17ccbf2c59c1e07eca5744 (diff)
These version checks are about the Clang the plugins are built /against/
...not the (Clang) compiler they are being built /with/. (Also simplifies the checking #if code.) Change-Id: I416321be4ef4478785be40571f81500fd3b6feb8
-rw-r--r--compilerplugins/Makefile-clang.mk2
-rw-r--r--compilerplugins/clang/checkconfigmacros.cxx28
-rw-r--r--compilerplugins/clang/compat.hxx54
-rw-r--r--compilerplugins/clang/getimplementationname.cxx3
-rw-r--r--compilerplugins/clang/implicitboolconversion.cxx4
-rw-r--r--compilerplugins/clang/nullptr.cxx2
-rw-r--r--compilerplugins/clang/pluginhandler.cxx2
-rw-r--r--compilerplugins/clang/pluginhandler.hxx2
-rw-r--r--compilerplugins/clang/refcounting.cxx2
-rw-r--r--compilerplugins/clang/salbool.cxx4
-rw-r--r--compilerplugins/clang/sfxpoolitem.cxx4
-rw-r--r--compilerplugins/clang/staticmethods.cxx2
-rw-r--r--compilerplugins/clang/store/stdexception.cxx2
-rw-r--r--compilerplugins/clang/unreffun.cxx4
-rw-r--r--compilerplugins/clang/unuseddefaultparams.cxx2
-rw-r--r--compilerplugins/clang/unusedmethods.cxx2
-rw-r--r--compilerplugins/clang/unusedvariablecheck.cxx2
-rw-r--r--compilerplugins/clang/vclwidgets.cxx2
-rw-r--r--config_host/config_clang.h.in2
-rw-r--r--configure.ac1
20 files changed, 66 insertions, 60 deletions
diff --git a/compilerplugins/Makefile-clang.mk b/compilerplugins/Makefile-clang.mk
index b914d37bd2e3..1e983098f315 100644
--- a/compilerplugins/Makefile-clang.mk
+++ b/compilerplugins/Makefile-clang.mk
@@ -14,7 +14,7 @@ CLANG_COMMA :=,
CLANGCXX=$(filter-out -m32 -m64 -fsanitize=%,$(CXX))
# Compile flags ('make CLANGCXXFLAGS=-g' if you need to debug the plugin)
-CLANGCXXFLAGS=-O2 -Wall -Wextra -g
+CLANGCXXFLAGS=-O2 -Wall -Wextra -Wundef -g
# The uninteresting rest.
diff --git a/compilerplugins/clang/checkconfigmacros.cxx b/compilerplugins/clang/checkconfigmacros.cxx
index cde3a42f8dba..5baea1ecfc50 100644
--- a/compilerplugins/clang/checkconfigmacros.cxx
+++ b/compilerplugins/clang/checkconfigmacros.cxx
@@ -34,7 +34,7 @@ class CheckConfigMacros
public:
explicit CheckConfigMacros( const InstantiationData& data );
virtual void run() override;
-#if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 3
+#if CLANG_VERSION < 30300
virtual void MacroDefined( const Token& macroToken, const MacroInfo* info ) override;
virtual void MacroUndefined( const Token& macroToken, const MacroInfo* info ) override;
virtual void Ifdef( SourceLocation location, const Token& macroToken ) override;
@@ -42,7 +42,7 @@ class CheckConfigMacros
virtual void Defined( const Token& macroToken ) override;
#else
virtual void MacroDefined( const Token& macroToken, const MacroDirective* info ) override;
-#if __clang_major__ == 3 && __clang_minor__ < 7
+#if CLANG_VERSION < 30700
virtual void MacroUndefined( const Token& macroToken, const MacroDirective* info ) override;
virtual void Ifdef( SourceLocation location, const Token& macroToken, const MacroDirective* info ) override;
virtual void Ifndef( SourceLocation location, const Token& macroToken, const MacroDirective* info ) override;
@@ -51,9 +51,9 @@ class CheckConfigMacros
virtual void Ifdef( SourceLocation location, const Token& macroToken, const MacroDefinition& info ) override;
virtual void Ifndef( SourceLocation location, const Token& macroToken, const MacroDefinition& info ) override;
#endif
-#if __clang_major__ == 3 && __clang_minor__ < 4
+#if CLANG_VERSION < 30400
virtual void Defined( const Token& macroToken, const MacroDirective* info ) override;
-#elif __clang_major__ == 3 && __clang_minor__ < 7
+#elif CLANG_VERSION < 30700
virtual void Defined( const Token& macroToken, const MacroDirective* info, SourceRange Range ) override;
#else
virtual void Defined( const Token& macroToken, const MacroDefinition& info, SourceRange Range ) override;
@@ -76,7 +76,7 @@ void CheckConfigMacros::run()
// nothing, only check preprocessor usage
}
-#if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 3
+#if CLANG_VERSION < 30300
void CheckConfigMacros::MacroDefined( const Token& macroToken, const MacroInfo* info )
{
SourceLocation location = info->getDefinitionLoc();
@@ -95,9 +95,9 @@ void CheckConfigMacros::MacroDefined( const Token& macroToken, const MacroDirect
}
}
-#if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 3
+#if CLANG_VERSION < 30300
void CheckConfigMacros::MacroUndefined( const Token& macroToken, const MacroInfo* )
-#elif __clang_major__ == 3 && __clang_minor__ < 7
+#elif CLANG_VERSION < 30700
void CheckConfigMacros::MacroUndefined( const Token& macroToken, const MacroDirective* )
#else
void CheckConfigMacros::MacroUndefined( const Token& macroToken, const MacroDefinition& )
@@ -106,9 +106,9 @@ void CheckConfigMacros::MacroUndefined( const Token& macroToken, const MacroDefi
configMacros.erase( macroToken.getIdentifierInfo()->getName());
}
-#if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 3
+#if CLANG_VERSION < 30300
void CheckConfigMacros::Ifdef( SourceLocation location, const Token& macroToken )
-#elif __clang_major__ == 3 && __clang_minor__ < 7
+#elif CLANG_VERSION < 30700
void CheckConfigMacros::Ifdef( SourceLocation location, const Token& macroToken, const MacroDirective* )
#else
void CheckConfigMacros::Ifdef( SourceLocation location, const Token& macroToken, const MacroDefinition& )
@@ -117,9 +117,9 @@ void CheckConfigMacros::Ifdef( SourceLocation location, const Token& macroToken,
checkMacro( macroToken, location );
}
-#if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 3
+#if CLANG_VERSION < 30300
void CheckConfigMacros::Ifndef( SourceLocation location, const Token& macroToken )
-#elif __clang_major__ == 3 && __clang_minor__ < 7
+#elif CLANG_VERSION < 30700
void CheckConfigMacros::Ifndef( SourceLocation location, const Token& macroToken, const MacroDirective* )
#else
void CheckConfigMacros::Ifndef( SourceLocation location, const Token& macroToken, const MacroDefinition& )
@@ -128,11 +128,11 @@ void CheckConfigMacros::Ifndef( SourceLocation location, const Token& macroToken
checkMacro( macroToken, location );
}
-#if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 3
+#if CLANG_VERSION < 30300
void CheckConfigMacros::Defined( const Token& macroToken )
-#elif __clang_major__ == 3 && __clang_minor__ < 4
+#elif CLANG_VERSION < 30400
void CheckConfigMacros::Defined( const Token& macroToken, const MacroDirective* )
-#elif __clang_major__ == 3 && __clang_minor__ < 7
+#elif CLANG_VERSION < 30700
void CheckConfigMacros::Defined( const Token& macroToken, const MacroDirective* , SourceRange )
#else
void CheckConfigMacros::Defined( const Token& macroToken, const MacroDefinition& , SourceRange )
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx
index 9b352db18802..0b451c8f0ac5 100644
--- a/compilerplugins/clang/compat.hxx
+++ b/compilerplugins/clang/compat.hxx
@@ -30,7 +30,9 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/raw_ostream.h"
-#if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3
+#include "config_clang.h"
+
+#if CLANG_VERSION >= 30400
#define LO_COMPILERPLUGINS_CLANG_COMPAT_HAVE_isAtEndOfImmediateMacroExpansion \
true
#else
@@ -42,7 +44,7 @@
namespace compat {
inline bool isLookupContext(clang::DeclContext const & ctxt) {
-#if (__clang_major__ == 3 && __clang_minor__ >= 7) || __clang_major__ > 3
+#if CLANG_VERSION >= 30700
return ctxt.isLookupContext();
#else
return !ctxt.isFunctionOrMethod()
@@ -51,7 +53,7 @@ inline bool isLookupContext(clang::DeclContext const & ctxt) {
}
inline bool isExternCContext(clang::DeclContext const & ctxt) {
-#if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3
+#if CLANG_VERSION >= 30400
return ctxt.isExternCContext();
#else
for (clang::DeclContext const * c = &ctxt;
@@ -67,7 +69,7 @@ inline bool isExternCContext(clang::DeclContext const & ctxt) {
}
inline bool isInExternCContext(clang::FunctionDecl const & decl) {
-#if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3
+#if CLANG_VERSION >= 30400
return decl.isInExternCContext();
#else
return isExternCContext(*decl.getCanonicalDecl()->getDeclContext());
@@ -80,7 +82,7 @@ inline bool forallBases(
void* callbackParam,
bool AllowShortCircuit)
{
-#if (__clang_major__ == 3 && __clang_minor__ > 7) || __clang_major__ > 3
+#if CLANG_VERSION >= 30700
(void) callbackParam;
return decl.forallBases(BaseMatches, AllowShortCircuit);
#else
@@ -88,14 +90,14 @@ inline bool forallBases(
#endif
}
-#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
+#if CLANG_VERSION >= 30300
typedef clang::LinkageInfo LinkageInfo;
#else
typedef clang::NamedDecl::LinkageInfo LinkageInfo;
#endif
inline clang::Linkage getLinkage(LinkageInfo const & info) {
-#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
+#if CLANG_VERSION >= 30300
return info.getLinkage();
#else
return info.linkage();
@@ -103,7 +105,7 @@ inline clang::Linkage getLinkage(LinkageInfo const & info) {
}
inline clang::Visibility getVisibility(LinkageInfo const & info) {
-#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
+#if CLANG_VERSION >= 30300
return info.getVisibility();
#else
return info.visibility();
@@ -111,7 +113,7 @@ inline clang::Visibility getVisibility(LinkageInfo const & info) {
}
inline bool isFirstDecl(clang::FunctionDecl const & decl) {
-#if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3
+#if CLANG_VERSION >= 30400
return decl.isFirstDecl();
#else
return decl.isFirstDeclaration();
@@ -119,7 +121,7 @@ inline bool isFirstDecl(clang::FunctionDecl const & decl) {
}
inline clang::QualType getReturnType(clang::FunctionDecl const & decl) {
-#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
+#if CLANG_VERSION >= 30500
return decl.getReturnType();
#else
return decl.getResultType();
@@ -127,7 +129,7 @@ inline clang::QualType getReturnType(clang::FunctionDecl const & decl) {
}
inline clang::QualType getReturnType(clang::FunctionProtoType const & type) {
-#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
+#if CLANG_VERSION >= 30500
return type.getReturnType();
#else
return type.getResultType();
@@ -135,7 +137,7 @@ inline clang::QualType getReturnType(clang::FunctionProtoType const & type) {
}
inline unsigned getNumParams(clang::FunctionProtoType const & type) {
-#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
+#if CLANG_VERSION >= 30500
return type.getNumParams();
#else
return type.getNumArgs();
@@ -145,7 +147,7 @@ inline unsigned getNumParams(clang::FunctionProtoType const & type) {
inline clang::QualType getParamType(
clang::FunctionProtoType const & type, unsigned i)
{
-#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
+#if CLANG_VERSION >= 30500
return type.getParamType(i);
#else
return type.getArgType(i);
@@ -155,7 +157,7 @@ inline clang::QualType getParamType(
inline clang::Stmt::const_child_iterator begin(
clang::Stmt::const_child_range const & range)
{
-#if (__clang_major__ == 3 && __clang_minor__ > 7) || __clang_major__ > 3
+#if CLANG_VERSION >= 30700
return range.begin();
#else
return range.first;
@@ -165,7 +167,7 @@ inline clang::Stmt::const_child_iterator begin(
inline clang::Stmt::const_child_iterator end(
clang::Stmt::const_child_range const & range)
{
-#if (__clang_major__ == 3 && __clang_minor__ > 7) || __clang_major__ > 3
+#if CLANG_VERSION >= 30700
return range.end();
#else
return range.second;
@@ -173,7 +175,7 @@ inline clang::Stmt::const_child_iterator end(
}
inline unsigned getBuiltinCallee(clang::CallExpr const & expr) {
-#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
+#if CLANG_VERSION >= 30500
return expr.getBuiltinCallee();
#else
return expr.isBuiltinCall();
@@ -183,7 +185,7 @@ inline unsigned getBuiltinCallee(clang::CallExpr const & expr) {
inline bool isInMainFile(
clang::SourceManager const & manager, clang::SourceLocation Loc)
{
-#if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3
+#if CLANG_VERSION >= 30400
return manager.isInMainFile(Loc);
#else
return manager.isFromMainFile(Loc);
@@ -194,7 +196,7 @@ inline unsigned getCustomDiagID(
clang::DiagnosticsEngine & engine, clang::DiagnosticsEngine::Level L,
llvm::StringRef FormatString)
{
-#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
+#if CLANG_VERSION >= 30500
return engine.getDiagnosticIDs()->getCustomDiagID(
static_cast<clang::DiagnosticIDs::Level>(L), FormatString);
#else
@@ -205,13 +207,13 @@ inline unsigned getCustomDiagID(
inline std::unique_ptr<llvm::raw_fd_ostream> create_raw_fd_ostream(
char const * Filename, std::string & ErrorInfo)
{
-#if (__clang_major__ == 3 && __clang_minor__ >= 6) || __clang_major__ > 3
+#if CLANG_VERSION >= 30600
std::error_code ec;
std::unique_ptr<llvm::raw_fd_ostream> s(
new llvm::raw_fd_ostream(Filename, ec, llvm::sys::fs::F_None));
ErrorInfo = ec ? "error: " + ec.message() : std::string();
return s;
-#elif __clang_major__ == 3 && __clang_minor__ == 5
+#elif CLANG_VERSION >= 30500
return std::unique_ptr<llvm::raw_fd_ostream>(
new llvm::raw_fd_ostream(Filename, ErrorInfo, llvm::sys::fs::F_None));
#else
@@ -220,7 +222,7 @@ inline std::unique_ptr<llvm::raw_fd_ostream> create_raw_fd_ostream(
#endif
}
-#if (__clang_major__ == 3 && __clang_minor__ >= 7) || __clang_major__ > 3
+#if CLANG_VERSION >= 30700
typedef clang::DeclContext::lookup_result DeclContextLookupResult;
typedef clang::DeclContext::lookup_iterator DeclContextLookupIterator;
#else
@@ -229,7 +231,7 @@ typedef clang::DeclContext::lookup_const_iterator DeclContextLookupIterator;
#endif
inline DeclContextLookupIterator begin(DeclContextLookupResult const & result) {
-#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
+#if CLANG_VERSION >= 30300
return result.begin();
#else
return result.first;
@@ -237,7 +239,7 @@ inline DeclContextLookupIterator begin(DeclContextLookupResult const & result) {
}
inline DeclContextLookupIterator end(DeclContextLookupResult const & result) {
-#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
+#if CLANG_VERSION >= 30300
return result.end();
#else
return result.second;
@@ -247,7 +249,7 @@ inline DeclContextLookupIterator end(DeclContextLookupResult const & result) {
inline void addPPCallbacks(
clang::Preprocessor & preprocessor, clang::PPCallbacks * C)
{
-#if (__clang_major__ == 3 && __clang_minor__ >= 6) || __clang_major__ > 3
+#if CLANG_VERSION >= 30600
preprocessor.addPPCallbacks(std::unique_ptr<clang::PPCallbacks>(C));
#else
preprocessor.addPPCallbacks(C);
@@ -256,7 +258,7 @@ inline void addPPCallbacks(
inline bool isMacroBodyExpansion(clang::CompilerInstance& compiler, clang::SourceLocation location)
{
-#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
+#if CLANG_VERSION >= 30300
return compiler.getSourceManager().isMacroBodyExpansion(location);
#else
return location.isMacroID()
@@ -266,7 +268,7 @@ inline bool isMacroBodyExpansion(clang::CompilerInstance& compiler, clang::Sourc
inline auto getAsTagDecl(clang::Type const& t) -> clang::TagDecl *
{
-#if (__clang_major__ == 3 && __clang_minor__ > 5) || __clang_major__ > 3
+#if CLANG_VERSION >= 30500
// TODO not sure if it works with clang 3.6, trunk is known to work
return t.getAsTagDecl();
#else
diff --git a/compilerplugins/clang/getimplementationname.cxx b/compilerplugins/clang/getimplementationname.cxx
index 7e90b3818011..b8873961b5fc 100644
--- a/compilerplugins/clang/getimplementationname.cxx
+++ b/compilerplugins/clang/getimplementationname.cxx
@@ -12,7 +12,8 @@
#if defined(__unix__)
// only compile this on clang 3.7 or higher, which is known to work
// there were problems on clang 3.5 at least
-#if (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 7))
+#include "config_clang.h"
+#if CLANG_VERSION >= 30700
#include <cassert>
#include <stdlib.h>
#include <string>
diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx
index bd1874ec3345..8aa65434a8c5 100644
--- a/compilerplugins/clang/implicitboolconversion.cxx
+++ b/compilerplugins/clang/implicitboolconversion.cxx
@@ -18,7 +18,7 @@
#include "compat.hxx"
#include "plugin.hxx"
-#if __clang_major__ == 3 && __clang_minor__ < 7
+#if CLANG_VERSION < 30700
template<> struct std::iterator_traits<ExprIterator> {
typedef std::ptrdiff_t difference_type;
@@ -230,7 +230,7 @@ bool hasCLanguageLinkageType(FunctionDecl const * decl) {
if (decl->isExternC()) {
return true;
}
-#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
+#if CLANG_VERSION >= 30300
if (decl->isInExternCContext()) {
return true;
}
diff --git a/compilerplugins/clang/nullptr.cxx b/compilerplugins/clang/nullptr.cxx
index 6bf4e54d3f15..8c1426919c30 100644
--- a/compilerplugins/clang/nullptr.cxx
+++ b/compilerplugins/clang/nullptr.cxx
@@ -193,7 +193,7 @@ bool Nullptr::isFromCIncludeFile(SourceLocation spellingLocation) const {
}
bool Nullptr::isMacroBodyExpansion(SourceLocation location) const {
-#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
+#if CLANG_VERSION >= 30300
return compiler.getSourceManager().isMacroBodyExpansion(location);
#else
return location.isMacroID()
diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx
index 54a181e55245..32651e18a5d0 100644
--- a/compilerplugins/clang/pluginhandler.cxx
+++ b/compilerplugins/clang/pluginhandler.cxx
@@ -250,7 +250,7 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context )
}
}
-#if (__clang_major__ == 3 && __clang_minor__ >= 6) || __clang_major__ > 3
+#if CLANG_VERSION >= 30600
std::unique_ptr<ASTConsumer> LibreOfficeAction::CreateASTConsumer( CompilerInstance& Compiler, StringRef )
{
return llvm::make_unique<PluginHandler>( Compiler, _args );
diff --git a/compilerplugins/clang/pluginhandler.hxx b/compilerplugins/clang/pluginhandler.hxx
index b4fc0c36ae7a..3992a70a2402 100644
--- a/compilerplugins/clang/pluginhandler.hxx
+++ b/compilerplugins/clang/pluginhandler.hxx
@@ -54,7 +54,7 @@ class LibreOfficeAction
: public PluginASTAction
{
public:
-#if (__clang_major__ == 3 && __clang_minor__ >= 6) || __clang_major__ > 3
+#if CLANG_VERSION >= 30600
virtual std::unique_ptr<ASTConsumer> CreateASTConsumer( CompilerInstance& Compiler, StringRef InFile );
#else
virtual ASTConsumer* CreateASTConsumer( CompilerInstance& Compiler, StringRef InFile );
diff --git a/compilerplugins/clang/refcounting.cxx b/compilerplugins/clang/refcounting.cxx
index 61854e47b981..0e899f362387 100644
--- a/compilerplugins/clang/refcounting.cxx
+++ b/compilerplugins/clang/refcounting.cxx
@@ -83,7 +83,7 @@ bool isDerivedFrom(const CXXRecordDecl *decl, const char *pString) {
!decl->hasAnyDependentBases() &&
!compat::forallBases(
*decl,
-#if __clang_major__ == 3 && __clang_minor__ <= 7
+#if CLANG_VERSION < 30800
BaseCheckNotSubclass,
#else
[pString](const CXXRecordDecl *BaseDefinition) -> bool
diff --git a/compilerplugins/clang/salbool.cxx b/compilerplugins/clang/salbool.cxx
index fd7dc9358426..dfead3576e82 100644
--- a/compilerplugins/clang/salbool.cxx
+++ b/compilerplugins/clang/salbool.cxx
@@ -30,7 +30,7 @@ bool isSalBool(QualType type) {
// class body.") but mis-classifies salhelper::Timer's isTicking, isExpired, and
// expiresBefore members as defined in salhelper/source/timer.cxx as inlined:
bool isInlined(FunctionDecl const & decl) {
-#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
+#if CLANG_VERSION >= 30300
return decl.isInlined();
#else
(void)decl;
@@ -53,7 +53,7 @@ bool hasCLanguageLinkageType(FunctionDecl const * decl) {
if (decl->isExternC()) {
return true;
}
-#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
+#if CLANG_VERSION >= 30300
if (decl->isInExternCContext()) {
return true;
}
diff --git a/compilerplugins/clang/sfxpoolitem.cxx b/compilerplugins/clang/sfxpoolitem.cxx
index d6942ebd1269..f01adf578235 100644
--- a/compilerplugins/clang/sfxpoolitem.cxx
+++ b/compilerplugins/clang/sfxpoolitem.cxx
@@ -34,7 +34,7 @@ public:
bool BaseCheckNotSfxPoolItemSubclass(
const CXXRecordDecl *BaseDefinition
-#if __clang_major__ == 3 && __clang_minor__ <= 7
+#if CLANG_VERSION < 30800
, void *
#endif
)
@@ -65,7 +65,7 @@ bool isDerivedFromSfxPoolItem(const CXXRecordDecl *decl) {
bool BaseCheckNotSwMsgPoolItemSubclass(
const CXXRecordDecl *BaseDefinition
-#if __clang_major__ == 3 && __clang_minor__ <= 7
+#if CLANG_VERSION < 30800
, void *
#endif
)
diff --git a/compilerplugins/clang/staticmethods.cxx b/compilerplugins/clang/staticmethods.cxx
index bb8eac65af10..d4edb1a53758 100644
--- a/compilerplugins/clang/staticmethods.cxx
+++ b/compilerplugins/clang/staticmethods.cxx
@@ -38,7 +38,7 @@ private:
bool BaseCheckNotTestFixtureSubclass(
const CXXRecordDecl *BaseDefinition
-#if __clang_major__ == 3 && __clang_minor__ <= 7
+#if CLANG_VERSION < 30800
, void *
#endif
)
diff --git a/compilerplugins/clang/store/stdexception.cxx b/compilerplugins/clang/store/stdexception.cxx
index 3f93b27927f8..824d6450d0f7 100644
--- a/compilerplugins/clang/store/stdexception.cxx
+++ b/compilerplugins/clang/store/stdexception.cxx
@@ -185,7 +185,7 @@ found:
}
bool StdException::isInMainFile(SourceLocation spellingLocation) const {
-#if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3
+#if CLANG_VERSION >= 30400
return compiler.getSourceManager().isInMainFile(spellingLocation);
#else
return compiler.getSourceManager().isFromMainFile(spellingLocation);
diff --git a/compilerplugins/clang/unreffun.cxx b/compilerplugins/clang/unreffun.cxx
index ff746bf23ba1..36e181640d6b 100644
--- a/compilerplugins/clang/unreffun.cxx
+++ b/compilerplugins/clang/unreffun.cxx
@@ -33,7 +33,7 @@ bool hasCLanguageLinkageType(FunctionDecl const * decl) {
if (decl->isExternC()) {
return true;
}
-#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
+#if CLANG_VERSION >= 30300
if (decl->isInExternCContext()) {
return true;
}
@@ -147,7 +147,7 @@ bool UnrefFun::VisitFunctionDecl(FunctionDecl const * decl) {
report(
DiagnosticsEngine::Warning,
(canon->isDefined()
-#if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3
+#if CLANG_VERSION >= 30400
? (canon->isExternallyVisible()
? "Unreferenced externally visible function%0 definition"
: "Unreferenced externally invisible function%0 definition")
diff --git a/compilerplugins/clang/unuseddefaultparams.cxx b/compilerplugins/clang/unuseddefaultparams.cxx
index 548720fe9f08..6906a93c2271 100644
--- a/compilerplugins/clang/unuseddefaultparams.cxx
+++ b/compilerplugins/clang/unuseddefaultparams.cxx
@@ -81,7 +81,7 @@ MyFuncInfo UnusedDefaultParams::niceName(const FunctionDecl* functionDecl)
else if (functionDecl->getClassScopeSpecializationPattern())
functionDecl = functionDecl->getClassScopeSpecializationPattern();
// workaround clang-3.5 issue
-#if __clang_major__ > 3 || ( __clang_major__ == 3 && __clang_minor__ >= 6 )
+#if CLANG_VERSION >= 30600
else if (functionDecl->getTemplateInstantiationPattern())
functionDecl = functionDecl->getTemplateInstantiationPattern();
#endif
diff --git a/compilerplugins/clang/unusedmethods.cxx b/compilerplugins/clang/unusedmethods.cxx
index c2785dd771ea..e0b971882a51 100644
--- a/compilerplugins/clang/unusedmethods.cxx
+++ b/compilerplugins/clang/unusedmethods.cxx
@@ -119,7 +119,7 @@ MyFuncInfo UnusedMethods::niceName(const FunctionDecl* functionDecl)
else if (functionDecl->getClassScopeSpecializationPattern())
functionDecl = functionDecl->getClassScopeSpecializationPattern();
// workaround clang-3.5 issue
-#if __clang_major__ > 3 || ( __clang_major__ == 3 && __clang_minor__ >= 6 )
+#if CLANG_VERSION >= 30600
else if (functionDecl->getTemplateInstantiationPattern())
functionDecl = functionDecl->getTemplateInstantiationPattern();
#endif
diff --git a/compilerplugins/clang/unusedvariablecheck.cxx b/compilerplugins/clang/unusedvariablecheck.cxx
index ce35afecafdc..8642032df12a 100644
--- a/compilerplugins/clang/unusedvariablecheck.cxx
+++ b/compilerplugins/clang/unusedvariablecheck.cxx
@@ -51,7 +51,7 @@ void UnusedVariableCheck::run()
bool BaseCheckNotDialogSubclass(
const CXXRecordDecl *BaseDefinition
-#if __clang_major__ == 3 && __clang_minor__ <= 7
+#if CLANG_VERSION < 30800
, void *
#endif
)
diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx
index 89f80a57235a..b368b18fc223 100644
--- a/compilerplugins/clang/vclwidgets.cxx
+++ b/compilerplugins/clang/vclwidgets.cxx
@@ -59,7 +59,7 @@ static bool startsWith(const std::string& s, const char* other)
bool BaseCheckNotWindowSubclass(
const CXXRecordDecl *BaseDefinition
-#if __clang_major__ == 3 && __clang_minor__ <= 7
+#if CLANG_VERSION < 30800
, void *
#endif
)
diff --git a/config_host/config_clang.h.in b/config_host/config_clang.h.in
index 3bbda7a320b3..c19c0875ce86 100644
--- a/config_host/config_clang.h.in
+++ b/config_host/config_clang.h.in
@@ -11,6 +11,8 @@ Settings related to Clang compiler plugins.
#undef SRCDIR
#undef WORKDIR
+#undef CLANG_VERSION
+
/* This is actually unused, but it should change whenever Clang changes,
thus causing update of this .h file and triggering rebuild of our Clang plugin. */
#undef CLANG_FULL_VERSION
diff --git a/configure.ac b/configure.ac
index de6eaae7f1e8..18c89ab368bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3784,6 +3784,7 @@ if test "$COM_IS_CLANG" = TRUE; then
CLANG_FULL_VERSION=`echo __clang_version__ | ${CC%-cl.exe*} -E -P -`
CLANGVER=`echo $clang_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
AC_MSG_RESULT([Clang $CLANG_FULL_VERSION, $CLANGVER])
+ AC_DEFINE_UNQUOTED(CLANG_VERSION,$CLANGVER)
AC_DEFINE_UNQUOTED(CLANG_FULL_VERSION,$CLANG_FULL_VERSION)
fi
AC_SUBST(COM_IS_CLANG)