summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-08-04 09:36:32 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-08-04 09:36:32 +0200
commitc15b4cf39a74176cee64795129d76f411d2c0a69 (patch)
treecf03416c9dd4762553e1dc66fdec5ded319c7353 /compilerplugins
parentf17f89aadc5e88880df0c852289e2fa5b04254ba (diff)
Adapt to current Clang trunk towards 3.7
Change-Id: Ibb2c641d49a1773be789c9259f53a040db6f605f
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/compat.hxx32
-rw-r--r--compilerplugins/clang/implicitboolconversion.cxx4
-rw-r--r--compilerplugins/clang/inlinesimplememberfunctions.cxx10
-rw-r--r--compilerplugins/clang/refcounting.cxx12
-rw-r--r--compilerplugins/clang/staticmethods.cxx10
-rw-r--r--compilerplugins/clang/unusedvariablecheck.cxx11
-rw-r--r--compilerplugins/clang/vclwidgets.cxx10
7 files changed, 77 insertions, 12 deletions
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx
index 08787e8c77fd..d7fb644984cc 100644
--- a/compilerplugins/clang/compat.hxx
+++ b/compilerplugins/clang/compat.hxx
@@ -65,6 +65,18 @@ inline bool isInExternCContext(clang::FunctionDecl const & decl) {
#endif
}
+inline bool forallBases(
+ clang::CXXRecordDecl const & decl,
+ clang::CXXRecordDecl::ForallBasesCallback BaseMatches,
+ bool AllowShortCircuit)
+{
+#if (__clang_major__ == 3 && __clang_minor__ >= 7) || __clang_major__ > 3
+ return decl.forallBases(BaseMatches, AllowShortCircuit);
+#else
+ return decl.forallBases(BaseMatches, nullptr, AllowShortCircuit);
+#endif
+}
+
#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
typedef clang::LinkageInfo LinkageInfo;
#else
@@ -129,6 +141,26 @@ inline clang::QualType getParamType(
#endif
}
+inline clang::Stmt::const_child_iterator begin(
+ clang::Stmt::const_child_range const & range)
+{
+#if (__clang_major__ == 3 && __clang_minor__ >= 7) || __clang_major__ > 3
+ return range.begin();
+#else
+ return range.first;
+#endif
+}
+
+inline clang::Stmt::const_child_iterator end(
+ clang::Stmt::const_child_range const & range)
+{
+#if (__clang_major__ == 3 && __clang_minor__ >= 7) || __clang_major__ > 3
+ return range.end();
+#else
+ return range.second;
+#endif
+}
+
inline unsigned getBuiltinCallee(clang::CallExpr const & expr) {
#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
return expr.getBuiltinCallee();
diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx
index 3f255ff35efe..ef8bc8e2526f 100644
--- a/compilerplugins/clang/implicitboolconversion.cxx
+++ b/compilerplugins/clang/implicitboolconversion.cxx
@@ -18,6 +18,8 @@
#include "compat.hxx"
#include "plugin.hxx"
+#if __clang_major__ == 3 && __clang_minor__ < 7
+
template<> struct std::iterator_traits<ExprIterator> {
typedef std::ptrdiff_t difference_type;
typedef Expr * value_type;
@@ -34,6 +36,8 @@ template<> struct std::iterator_traits<ConstExprIterator> {
typedef std::random_access_iterator_tag iterator_category;
};
+#endif
+
namespace {
Expr const * ignoreParenAndTemporaryMaterialization(Expr const * expr) {
diff --git a/compilerplugins/clang/inlinesimplememberfunctions.cxx b/compilerplugins/clang/inlinesimplememberfunctions.cxx
index 42dd2569df72..74959c3127bd 100644
--- a/compilerplugins/clang/inlinesimplememberfunctions.cxx
+++ b/compilerplugins/clang/inlinesimplememberfunctions.cxx
@@ -31,10 +31,10 @@ private:
};
static bool oneAndOnlyOne(clang::Stmt::const_child_range range) {
- if (range.empty()) {
+ if (compat::begin(range) == compat::end(range)) {
return false;
}
- if ((++range.first) != range.second) {
+ if (++compat::begin(range) != compat::end(range)) {
return false;
}
return true;
@@ -134,7 +134,7 @@ bool InlineSimpleMemberFunctions::VisitCXXMethodDecl(const CXXMethodDecl * funct
{
childStmt2 = *childStmt2->child_begin();
if (dyn_cast<CXXThisExpr>( childStmt2 ) != nullptr
- && childStmt2->children().empty())
+ && compat::begin(childStmt2->children()) == compat::end(childStmt2->children()))
{
return true;
}
@@ -145,7 +145,7 @@ bool InlineSimpleMemberFunctions::VisitCXXMethodDecl(const CXXMethodDecl * funct
{
const Stmt* childStmt2 = *childStmt->child_begin();
if (dyn_cast<CXXThisExpr>( childStmt2 ) != nullptr
- && childStmt2->children().empty())
+ && compat::begin(childStmt2->children()) == compat::end(childStmt2->children()))
{
return true;
}
@@ -208,7 +208,7 @@ bool InlineSimpleMemberFunctions::VisitCXXMethodDecl(const CXXMethodDecl * funct
}
return true;
}
- if ( childStmt->children().empty() )
+ if ( compat::begin(childStmt->children()) == compat::end(childStmt->children()) )
return true;
childStmt = *childStmt->child_begin();
}
diff --git a/compilerplugins/clang/refcounting.cxx b/compilerplugins/clang/refcounting.cxx
index 0ecdf8e8037f..460db1c42489 100644
--- a/compilerplugins/clang/refcounting.cxx
+++ b/compilerplugins/clang/refcounting.cxx
@@ -73,7 +73,17 @@ bool isDerivedFrom(const CXXRecordDecl *decl, const char *pString) {
if (// not sure what hasAnyDependentBases() does,
// but it avoids classes we don't want, e.g. WeakAggComponentImplHelper1
!decl->hasAnyDependentBases() &&
- !decl->forallBases(BaseCheckNotSubclass, static_cast<void*>(const_cast<char*>(pString)), true)) {
+ !compat::forallBases(
+ *decl,
+#if __clang_major__ == 3 && __clang_minor__ < 7
+ BaseCheckNotSubclass,
+#else
+ [pString](const CXXRecordDecl *BaseDefinition) -> bool
+ { return BaseCheckNotSubclass(
+ BaseDefinition, const_cast<char *>(pString)); },
+#endif
+ true))
+ {
return true;
}
return false;
diff --git a/compilerplugins/clang/staticmethods.cxx b/compilerplugins/clang/staticmethods.cxx
index 036662c3ea16..4fbddeb0d262 100644
--- a/compilerplugins/clang/staticmethods.cxx
+++ b/compilerplugins/clang/staticmethods.cxx
@@ -36,7 +36,13 @@ private:
std::string getFilename(SourceLocation loc);
};
-bool BaseCheckNotTestFixtureSubclass(const CXXRecordDecl *BaseDefinition, void *) {
+bool BaseCheckNotTestFixtureSubclass(
+ const CXXRecordDecl *BaseDefinition
+#if __clang_major__ == 3 && __clang_minor__ < 7
+ , void *
+#endif
+ )
+{
if (BaseDefinition->getQualifiedNameAsString().compare("CppUnit::TestFixture") == 0) {
return false;
}
@@ -49,7 +55,7 @@ bool isDerivedFromTestFixture(const CXXRecordDecl *decl) {
if (// not sure what hasAnyDependentBases() does,
// but it avoids classes we don't want, e.g. WeakAggComponentImplHelper1
!decl->hasAnyDependentBases() &&
- !decl->forallBases(BaseCheckNotTestFixtureSubclass, nullptr, true)) {
+ !compat::forallBases(*decl, BaseCheckNotTestFixtureSubclass, true)) {
return true;
}
return false;
diff --git a/compilerplugins/clang/unusedvariablecheck.cxx b/compilerplugins/clang/unusedvariablecheck.cxx
index 0308d9b6150c..9bbb9d5e6ae2 100644
--- a/compilerplugins/clang/unusedvariablecheck.cxx
+++ b/compilerplugins/clang/unusedvariablecheck.cxx
@@ -16,6 +16,7 @@
// (LO classes won't get duplicated warnings, as the attribute is different).
#if !HAVE_GCC_ATTRIBUTE_WARN_UNUSED_STL
+#include "compat.hxx"
#include "unusedvariablecheck.hxx"
#include <clang/AST/Attr.h>
@@ -48,7 +49,13 @@ void UnusedVariableCheck::run()
TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
}
-bool BaseCheckNotDialogSubclass(const CXXRecordDecl *BaseDefinition, void *) {
+bool BaseCheckNotDialogSubclass(
+ const CXXRecordDecl *BaseDefinition
+#if __clang_major__ == 3 && __clang_minor__ < 7
+ , void *
+#endif
+ )
+{
if (BaseDefinition && BaseDefinition->getQualifiedNameAsString().compare("Dialog") == 0) {
return false;
}
@@ -66,7 +73,7 @@ bool isDerivedFromDialog(const CXXRecordDecl *decl) {
if (// not sure what hasAnyDependentBases() does,
// but it avoids classes we don't want, e.g. WeakAggComponentImplHelper1
!decl->hasAnyDependentBases() &&
- !decl->forallBases(BaseCheckNotDialogSubclass, nullptr, true)) {
+ !compat::forallBases(*decl, BaseCheckNotDialogSubclass, true)) {
return true;
}
return false;
diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx
index 7be617ff0316..032dc937a3df 100644
--- a/compilerplugins/clang/vclwidgets.cxx
+++ b/compilerplugins/clang/vclwidgets.cxx
@@ -57,7 +57,13 @@ static bool startsWith(const std::string& s, const char* other)
return s.compare(0, strlen(other), other) == 0;
}
-bool BaseCheckNotWindowSubclass(const CXXRecordDecl *BaseDefinition, void *) {
+bool BaseCheckNotWindowSubclass(
+ const CXXRecordDecl *BaseDefinition
+#if __clang_major__ == 3 && __clang_minor__ < 7
+ , void *
+#endif
+ )
+{
if (BaseDefinition && BaseDefinition->getQualifiedNameAsString() == "OutputDevice") {
return false;
}
@@ -75,7 +81,7 @@ bool isDerivedFromWindow(const CXXRecordDecl *decl) {
if (// not sure what hasAnyDependentBases() does,
// but it avoids classes we don't want, e.g. WeakAggComponentImplHelper1
!decl->hasAnyDependentBases() &&
- !decl->forallBases(BaseCheckNotWindowSubclass, nullptr, true)) {
+ !compat::forallBases(*decl, BaseCheckNotWindowSubclass, true)) {
return true;
}
return false;