compilerplugins/clang/compat.hxx | 21 +++++++++++++++++++++ compilerplugins/clang/faileddyncast.cxx | 1 + compilerplugins/clang/implicitboolconversion.cxx | 8 ++++++-- compilerplugins/clang/passstuffbyref.cxx | 2 +- compilerplugins/clang/privatebase.cxx | 8 ++++---- compilerplugins/clang/staticmethods.cxx | 2 ++ compilerplugins/clang/typecheck.cxx | 3 ++- compilerplugins/clang/unuseddefaultparams.cxx | 2 ++ compilerplugins/clang/unusedmethods.cxx | 5 ++++- compilerplugins/clang/vclwidgets.cxx | 8 +++++--- 10 files changed, 48 insertions(+), 12 deletions(-)
New commits: commit cae64f2a8b372b87d1e323b8b0332665eeef7d9f Author: Stephan Bergmann <[email protected]> Date: Tue Jun 28 16:25:55 2016 +0200 Adapt to Clang 3.4 (in preparation of a buildbot on CentOS 7) (cherry picked from commit 9308f353186fb39a02eddfc281fc72ac1026e0b6) Conflicts: compilerplugins/clang/refcounting.cxx compilerplugins/clang/singlevalfields.cxx compilerplugins/clang/weakobject.cxx Change-Id: Ie2859f03b31c57deb7fd0deba3285f782e33b239 Reviewed-on: https://gerrit.libreoffice.org/26777 Tested-by: Jenkins <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index e1b4d8e..2f73b7f 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -323,6 +323,27 @@ inline auto getAsTagDecl(clang::Type const& t) -> clang::TagDecl * #endif } +inline bool isStdNamespace(clang::DeclContext const & context) { +#if CLANG_VERSION >= 30500 + return context.isStdNamespace(); +#else + // cf. lib/AST/DeclBase.cpp: + if (!context.isNamespace()) { + return false; + } + const clang::NamespaceDecl *ND = clang::cast<clang::NamespaceDecl>( + &context); + if (ND->isInline()) { + return isStdNamespace(*ND->getParent()); + } + if (!context.getParent()->getRedeclContext()->isTranslationUnit()) { + return false; + } + const clang::IdentifierInfo *II = ND->getIdentifier(); + return II && II->isStr("std"); +#endif +} + } #endif diff --git a/compilerplugins/clang/faileddyncast.cxx b/compilerplugins/clang/faileddyncast.cxx index 6fef227..9be28f0 100644 --- a/compilerplugins/clang/faileddyncast.cxx +++ b/compilerplugins/clang/faileddyncast.cxx @@ -9,6 +9,7 @@ #include <algorithm> +#include "clang/AST/Attr.h" #include "clang/AST/CXXInheritance.h" #include "plugin.hxx" diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx index 8c47212..e035c90 100644 --- a/compilerplugins/clang/implicitboolconversion.cxx +++ b/compilerplugins/clang/implicitboolconversion.cxx @@ -20,7 +20,9 @@ #if CLANG_VERSION < 30700 -template<> struct std::iterator_traits<ExprIterator> { +namespace std { + +template<> struct iterator_traits<ExprIterator> { typedef std::ptrdiff_t difference_type; typedef Expr * value_type; typedef Expr const ** pointer; @@ -28,7 +30,7 @@ template<> struct std::iterator_traits<ExprIterator> { typedef std::random_access_iterator_tag iterator_category; }; -template<> struct std::iterator_traits<ConstExprIterator> { +template<> struct iterator_traits<ConstExprIterator> { typedef std::ptrdiff_t difference_type; typedef Expr const * value_type; typedef Expr const ** pointer; @@ -36,6 +38,8 @@ template<> struct std::iterator_traits<ConstExprIterator> { typedef std::random_access_iterator_tag iterator_category; }; +} + #endif namespace { diff --git a/compilerplugins/clang/passstuffbyref.cxx b/compilerplugins/clang/passstuffbyref.cxx index a14d01f..059b1de 100644 --- a/compilerplugins/clang/passstuffbyref.cxx +++ b/compilerplugins/clang/passstuffbyref.cxx @@ -122,7 +122,7 @@ void PassStuffByRef::checkReturnValue(const FunctionDecl * functionDecl, const C return; } - const QualType type = functionDecl->getReturnType().getDesugaredType(compiler.getASTContext()); + const QualType type = compat::getReturnType(*functionDecl).getDesugaredType(compiler.getASTContext()); if (type->isReferenceType() || type->isIntegralOrEnumerationType() || type->isPointerType() || type->isTemplateTypeParmType() || type->isDependentType() || type->isBuiltinType() || type->isScalarType()) diff --git a/compilerplugins/clang/privatebase.cxx b/compilerplugins/clang/privatebase.cxx index 8084ee3..d2a125d 100644 --- a/compilerplugins/clang/privatebase.cxx +++ b/compilerplugins/clang/privatebase.cxx @@ -34,14 +34,14 @@ bool PrivateBase::VisitCXXRecordDecl(CXXRecordDecl const * decl) { { return true; } - for (auto const & i: decl->bases()) { - if (i.getAccessSpecifierAsWritten() == AS_none) { + for (auto i = decl->bases_begin(); i != decl->bases_end(); ++i) { + if (i->getAccessSpecifierAsWritten() == AS_none) { report( DiagnosticsEngine::Warning, "base class is private by default; explicitly give an access" " specifier", - i.getLocStart()) - << i.getSourceRange(); + i->getLocStart()) + << i->getSourceRange(); } } return true; diff --git a/compilerplugins/clang/staticmethods.cxx b/compilerplugins/clang/staticmethods.cxx index 43e0f73..be014fd 100644 --- a/compilerplugins/clang/staticmethods.cxx +++ b/compilerplugins/clang/staticmethods.cxx @@ -7,6 +7,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "clang/AST/Attr.h" + #include "plugin.hxx" #include "compat.hxx" diff --git a/compilerplugins/clang/typecheck.cxx b/compilerplugins/clang/typecheck.cxx index e185643..490deb8 100644 --- a/compilerplugins/clang/typecheck.cxx +++ b/compilerplugins/clang/typecheck.cxx @@ -55,7 +55,8 @@ TerminalCheck NamespaceCheck::GlobalNamespace() const { } TerminalCheck NamespaceCheck::StdNamespace() const { - return TerminalCheck(context_ != nullptr && context_->isStdNamespace()); + return TerminalCheck( + context_ != nullptr && compat::isStdNamespace(*context_)); } } diff --git a/compilerplugins/clang/unuseddefaultparams.cxx b/compilerplugins/clang/unuseddefaultparams.cxx index 6d2094e..db58824 100644 --- a/compilerplugins/clang/unuseddefaultparams.cxx +++ b/compilerplugins/clang/unuseddefaultparams.cxx @@ -12,6 +12,8 @@ #include <iostream> #include <fstream> +#include "clang/AST/Attr.h" + #include "plugin.hxx" #include "compat.hxx" diff --git a/compilerplugins/clang/unusedmethods.cxx b/compilerplugins/clang/unusedmethods.cxx index d84449f..03bcf45 100644 --- a/compilerplugins/clang/unusedmethods.cxx +++ b/compilerplugins/clang/unusedmethods.cxx @@ -12,6 +12,9 @@ #include <iostream> #include <fstream> #include <set> + +#include "clang/AST/Attr.h" + #include "plugin.hxx" #include "compat.hxx" @@ -292,7 +295,7 @@ gotfunc: } // Now do the checks necessary for the "unused return value" analysis - if (calleeFunctionDecl->getReturnType()->isVoidType()) { + if (compat::getReturnType(*calleeFunctionDecl)->isVoidType()) { return true; } if (!parent) { diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx index 212dcb5..368c962 100644 --- a/compilerplugins/clang/vclwidgets.cxx +++ b/compilerplugins/clang/vclwidgets.cxx @@ -205,9 +205,11 @@ bool VCLWidgets::VisitCXXDestructorDecl(const CXXDestructorDecl* pCXXDestructorD if (pCompoundStatement) { bool bFoundDisposeOnce = false; int nNumExtraStatements = 0; - for(auto const * x : pCompoundStatement->body()) + for (auto i = pCompoundStatement->body_begin(); + i != pCompoundStatement->body_end(); ++i) { - const CXXMemberCallExpr *pCallExpr = dyn_cast<CXXMemberCallExpr>(x); + const CXXMemberCallExpr *pCallExpr = dyn_cast<CXXMemberCallExpr>( + *i); if (pCallExpr) { if( const FunctionDecl* func = pCallExpr->getDirectCallee()) { if( func->getNumParams() == 0 && func->getIdentifier() != NULL @@ -217,7 +219,7 @@ bool VCLWidgets::VisitCXXDestructorDecl(const CXXDestructorDecl* pCXXDestructorD } } // checking for ParenExpr is a hacky way to ignore assert statements in older versions of clang (i.e. <= 3.2) - if (!pCallExpr && !dyn_cast<ParenExpr>(x)) + if (!pCallExpr && !dyn_cast<ParenExpr>(*i)) nNumExtraStatements++; } bOk = bFoundDisposeOnce && nNumExtraStatements == 0;
_______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
