diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-06-28 16:25:55 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-06-28 16:26:33 +0200 |
commit | 9308f353186fb39a02eddfc281fc72ac1026e0b6 (patch) | |
tree | 7c655cf5e142c811ff4dc652ec6d69c7ce133a57 /compilerplugins | |
parent | 36936d5a8c2e6fc32dcc65d860bdfdafd2fbb766 (diff) |
Adapt to Clang 3.4 (in preparation of a buildbot on CentOS 7)
Change-Id: Ie2859f03b31c57deb7fd0deba3285f782e33b239
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/compat.hxx | 21 | ||||
-rw-r--r-- | compilerplugins/clang/faileddyncast.cxx | 1 | ||||
-rw-r--r-- | compilerplugins/clang/implicitboolconversion.cxx | 8 | ||||
-rw-r--r-- | compilerplugins/clang/passstuffbyref.cxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/privatebase.cxx | 8 | ||||
-rw-r--r-- | compilerplugins/clang/refcounting.cxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/singlevalfields.cxx | 6 | ||||
-rw-r--r-- | compilerplugins/clang/staticmethods.cxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/typecheck.cxx | 3 | ||||
-rw-r--r-- | compilerplugins/clang/unuseddefaultparams.cxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/unusedmethods.cxx | 5 | ||||
-rw-r--r-- | compilerplugins/clang/vclwidgets.cxx | 8 | ||||
-rw-r--r-- | compilerplugins/clang/weakobject.cxx | 5 |
13 files changed, 55 insertions, 18 deletions
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index e1b4d8e4eba4..2f73b7ff5e0f 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 6fef22758a85..9be28f0a9f88 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 1e4c5e29c0cf..79dc8fba2726 100644 --- a/compilerplugins/clang/implicitboolconversion.cxx +++ b/compilerplugins/clang/implicitboolconversion.cxx @@ -21,7 +21,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; @@ -29,7 +31,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; @@ -37,6 +39,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 8c9814e66003..b2f5ce65b21a 100644 --- a/compilerplugins/clang/passstuffbyref.cxx +++ b/compilerplugins/clang/passstuffbyref.cxx @@ -231,7 +231,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 8084ee34104b..d2a125d4851f 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/refcounting.cxx b/compilerplugins/clang/refcounting.cxx index 9bb948517712..9ce88a370e21 100644 --- a/compilerplugins/clang/refcounting.cxx +++ b/compilerplugins/clang/refcounting.cxx @@ -427,7 +427,7 @@ bool RefCounting::VisitFunctionDecl(const FunctionDecl * functionDecl) { if (methodDecl && methodDecl->size_overridden_methods() > 0) { return true; } - checkUnoReference(functionDecl->getReturnType(), functionDecl, "", "return"); + checkUnoReference(compat::getReturnType(*functionDecl), functionDecl, "", "return"); return true; } diff --git a/compilerplugins/clang/singlevalfields.cxx b/compilerplugins/clang/singlevalfields.cxx index 79866fa90886..a75b52910c54 100644 --- a/compilerplugins/clang/singlevalfields.cxx +++ b/compilerplugins/clang/singlevalfields.cxx @@ -258,7 +258,7 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr ) if (parent && isa<ReturnStmt>(parent)) { const Stmt* parent2 = parentStmt(parent); if (parent2 && isa<CompoundStmt>(parent2)) { - QualType qt = parentFunction->getReturnType().getDesugaredType(compiler.getASTContext()); + QualType qt = compat::getReturnType(*parentFunction).getDesugaredType(compiler.getASTContext()); if (!qt.isConstQualified() && qt->isReferenceType()) { assignValue = "?"; bPotentiallyAssignedTo = true; @@ -443,10 +443,10 @@ void SingleValFields::checkCallExpr(const Stmt* child, const CallExpr* callExpr, return; } for (unsigned i = 0; i < callExpr->getNumArgs(); ++i) { - if (i >= proto->getNumParams()) // can happen in template code + if (i >= compat::getNumParams(*proto)) // can happen in template code break; if (callExpr->getArg(i) == child) { - QualType qt = proto->getParamTypes()[i].getDesugaredType(compiler.getASTContext()); + QualType qt = compat::getParamType(*proto, i).getDesugaredType(compiler.getASTContext()); if (!qt.isConstQualified() && qt->isReferenceType()) { assignValue = "?"; bPotentiallyAssignedTo = true; diff --git a/compilerplugins/clang/staticmethods.cxx b/compilerplugins/clang/staticmethods.cxx index 43e0f73db414..be014fd1630d 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 71f9994b6bc4..d7bccfd814a8 100644 --- a/compilerplugins/clang/typecheck.cxx +++ b/compilerplugins/clang/typecheck.cxx @@ -81,7 +81,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 6d2094e8ab87..db5882480f52 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 7de434d9b887..0ff053af6943 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" @@ -265,7 +268,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 212dcb505f7a..368c962a84b7 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; diff --git a/compilerplugins/clang/weakobject.cxx b/compilerplugins/clang/weakobject.cxx index cac13cdcc7db..c714274a45f1 100644 --- a/compilerplugins/clang/weakobject.cxx +++ b/compilerplugins/clang/weakobject.cxx @@ -98,10 +98,11 @@ public: } CompoundStmt const*const pCompoundStatement( dyn_cast<CompoundStmt>(pMethodDecl->getBody())); - for (auto const pStmt : pCompoundStatement->body()) + for (auto i = pCompoundStatement->body_begin(); + i != pCompoundStatement->body_end(); ++i) { // note: this is not a CXXMemberCallExpr - CallExpr const*const pCallExpr(dyn_cast<CallExpr>(pStmt)); + CallExpr const*const pCallExpr(dyn_cast<CallExpr>(*i)); if (pCallExpr) { // note: this is only sometimes a CXXMethodDecl |