diff --git a/README.md b/README.md index 1e32005147d3b89b64ba06e1168f9d4ef172aef9..39fe759836c696bc1b86dcc1f08da755430187da 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ C++17, C++14, or C++11" in its current form (due to the #pragma GCC diagnostic i that it does not understand). If you want to use Clang with the LibreOffice compiler plugins, the minimal -version of Clang is 3.8. Since Xcode doesn't provide the compiler plugin +version of Clang is 5.0.2. Since Xcode doesn't provide the compiler plugin headers, you have to compile your own Clang to use them on macOS. You can find the TDF configure switches in the distro-configs/ directory. diff --git a/compilerplugins/clang/casttovoid.cxx b/compilerplugins/clang/casttovoid.cxx index 3812618a7283d1b4d025139813154df4f70a7d8e..e6da5b6d7445f4e791480ebd9842155ca68e0f62 100644 --- a/compilerplugins/clang/casttovoid.cxx +++ b/compilerplugins/clang/casttovoid.cxx @@ -105,7 +105,6 @@ public: return ret; } -#if CLANG_VERSION >= 50000 bool TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl * decl) { returnTypes_.push(decl->getReturnType()); auto const ret = RecursiveASTVisitor::TraverseCXXDeductionGuideDecl( @@ -115,7 +114,6 @@ public: returnTypes_.pop(); return ret; } -#endif bool TraverseCXXMethodDecl(CXXMethodDecl * decl) { returnTypes_.push(decl->getReturnType()); @@ -489,7 +487,7 @@ private: } auto const loc = compat::getBeginLoc(dre); if (compiler.getSourceManager().isMacroArgExpansion(loc) - && (compat::getImmediateMacroNameForDiagnostics( + && (Lexer::getImmediateMacroNameForDiagnostics( loc, compiler.getSourceManager(), compiler.getLangOpts()) == "assert")) { diff --git a/compilerplugins/clang/checkconfigmacros.cxx b/compilerplugins/clang/checkconfigmacros.cxx index 7e0a722ef2bb4c4cdc03019329abbf9c0e0e2728..cff2d41dd6dff025936a78681bdc64b1737ac3c2 100644 --- a/compilerplugins/clang/checkconfigmacros.cxx +++ b/compilerplugins/clang/checkconfigmacros.cxx @@ -37,11 +37,7 @@ class CheckConfigMacros explicit CheckConfigMacros( const InstantiationData& data ); virtual void run() override; virtual void MacroDefined( const Token& macroToken, const MacroDirective* info ) override; - virtual void MacroUndefined( const Token& macroToken, MacroDefinition const & -#if CLANG_VERSION >= 50000 - , MacroDirective const * -#endif - ) override; + virtual void MacroUndefined( const Token& macroToken, MacroDefinition const &, MacroDirective const * ) override; virtual void Ifdef( SourceLocation location, const Token& macroToken, MacroDefinition const & ) override; virtual void Ifndef( SourceLocation location, const Token& macroToken, MacroDefinition const & ) override; virtual void Defined( const Token& macroToken, MacroDefinition const &, SourceRange Range ) override; @@ -75,11 +71,7 @@ void CheckConfigMacros::MacroDefined( const Token& macroToken, const MacroDirect } } -void CheckConfigMacros::MacroUndefined( const Token& macroToken, MacroDefinition const & -#if CLANG_VERSION >= 50000 - , MacroDirective const * -#endif - ) +void CheckConfigMacros::MacroUndefined( const Token& macroToken, MacroDefinition const &, MacroDirective const * ) { configMacros.erase( macroToken.getIdentifierInfo()->getName()); } diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index f2a8e2f10fe0f97a2f4b4cb86ffc855e995f1839..4733cd332e5e71ccdb3889443709997c34e352e4 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -27,30 +27,6 @@ // Compatibility wrapper to abstract over (trivial) changes in the Clang API: namespace compat { -inline llvm::StringRef take_front(llvm::StringRef ref, std::size_t N = 1) { -#if CLANG_VERSION >= 40000 - return ref.take_front(N); -#else - auto const size = ref.size(); - return N >= size ? ref : ref.drop_back(size - N); -#endif -} - - -#if CLANG_VERSION >= 30900 -inline clang::ArrayRef parameters( - clang::FunctionDecl const & decl) -{ - return decl.parameters(); -} -#else -inline clang::FunctionDecl::param_const_range parameters( - clang::FunctionDecl const & decl) -{ - return decl.params(); -} -#endif - inline clang::SourceLocation getBeginLoc(clang::Decl const * decl) { #if CLANG_VERSION >= 80000 return decl->getBeginLoc(); @@ -141,58 +117,6 @@ inline bool isPointWithin( #endif } -inline bool isMacroArgExpansion( - clang::CompilerInstance& compiler, clang::SourceLocation location, - clang::SourceLocation * startLocation) -{ -#if CLANG_VERSION >= 30900 - return compiler.getSourceManager().isMacroArgExpansion( - location, startLocation); -#else - bool b = compiler.getSourceManager().isMacroArgExpansion(location); - if (b) { - *startLocation = compiler.getSourceManager() - .getSLocEntry(compiler.getSourceManager().getFileID(location)) - .getExpansion().getExpansionLocStart(); - } - return b; -#endif -} - -inline llvm::StringRef getImmediateMacroNameForDiagnostics( - clang::SourceLocation Loc, clang::SourceManager const & SM, - clang::LangOptions const &LangOpts) -{ -#if CLANG_VERSION >= 30900 - return clang::Lexer::getImmediateMacroNameForDiagnostics(Loc, SM, LangOpts); -#else - using namespace clang; - // Verbatim copy from Clang's lib/Lex/Lexer.cpp: - - assert(Loc.isMacroID() && "Only reasonable to call this on macros"); - // Walk past macro argument expansion. - while (SM.isMacroArgExpansion(Loc)) - Loc = SM.getImmediateExpansionRange(Loc).first; - - // If the macro's spelling has no FileID, then it's actually a token paste - // or stringization (or similar) and not a macro at all. - if (!SM.getFileEntryForID(SM.getFileID(SM.getSpellingLoc(Loc)))) - return StringRef(); - - // Find the spelling location of the start of the non-argument expansion - // range. This is where the macro name was spelled in order to begin - // expanding this macro. - Loc = SM.getSpellingLoc(SM.getImmediateExpansionRange(Loc).first); - - // Dig out the buffer where the macro name was spelled and the extents of - // the name so that we can render it into the expansion note. - std::pair ExpansionInfo = SM.getDecomposedLoc(Loc); - unsigned MacroTokenLength = Lexer::MeasureTokenLength(Loc, SM, LangOpts); - StringRef ExpansionBuffer = SM.getBufferData(ExpansionInfo.first); - return ExpansionBuffer.substr(ExpansionInfo.second, MacroTokenLength); -#endif -} - inline clang::Expr const * IgnoreImplicit(clang::Expr const * expr) { #if CLANG_VERSION >= 80000 return expr->IgnoreImplicit(); diff --git a/compilerplugins/clang/constantparam.cxx b/compilerplugins/clang/constantparam.cxx index 208fc19ca0f7c6a5e193f28264414ec3ead49760..34455ee00400c93cd7ed97f422b2afaa847e3768 100644 --- a/compilerplugins/clang/constantparam.cxx +++ b/compilerplugins/clang/constantparam.cxx @@ -135,7 +135,7 @@ void ConstantParam::addToCallSet(const FunctionDecl* functionDecl, int paramInde } aInfo.nameAndParams += functionDecl->getNameAsString() + "("; bool bFirst = true; - for (const ParmVarDecl *pParmVarDecl : compat::parameters(*functionDecl)) { + for (const ParmVarDecl *pParmVarDecl : functionDecl->parameters()) { if (bFirst) bFirst = false; else diff --git a/compilerplugins/clang/constfields.cxx b/compilerplugins/clang/constfields.cxx index 6613c836b8923181be845eccae86415f66c4a803..ce73e0d8e51fcbfc6faf06b2b4229599c55733b6 100644 --- a/compilerplugins/clang/constfields.cxx +++ b/compilerplugins/clang/constfields.cxx @@ -393,10 +393,7 @@ void ConstFields::check(const FieldDecl* fieldDecl, const Expr* memberExpr) break; } else if (isa(parent) || isa(parent) || isa(parent) - || isa(parent) -#if CLANG_VERSION >= 40000 - || isa(parent) -#endif + || isa(parent) || isa(parent) || isa(parent)) { walkUp(); diff --git a/compilerplugins/clang/constparams.cxx b/compilerplugins/clang/constparams.cxx index ee8ede3c1e2c59df670dd2fcf7ed031dc950e951..cccc454fa1afaf7add220f3bc695d3b1868efe12 100644 --- a/compilerplugins/clang/constparams.cxx +++ b/compilerplugins/clang/constparams.cxx @@ -216,7 +216,7 @@ bool ConstParams::CheckTraverseFunctionDecl(FunctionDecl * functionDecl) // calculate the ones we want to check bool foundInterestingParam = false; - for (const ParmVarDecl *pParmVarDecl : compat::parameters(*functionDecl)) { + for (const ParmVarDecl *pParmVarDecl : functionDecl->parameters()) { // ignore unused params if (pParmVarDecl->getName().empty() || pParmVarDecl->hasAttr()) diff --git a/compilerplugins/clang/countusersofdefaultparams.cxx b/compilerplugins/clang/countusersofdefaultparams.cxx index 12057dec926440567b080827c36d8632ac3a4917..0f434689a6c2bc6ddfff3b8edd5aa4956e41f13f 100644 --- a/compilerplugins/clang/countusersofdefaultparams.cxx +++ b/compilerplugins/clang/countusersofdefaultparams.cxx @@ -114,7 +114,7 @@ void CountUsersOfDefaultParams::niceName(const FunctionDecl* functionDecl, MyFun } aInfo.nameAndParams += functionDecl->getNameAsString() + "("; bool bFirst = true; - for (const ParmVarDecl *pParmVarDecl : compat::parameters(*functionDecl)) { + for (const ParmVarDecl *pParmVarDecl : functionDecl->parameters()) { if (bFirst) bFirst = false; else diff --git a/compilerplugins/clang/dynexcspec.cxx b/compilerplugins/clang/dynexcspec.cxx index c596547ea1957f2543873de304ebb65c5ad5804d..e5e15cb139fc62b47c4ed3af2c7ef6c72c531c05 100644 --- a/compilerplugins/clang/dynexcspec.cxx +++ b/compilerplugins/clang/dynexcspec.cxx @@ -90,10 +90,7 @@ public: } } bool dtorOrDealloc = isDtorOrDealloc(decl); - SourceRange source; -#if CLANG_VERSION >= 40000 - source = decl->getExceptionSpecSourceRange(); -#endif + auto const source = decl->getExceptionSpecSourceRange(); if (rewriter != nullptr && source.isValid()) { if (dtorOrDealloc) { if (replaceText(source, "noexcept(false)")) { diff --git a/compilerplugins/clang/expandablemethods.cxx b/compilerplugins/clang/expandablemethods.cxx index 4da75cfd0f022ccdfa241d2dbc4c95fd591f34a1..8277ae838028497ec9e302eb39672c22dca2d6ed 100644 --- a/compilerplugins/clang/expandablemethods.cxx +++ b/compilerplugins/clang/expandablemethods.cxx @@ -140,7 +140,7 @@ MyFuncInfo ExpandableMethods::niceName(const FunctionDecl* functionDecl) } aInfo.nameAndParams += functionDecl->getNameAsString() + "("; bool bFirst = true; - for (const ParmVarDecl *pParmVarDecl : compat::parameters(*functionDecl)) { + for (const ParmVarDecl *pParmVarDecl : functionDecl->parameters()) { if (bFirst) bFirst = false; else @@ -187,7 +187,7 @@ bool ExpandableMethods::VisitFunctionDecl( const FunctionDecl* functionDecl ) // any function that uses a parameter more than once if (!bLargeFunction) { StringRef bodyText(s1, s2-s1); - for (const ParmVarDecl* param : compat::parameters(*functionDecl)) { + for (const ParmVarDecl* param : functionDecl->parameters()) { StringRef name = param->getName(); if (name.empty()) continue; diff --git a/compilerplugins/clang/external.cxx b/compilerplugins/clang/external.cxx index f0abf52fd52c0030989ae47b0c27a6a7473a7ca7..8e66cf2ee5df37a512b195245d15bff108accf67 100644 --- a/compilerplugins/clang/external.cxx +++ b/compilerplugins/clang/external.cxx @@ -251,13 +251,7 @@ private: { return true; } - if (decl->getLinkageInternal() < -#if CLANG_VERSION >= 50000 - ModuleLinkage -#else - ExternalLinkage -#endif - ) + if (decl->getLinkageInternal() < ModuleLinkage) { return true; } diff --git a/compilerplugins/clang/externvar.cxx b/compilerplugins/clang/externvar.cxx index cc2c8fc7f4b0087b902198956a8d5e9b8f271d10..93a08092bd08233237f9720da9c1d4729662077c 100644 --- a/compilerplugins/clang/externvar.cxx +++ b/compilerplugins/clang/externvar.cxx @@ -8,7 +8,6 @@ */ #include "check.hxx" -#include "compat.hxx" #include "plugin.hxx" // Find variable declarations at namespace scope that need not have external @@ -78,7 +77,7 @@ public: return true; } SourceLocation argLoc; - if (compat::isMacroArgExpansion(compiler, def->getLocation(), &argLoc) + if (compiler.getSourceManager().isMacroArgExpansion(def->getLocation(), &argLoc) && (Lexer::getImmediateMacroName( argLoc, compiler.getSourceManager(), compiler.getLangOpts()) == "DEFINE_GUID")) diff --git a/compilerplugins/clang/includeform.cxx b/compilerplugins/clang/includeform.cxx index 0add9ffc47ba2e7cafae00e40a4815b533382fb0..9d6587506a850d07e5023db98c074b3d49ebe510 100644 --- a/compilerplugins/clang/includeform.cxx +++ b/compilerplugins/clang/includeform.cxx @@ -11,7 +11,6 @@ #include "config_clang.h" -#include "compat.hxx" #include "plugin.hxx" // Enforces the "Rules for #include directives (C/C++)" described in README.md. @@ -74,7 +73,7 @@ private: pos = pos2; } #endif - auto dir2 = std::string(compat::take_front(file, pos)); + auto dir2 = std::string(file.take_front(pos)); loplugin::normalizeDotDotInFilePath(dir2); shouldUseAngles = !loplugin::isSamePathname(dir1, dir2); } diff --git a/compilerplugins/clang/methodcycles.cxx b/compilerplugins/clang/methodcycles.cxx index 20a31171c001975d4f8a42539d701c7890f301cd..fb1a88b80a94e379163aba539c37ede7b5ee217a 100644 --- a/compilerplugins/clang/methodcycles.cxx +++ b/compilerplugins/clang/methodcycles.cxx @@ -18,7 +18,6 @@ #include "clang/AST/Attr.h" #include "plugin.hxx" -#include "compat.hxx" /** What we are looking for here are methods that are not reachable from any of the program @@ -110,9 +109,8 @@ public: bool TraverseCXXConstructorDecl(CXXConstructorDecl*); bool TraverseCXXConversionDecl(CXXConversionDecl*); bool TraverseCXXDestructorDecl(CXXDestructorDecl*); -#if CLANG_VERSION >= 50000 bool TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl*); -#endif + private: void logCallToRootMethods(const FunctionDecl* functionDeclFrom, const FunctionDecl* functionDeclTo); @@ -154,7 +152,7 @@ MyFuncInfo MethodCycles::niceName(const FunctionDecl* functionDecl) aInfo.nameAndParams = functionDecl->getQualifiedNameAsString() + "("; } bool bFirst = true; - for (const ParmVarDecl* pParmVarDecl : compat::parameters(*functionDecl)) + for (const ParmVarDecl* pParmVarDecl : functionDecl->parameters()) { if (bFirst) bFirst = false; @@ -349,7 +347,6 @@ bool MethodCycles::TraverseCXXConversionDecl(CXXConversionDecl* f) currentFunctionDecl = copy; return ret; } -#if CLANG_VERSION >= 50000 bool MethodCycles::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* f) { auto copy = currentFunctionDecl; @@ -358,7 +355,6 @@ bool MethodCycles::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* f) currentFunctionDecl = copy; return ret; } -#endif bool MethodCycles::TraverseCXXConstructorDecl(CXXConstructorDecl* f) { auto copy = currentFunctionDecl; diff --git a/compilerplugins/clang/oslendian.cxx b/compilerplugins/clang/oslendian.cxx index 75b1dcfdde9f70f844d9dd2b2b2f20d5e3ebb179..3cb1adbe3da0ac14861c425dea174e6f495fe8f2 100644 --- a/compilerplugins/clang/oslendian.cxx +++ b/compilerplugins/clang/oslendian.cxx @@ -59,11 +59,7 @@ private: } void MacroUndefined( - Token const & MacroNameTok, MacroDefinition const & -#if CLANG_VERSION >= 50000 - , MacroDirective const * -#endif - ) override + Token const & MacroNameTok, MacroDefinition const &, MacroDirective const *) override { auto id = MacroNameTok.getIdentifierInfo()->getName(); if (id == "OSL_BIGENDIAN" || id == "OSL_LITENDIAN") { diff --git a/compilerplugins/clang/overrideparam.cxx b/compilerplugins/clang/overrideparam.cxx index 39400566152bf5c87dfac072c2ddefe6ecb17f42..63620fe206c3fda1c90d97f8087cbc46b1c48cc3 100644 --- a/compilerplugins/clang/overrideparam.cxx +++ b/compilerplugins/clang/overrideparam.cxx @@ -11,7 +11,6 @@ #include #include "plugin.hxx" -#include "compat.hxx" #include "check.hxx" /* @@ -76,7 +75,7 @@ bool OverrideParam::VisitCXXMethodDecl(const CXXMethodDecl * methodDecl) { continue; } int i = 0; - for (const ParmVarDecl *superParmVarDecl : compat::parameters(*superMethodDecl)) { + for (const ParmVarDecl *superParmVarDecl : superMethodDecl->parameters()) { const ParmVarDecl *parmVarDecl = methodDecl->getParamDecl(i); if (parmVarDecl->hasDefaultArg() && !superParmVarDecl->hasDefaultArg()) { report( diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index 84975c99107aef1b140b06a86b4ff24089ef644f..ff12ebb2d6ba80b5e1628ebbdf9315be61a71dcb 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -351,7 +351,6 @@ Plugin::IdenticalDefaultArgumentsResult Plugin::checkIdenticalDefaultArguments( ? IdenticalDefaultArgumentsResult::Yes : IdenticalDefaultArgumentsResult::No; } -#if CLANG_VERSION >= 30900 APFloat f1(0.0f), f2(0.0f); if (argument1->EvaluateAsFloat(f1, compiler.getASTContext()) && argument2->EvaluateAsFloat(f2, compiler.getASTContext())) @@ -360,7 +359,6 @@ Plugin::IdenticalDefaultArgumentsResult Plugin::checkIdenticalDefaultArguments( ? IdenticalDefaultArgumentsResult::Yes : IdenticalDefaultArgumentsResult::No; } -#endif auto const desugared1 = argument1->IgnoreParenImpCasts(); auto const desugared2 = argument2->IgnoreParenImpCasts(); if (auto const lit1 = dyn_cast(desugared1)) { diff --git a/compilerplugins/clang/redundantinline.cxx b/compilerplugins/clang/redundantinline.cxx index 1c3ea454a9556574fec77372b01bca6e0227b3f8..5fab44825afa0c248d895e7ea6e173a62ddd7b2b 100644 --- a/compilerplugins/clang/redundantinline.cxx +++ b/compilerplugins/clang/redundantinline.cxx @@ -137,14 +137,7 @@ private: } bool handleNonExternalLinkage(FunctionDecl const * decl) { - if (decl->getLinkageInternal() >= -#if CLANG_VERSION >= 50000 - ModuleLinkage -#else - ExternalLinkage -#endif - ) - { + if (decl->getLinkageInternal() >= ModuleLinkage) { return false; } if (!compiler.getSourceManager().isInMainFile(decl->getLocation())) { diff --git a/compilerplugins/clang/salbool.cxx b/compilerplugins/clang/salbool.cxx index 9b664e626f0d961e462975115c959717cb8d26a4..ad71435470f05376b8bfcf8ac24c47a62c053650 100644 --- a/compilerplugins/clang/salbool.cxx +++ b/compilerplugins/clang/salbool.cxx @@ -333,8 +333,8 @@ bool SalBool::VisitCStyleCastExpr(CStyleCastExpr * expr) { .getImmediateMacroCallerLoc(loc); if (!isSharedCAndCppCode(callLoc)) { SourceLocation argLoc; - if (compat::isMacroArgExpansion( - compiler, compat::getBeginLoc(expr), &argLoc) + if (compiler.getSourceManager().isMacroArgExpansion( + compat::getBeginLoc(expr), &argLoc) //TODO: check it's the complete (first) arg to the macro && (Lexer::getImmediateMacroName( argLoc, compiler.getSourceManager(), diff --git a/compilerplugins/clang/singlevalfields.cxx b/compilerplugins/clang/singlevalfields.cxx index 7e8195bdacb4f3635286c9b24d2aef6629aba92c..e14fd7c84b3b78d37b75ac78d226f2110378391e 100644 --- a/compilerplugins/clang/singlevalfields.cxx +++ b/compilerplugins/clang/singlevalfields.cxx @@ -321,13 +321,11 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr ) { break; } -#if CLANG_VERSION >= 40000 else if ( isa(parent) ) { bPotentiallyAssignedTo = true; break; } -#endif else { bPotentiallyAssignedTo = true; bDump = true; @@ -451,7 +449,6 @@ std::string SingleValFields::getExprValue(const Expr* arg) return dyn_cast(constructExpr->getArg(0))->getString(); } } -#if CLANG_VERSION >= 50000 if (arg->getType()->isFloatingType()) { APFloat x1(0.0f); @@ -463,7 +460,6 @@ std::string SingleValFields::getExprValue(const Expr* arg) return os.str(); } } -#endif APSInt x1; if (arg->EvaluateAsInt(x1, compiler.getASTContext())) return x1.toString(10); diff --git a/compilerplugins/clang/staticconstfield.cxx b/compilerplugins/clang/staticconstfield.cxx index eadbd26bef789e3af5865e5756b97a007c3ae250..6925c18ec301d3ae0066deb463723df7fe41369c 100644 --- a/compilerplugins/clang/staticconstfield.cxx +++ b/compilerplugins/clang/staticconstfield.cxx @@ -109,7 +109,6 @@ bool StaticConstField::TraverseConstructorInitializer(CXXCtorInitializer* init) } } } -#if CLANG_VERSION >= 50000 else if (type->isFloatingType()) { APFloat x1(0.0f); @@ -122,7 +121,6 @@ bool StaticConstField::TraverseConstructorInitializer(CXXCtorInitializer* init) found = true; } } -#endif // ignore this, it seems to trigger an infinite recursion else if (isa(initexpr)) ; diff --git a/compilerplugins/clang/test/staticconstfield.cxx b/compilerplugins/clang/test/staticconstfield.cxx index ab0a24fa734a9df4eb89ccf6a263a86dcf92aa7d..d0d6939a36198ba2ce1b327e8d2226833c3bb20f 100644 --- a/compilerplugins/clang/test/staticconstfield.cxx +++ b/compilerplugins/clang/test/staticconstfield.cxx @@ -47,7 +47,6 @@ class Class4 } }; -#if CLANG_VERSION >= 50000 // Expr::EvaluateAsFloat class Class5 { enum class Enum @@ -77,7 +76,6 @@ class Class5 (void)m_fielda4; } }; -#endif // no warning expected class Class6 diff --git a/compilerplugins/clang/test/staticvar.cxx b/compilerplugins/clang/test/staticvar.cxx index 9963e99db68775ae469fc52861a2daa3340b809d..639e6cce46d34e8b4432f982c963c32136a4bf57 100644 --- a/compilerplugins/clang/test/staticvar.cxx +++ b/compilerplugins/clang/test/staticvar.cxx @@ -33,7 +33,6 @@ struct S2 OUString x; }; -#if CLANG_VERSION >= 50000 // probably something to do with how OUString initialisers work S2 const& f2() { static S2 const s1[]{ @@ -42,7 +41,6 @@ S2 const& f2() }; return s1[0]; } -#endif // no warning expected S2 const& f3() diff --git a/compilerplugins/clang/test/unnecessaryoverride.cxx b/compilerplugins/clang/test/unnecessaryoverride.cxx index a4db41aa5a99ffffdca63373570ad04128fa9bfb..89b772e04698947ae5ed6224e2f3549b71b21ebe 100644 --- a/compilerplugins/clang/test/unnecessaryoverride.cxx +++ b/compilerplugins/clang/test/unnecessaryoverride.cxx @@ -69,7 +69,6 @@ struct DerivedDifferent : Base struct DerivedSame : Base { -#if CLANG_VERSION >= 30900 // cf. corresponding condition in Plugin::checkIdenticalDefaultArguments void defaults( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}} void* x1 = 0, int x2 = (1 - 1), double x3 = 1.0, Base const& x4 = (Base()), @@ -78,7 +77,6 @@ struct DerivedSame : Base { Base::defaults(x1, x2, x3, x4, x5); } -#endif }; struct DerivedSlightlyDifferent : Base diff --git a/compilerplugins/clang/test/useuniqueptr.cxx b/compilerplugins/clang/test/useuniqueptr.cxx index 4cf6c96521ab58a670e7e114cebb8fb5f0bd5e92..5f20c734958c2ffb31e98f1bc6595d45607cb885 100644 --- a/compilerplugins/clang/test/useuniqueptr.cxx +++ b/compilerplugins/clang/test/useuniqueptr.cxx @@ -219,7 +219,6 @@ class Foo17 { }; // this only starts to work somewhere after clang 3.8 and before clang7 -#if CLANG_VERSION >= 30900 class Foo18 { std::vector m_pbar1; // expected-note {{member is here [loplugin:useuniqueptr]}} ~Foo18() @@ -228,7 +227,6 @@ class Foo18 { delete *aIter; // expected-error {{rather manage with std::some_container> [loplugin:useuniqueptr]}} } }; -#endif void foo19() { diff --git a/compilerplugins/clang/unnecessaryvirtual.cxx b/compilerplugins/clang/unnecessaryvirtual.cxx index afc324cee1567d4682531e3b73430846150d26c0..df3dda68adbce0cbc513a1f3b9be02272d6d08d4 100644 --- a/compilerplugins/clang/unnecessaryvirtual.cxx +++ b/compilerplugins/clang/unnecessaryvirtual.cxx @@ -13,7 +13,6 @@ #include #include #include "plugin.hxx" -#include "compat.hxx" #include /** @@ -95,7 +94,7 @@ std::string niceName(const CXXMethodDecl* cxxMethodDecl) cxxMethodDecl = dyn_cast(cxxMethodDecl->getInstantiatedFromMemberFunction()); std::string s = cxxMethodDecl->getReturnType().getCanonicalType().getAsString() + " " + cxxMethodDecl->getQualifiedNameAsString() + "("; - for (const ParmVarDecl *pParmVarDecl : compat::parameters(*cxxMethodDecl)) { + for (const ParmVarDecl *pParmVarDecl : cxxMethodDecl->parameters()) { s += pParmVarDecl->getType().getCanonicalType().getAsString(); s += ","; } diff --git a/compilerplugins/clang/unusedfields.cxx b/compilerplugins/clang/unusedfields.cxx index 1e63ac19a3ddad4c90c481405b87e389d8fbd547..61dcedf434bb05bb8a0fbffbe6283ba527e636a7 100644 --- a/compilerplugins/clang/unusedfields.cxx +++ b/compilerplugins/clang/unusedfields.cxx @@ -524,10 +524,7 @@ void UnusedFields::checkIfReadFrom(const FieldDecl* fieldDecl, const Expr* membe break; } else if (isa(parent) || isa(parent) || isa(parent) || isa(parent) -#if CLANG_VERSION >= 40000 - || isa(parent) -#endif - || isa(parent)) + || isa(parent) || isa(parent)) { walkupUp(); } @@ -731,10 +728,7 @@ void UnusedFields::checkIfWrittenTo(const FieldDecl* fieldDecl, const Expr* memb break; } else if (isa(parent) || isa(parent) || isa(parent) || isa(parent) -#if CLANG_VERSION >= 40000 - || isa(parent) -#endif - || isa(parent)) + || isa(parent) || isa(parent)) { walkupUp(); } diff --git a/compilerplugins/clang/unusedmethods.cxx b/compilerplugins/clang/unusedmethods.cxx index 5f998712d3ef6384b55bb582ffe8f1656e0393ad..8ca645335c43eed6967347ac3977da0993455576 100644 --- a/compilerplugins/clang/unusedmethods.cxx +++ b/compilerplugins/clang/unusedmethods.cxx @@ -18,7 +18,6 @@ #include "clang/AST/Attr.h" #include "plugin.hxx" -#include "compat.hxx" /** This plugin performs 3 different analyses: @@ -118,9 +117,8 @@ public: bool TraverseFunctionDecl( FunctionDecl* ); bool TraverseCXXMethodDecl( CXXMethodDecl* ); bool TraverseCXXConversionDecl( CXXConversionDecl* ); -#if CLANG_VERSION >= 50000 bool TraverseCXXDeductionGuideDecl( CXXDeductionGuideDecl* ); -#endif + private: void logCallToRootMethods(const FunctionDecl* functionDecl, std::set& funcSet); MyFuncInfo niceName(const FunctionDecl* functionDecl); @@ -167,7 +165,7 @@ MyFuncInfo UnusedMethods::niceName(const FunctionDecl* functionDecl) aInfo.nameAndParams = functionDecl->getQualifiedNameAsString() + "("; } bool bFirst = true; - for (const ParmVarDecl *pParmVarDecl : compat::parameters(*functionDecl)) { + for (const ParmVarDecl *pParmVarDecl : functionDecl->parameters()) { if (bFirst) bFirst = false; else @@ -400,7 +398,6 @@ bool UnusedMethods::TraverseCXXConversionDecl(CXXConversionDecl* f) currentFunctionDecl = copy; return ret; } -#if CLANG_VERSION >= 50000 bool UnusedMethods::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* f) { auto copy = currentFunctionDecl; @@ -409,7 +406,6 @@ bool UnusedMethods::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* f) currentFunctionDecl = copy; return ret; } -#endif loplugin::Plugin::Registration< UnusedMethods > X("unusedmethods", false); diff --git a/compilerplugins/clang/unusedmethodsremove.cxx b/compilerplugins/clang/unusedmethodsremove.cxx index 5fdeefa13a7fc2ed3bcd7ad63b7def7a364e7902..1a4adc0a5c6bb0233d2b320e81bfbbdae58549d0 100644 --- a/compilerplugins/clang/unusedmethodsremove.cxx +++ b/compilerplugins/clang/unusedmethodsremove.cxx @@ -81,7 +81,7 @@ std::string niceName(const CXXMethodDecl* functionDecl) + "::" + functionDecl->getNameAsString() + "("; bool bFirst = true; - for (const ParmVarDecl *pParmVarDecl : compat::parameters(*functionDecl)) { + for (const ParmVarDecl *pParmVarDecl : functionDecl->parameters()) { if (bFirst) bFirst = false; else diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx index 72cf39aa049a3753244cc805ba52b60282574431..3aabbccf991adac7091f47a60aa4192621acf315 100644 --- a/compilerplugins/clang/useuniqueptr.cxx +++ b/compilerplugins/clang/useuniqueptr.cxx @@ -133,9 +133,7 @@ public: bool VisitFunctionDecl(const FunctionDecl* ); bool VisitCXXDeleteExpr(const CXXDeleteExpr* ); bool TraverseFunctionDecl(FunctionDecl* ); -#if CLANG_VERSION >= 50000 bool TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* ); -#endif bool TraverseCXXMethodDecl(CXXMethodDecl* ); bool TraverseCXXConstructorDecl(CXXConstructorDecl* ); bool TraverseCXXConversionDecl(CXXConversionDecl* ); @@ -957,7 +955,6 @@ bool UseUniquePtr::TraverseCXXMethodDecl(CXXMethodDecl* methodDecl) return ret; } -#if CLANG_VERSION >= 50000 bool UseUniquePtr::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* methodDecl) { if (ignoreLocation(methodDecl)) @@ -970,7 +967,6 @@ bool UseUniquePtr::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* methodDe return ret; } -#endif bool UseUniquePtr::TraverseCXXConstructorDecl(CXXConstructorDecl* methodDecl) { diff --git a/compilerplugins/clang/virtualdown.cxx b/compilerplugins/clang/virtualdown.cxx index 0bc9bf491148e9c2bd89ab094e14db070761eb05..9e59c842f49fd5cac17ae5210a9555a1e9bd44f4 100644 --- a/compilerplugins/clang/virtualdown.cxx +++ b/compilerplugins/clang/virtualdown.cxx @@ -12,7 +12,6 @@ #include #include #include "plugin.hxx" -#include "compat.hxx" #include /** @@ -74,9 +73,8 @@ public: bool TraverseFunctionDecl(FunctionDecl*); bool TraverseCXXMethodDecl(CXXMethodDecl*); bool TraverseCXXConversionDecl(CXXConversionDecl*); -#if CLANG_VERSION >= 50000 bool TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl*); -#endif + private: std::string toString(SourceLocation loc); std::string niceName(const CXXMethodDecl* functionDecl); @@ -177,7 +175,6 @@ bool VirtualDown::TraverseCXXConversionDecl(CXXConversionDecl* f) currentFunctionDecl = copy; return ret; } -#if CLANG_VERSION >= 50000 bool VirtualDown::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* f) { auto copy = currentFunctionDecl; @@ -186,13 +183,12 @@ bool VirtualDown::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* f) currentFunctionDecl = copy; return ret; } -#endif std::string VirtualDown::niceName(const CXXMethodDecl* cxxMethodDecl) { std::string s = cxxMethodDecl->getReturnType().getCanonicalType().getAsString() + " " + cxxMethodDecl->getQualifiedNameAsString() + "("; - for (const ParmVarDecl* pParmVarDecl : compat::parameters(*cxxMethodDecl)) + for (const ParmVarDecl* pParmVarDecl : cxxMethodDecl->parameters()) { s += pParmVarDecl->getType().getCanonicalType().getAsString(); s += ","; diff --git a/configure.ac b/configure.ac index bc165bd6b31a6fcfbb203b2300fe4628dd3f3b0b..827b5f6c995e1456286dd9b1e19e0ce9181abd71 100644 --- a/configure.ac +++ b/configure.ac @@ -6698,9 +6698,9 @@ if test "$COM_IS_CLANG" = "TRUE"; then else compiler_plugins=no fi - if test "$compiler_plugins" != no -a "$CLANGVER" -lt 30800; then + if test "$compiler_plugins" != no -a "$CLANGVER" -lt 50002; then if test "$compiler_plugins" = yes; then - AC_MSG_ERROR([Clang $CLANGVER is too old to build compiler plugins; need >= 3.8.0.]) + AC_MSG_ERROR([Clang $CLANGVER is too old to build compiler plugins; need >= 5.0.2.]) else compiler_plugins=no fi