[Libreoffice-commits] core.git: compilerplugins/clang

Stephan Bergmann sbergman at redhat.com
Tue Aug 4 00:38:27 PDT 2015


 compilerplugins/clang/compat.hxx                      |   32 ++++++++++++++++++
 compilerplugins/clang/implicitboolconversion.cxx      |    4 ++
 compilerplugins/clang/inlinesimplememberfunctions.cxx |   10 ++---
 compilerplugins/clang/refcounting.cxx                 |   12 ++++++
 compilerplugins/clang/staticmethods.cxx               |   10 ++++-
 compilerplugins/clang/unusedvariablecheck.cxx         |   11 +++++-
 compilerplugins/clang/vclwidgets.cxx                  |   10 ++++-
 7 files changed, 77 insertions(+), 12 deletions(-)

New commits:
commit c15b4cf39a74176cee64795129d76f411d2c0a69
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Aug 4 09:36:32 2015 +0200

    Adapt to current Clang trunk towards 3.7
    
    Change-Id: Ibb2c641d49a1773be789c9259f53a040db6f605f

diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx
index 08787e8..d7fb644 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 3f255ff..ef8bc8e 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 42dd256..74959c3 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 0ecdf8e..460db1c 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 036662c..4fbddeb 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 0308d9b..9bbb9d5 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 7be617f..032dc93 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;


More information about the Libreoffice-commits mailing list