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

Philipp Hofer (via logerrit) logerrit at kemper.freedesktop.org
Sun Nov 22 00:56:59 UTC 2020


 compilerplugins/clang/expressionalwayszero.cxx  |   54 +++++++++++-------------
 compilerplugins/clang/store/cascadingcondop.cxx |   25 +++++------
 compilerplugins/clang/store/test/deadclass.cxx  |    3 -
 compilerplugins/clang/test/datamembershadow.cxx |    6 +-
 compilerplugins/clang/test/external.hxx         |    5 --
 compilerplugins/clang/test/oslendian-1.cxx      |   12 ++---
 compilerplugins/clang/test/redundantcast.hxx    |   11 ++--
 compilerplugins/clang/test/stringconcatauto.cxx |   34 ++++++---------
 solenv/clang-format/excludelist                 |    8 ---
 9 files changed, 72 insertions(+), 86 deletions(-)

New commits:
commit c096ab87c8a11e8d75dc689ea7024288419cfd22
Author:     Philipp Hofer <philipp.hofer at protonmail.com>
AuthorDate: Thu Nov 12 12:51:50 2020 +0100
Commit:     Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
CommitDate: Sun Nov 22 01:56:05 2020 +0100

    tdf#123936 Formatting files in module compilerplugins with clang-format
    
    Change-Id: Ie6e23d3d2a20849e47d048b439d72fd7376c53db
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105654
    Tested-by: Jenkins
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>

diff --git a/compilerplugins/clang/expressionalwayszero.cxx b/compilerplugins/clang/expressionalwayszero.cxx
index 067aa9cc6dbd..24e7287615ba 100644
--- a/compilerplugins/clang/expressionalwayszero.cxx
+++ b/compilerplugins/clang/expressionalwayszero.cxx
@@ -21,13 +21,15 @@
     Generally a mistake when people meant to use | or operator|
 */
 
-namespace {
-
-class ExpressionAlwaysZero:
-    public loplugin::FilteringPlugin<ExpressionAlwaysZero>
+namespace
+{
+class ExpressionAlwaysZero : public loplugin::FilteringPlugin<ExpressionAlwaysZero>
 {
 public:
-    explicit ExpressionAlwaysZero(loplugin::InstantiationData const & data): FilteringPlugin(data) {}
+    explicit ExpressionAlwaysZero(loplugin::InstantiationData const& data)
+        : FilteringPlugin(data)
+    {
+    }
 
     virtual void run() override
     {
@@ -57,15 +59,16 @@ public:
         TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
     }
 
-    bool VisitBinaryOperator(BinaryOperator const *);
-    bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const *);
-    bool TraverseStaticAssertDecl(StaticAssertDecl *);
+    bool VisitBinaryOperator(BinaryOperator const*);
+    bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const*);
+    bool TraverseStaticAssertDecl(StaticAssertDecl*);
+
 private:
     // note, abusing std::unique_ptr as a std::optional lookalike
     std::unique_ptr<APSInt> getExprValue(const Expr* arg);
 };
 
-bool ExpressionAlwaysZero::VisitBinaryOperator( BinaryOperator const * binaryOperator )
+bool ExpressionAlwaysZero::VisitBinaryOperator(BinaryOperator const* binaryOperator)
 {
     if (ignoreLocation(binaryOperator))
         return true;
@@ -86,16 +89,14 @@ bool ExpressionAlwaysZero::VisitBinaryOperator( BinaryOperator const * binaryOpe
         ; // ok
     else
         return true;
-    report(
-        DiagnosticsEngine::Warning, "expression always evaluates to zero, lhs=%0 rhs=%1",
-        compat::getBeginLoc(binaryOperator))
+    report(DiagnosticsEngine::Warning, "expression always evaluates to zero, lhs=%0 rhs=%1",
+           compat::getBeginLoc(binaryOperator))
         << (lhsValue ? lhsValue->toString(10) : "unknown")
-        << (rhsValue ? rhsValue->toString(10) : "unknown")
-        << binaryOperator->getSourceRange();
+        << (rhsValue ? rhsValue->toString(10) : "unknown") << binaryOperator->getSourceRange();
     return true;
 }
 
-bool ExpressionAlwaysZero::VisitCXXOperatorCallExpr( CXXOperatorCallExpr const * cxxOperatorCallExpr )
+bool ExpressionAlwaysZero::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const* cxxOperatorCallExpr)
 {
     if (ignoreLocation(cxxOperatorCallExpr))
         return true;
@@ -103,7 +104,7 @@ bool ExpressionAlwaysZero::VisitCXXOperatorCallExpr( CXXOperatorCallExpr const *
         return true;
 
     auto op = cxxOperatorCallExpr->getOperator();
-    if ( !(op == OO_Amp || op == OO_AmpEqual || op == OO_AmpAmp))
+    if (!(op == OO_Amp || op == OO_AmpEqual || op == OO_AmpAmp))
         return true;
 
     if (cxxOperatorCallExpr->getNumArgs() != 2)
@@ -118,20 +119,19 @@ bool ExpressionAlwaysZero::VisitCXXOperatorCallExpr( CXXOperatorCallExpr const *
         ; // ok
     else
         return true;
-    report(
-        DiagnosticsEngine::Warning, "expression always evaluates to zero, lhs=%0 rhs=%1",
-        compat::getBeginLoc(cxxOperatorCallExpr))
+    report(DiagnosticsEngine::Warning, "expression always evaluates to zero, lhs=%0 rhs=%1",
+           compat::getBeginLoc(cxxOperatorCallExpr))
         << (lhsValue ? lhsValue->toString(10) : "unknown")
-        << (rhsValue ? rhsValue->toString(10) : "unknown")
-        << cxxOperatorCallExpr->getSourceRange();
+        << (rhsValue ? rhsValue->toString(10) : "unknown") << cxxOperatorCallExpr->getSourceRange();
     return true;
 }
 
-std::unique_ptr<APSInt> ExpressionAlwaysZero::getExprValue(Expr const * expr)
+std::unique_ptr<APSInt> ExpressionAlwaysZero::getExprValue(Expr const* expr)
 {
     expr = expr->IgnoreParenCasts();
     // ignore this, it seems to trigger an infinite recursion
-    if (isa<UnaryExprOrTypeTraitExpr>(expr)) {
+    if (isa<UnaryExprOrTypeTraitExpr>(expr))
+    {
         return std::unique_ptr<APSInt>();
     }
     APSInt x1;
@@ -141,13 +141,9 @@ std::unique_ptr<APSInt> ExpressionAlwaysZero::getExprValue(Expr const * expr)
 }
 
 // these will often evaluate to zero harmlessly
-bool ExpressionAlwaysZero::TraverseStaticAssertDecl( StaticAssertDecl * )
-{
-    return true;
-}
-
-loplugin::Plugin::Registration< ExpressionAlwaysZero > X("expressionalwayszero", false);
+bool ExpressionAlwaysZero::TraverseStaticAssertDecl(StaticAssertDecl*) { return true; }
 
+loplugin::Plugin::Registration<ExpressionAlwaysZero> X("expressionalwayszero", false);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/store/cascadingcondop.cxx b/compilerplugins/clang/store/cascadingcondop.cxx
index f2687e76922d..4671f41b436a 100644
--- a/compilerplugins/clang/store/cascadingcondop.cxx
+++ b/compilerplugins/clang/store/cascadingcondop.cxx
@@ -30,16 +30,15 @@ static const int stmtlimit = 50;
 
 namespace loplugin
 {
-
 struct WalkCounter
 {
-    int  stmtcount;
+    int stmtcount;
     bool cascading;
 };
 
 // Ctor, nothing special, pass the argument(s).
-CascadingCondOp::CascadingCondOp( const InstantiationData& data )
-    : FilteringPlugin( data )
+CascadingCondOp::CascadingCondOp(const InstantiationData& data)
+    : FilteringPlugin(data)
 {
 }
 
@@ -48,38 +47,38 @@ void CascadingCondOp::run()
 {
     // Traverse the whole AST of the translation unit (i.e. examine the whole source file).
     // The Clang AST helper class will call VisitReturnStmt for every return statement.
-    TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
+    TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
 }
 
-void CascadingCondOp::Walk( const Stmt* stmt, WalkCounter& c )
+void CascadingCondOp::Walk(const Stmt* stmt, WalkCounter& c)
 {
-    for(Stmt::const_child_iterator it = stmt->child_begin(); it != stmt->child_end(); ++it)
+    for (Stmt::const_child_iterator it = stmt->child_begin(); it != stmt->child_end(); ++it)
     {
         ++c.stmtcount;
-        if ( dyn_cast< ConditionalOperator >( *it ))
+        if (dyn_cast<ConditionalOperator>(*it))
             c.cascading = true;
         Walk(*it, c);
     }
 }
 
-bool CascadingCondOp::VisitStmt( const Stmt* stmt )
+bool CascadingCondOp::VisitStmt(const Stmt* stmt)
 {
-    if ( const ConditionalOperator* condop = dyn_cast< ConditionalOperator >( stmt ))
+    if (const ConditionalOperator* condop = dyn_cast<ConditionalOperator>(stmt))
     {
         WalkCounter c = { 0, false };
         Walk(condop, c);
-        if(c.cascading && c.stmtcount >= stmtlimit)
+        if (c.cascading && c.stmtcount >= stmtlimit)
         {
             std::string msg("cascading conditional operator, complexity: ");
             msg.append(std::to_string(c.stmtcount));
-            report( DiagnosticsEngine::Warning, msg, condop->getLocStart());
+            report(DiagnosticsEngine::Warning, msg, condop->getLocStart());
         }
     }
     return true;
 }
 
 // Register the plugin action with the LO plugin handling.
-static Plugin::Registration< CascadingCondOp > X( "cascadingcondop" );
+static Plugin::Registration<CascadingCondOp> X("cascadingcondop");
 
 } // namespace loplugin
 
diff --git a/compilerplugins/clang/store/test/deadclass.cxx b/compilerplugins/clang/store/test/deadclass.cxx
index d8b9cdb60889..ffae241d4285 100644
--- a/compilerplugins/clang/store/test/deadclass.cxx
+++ b/compilerplugins/clang/store/test/deadclass.cxx
@@ -7,7 +7,8 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-struct Foo { // expected-error {{class has only copy/move constructors, must be dead [loplugin:deadclass]}}
+struct Foo
+{ // expected-error {{class has only copy/move constructors, must be dead [loplugin:deadclass]}}
     Foo(Foo&);
 };
 
diff --git a/compilerplugins/clang/test/datamembershadow.cxx b/compilerplugins/clang/test/datamembershadow.cxx
index a11a7cc51c65..ef8722d5c806 100644
--- a/compilerplugins/clang/test/datamembershadow.cxx
+++ b/compilerplugins/clang/test/datamembershadow.cxx
@@ -11,11 +11,13 @@
 
 #include <config_clang.h>
 
-struct Bar {
+struct Bar
+{
     int x; // expected-note {{superclass member here [loplugin:datamembershadow]}}
 };
 
-struct Foo : public Bar {
+struct Foo : public Bar
+{
     int x; // expected-error {{data member x is shadowing member in superclass, through inheritance path Foo->Bar [loplugin:datamembershadow]}}
 };
 
diff --git a/compilerplugins/clang/test/external.hxx b/compilerplugins/clang/test/external.hxx
index 749fec0ee3c7..40e8d55c0afe 100644
--- a/compilerplugins/clang/test/external.hxx
+++ b/compilerplugins/clang/test/external.hxx
@@ -11,10 +11,9 @@
 
 extern int n0;
 
-namespace N {
-
+namespace N
+{
 extern int v1;
-
 }
 
 struct S;
diff --git a/compilerplugins/clang/test/oslendian-1.cxx b/compilerplugins/clang/test/oslendian-1.cxx
index 7349239aa98d..7d0023037f75 100644
--- a/compilerplugins/clang/test/oslendian-1.cxx
+++ b/compilerplugins/clang/test/oslendian-1.cxx
@@ -24,24 +24,24 @@
 
 #if !defined OSL_BIGENDIAN
 #define OSL_BIGENDIAN
-    // expected-error at -1 {{macro 'OSL_BIGENDIAN' defined in addition to 'OSL_LITENDIAN' [loplugin:oslendian]}}
-    // expected-note at osl/endian.h:* {{conflicting macro definition is here [loplugin:oslendian]}}
+// expected-error at -1 {{macro 'OSL_BIGENDIAN' defined in addition to 'OSL_LITENDIAN' [loplugin:oslendian]}}
+// expected-note at osl/endian.h:* {{conflicting macro definition is here [loplugin:oslendian]}}
 #endif
 
 #if !defined OSL_LITENDIAN
 #define OSL_LITENDIAN
-    // expected-error at -1 {{macro 'OSL_LITENDIAN' defined in addition to 'OSL_BIGENDIAN' [loplugin:oslendian]}}
-    // expected-note at osl/endian.h:* {{conflicting macro definition is here [loplugin:oslendian]}}
+// expected-error at -1 {{macro 'OSL_LITENDIAN' defined in addition to 'OSL_BIGENDIAN' [loplugin:oslendian]}}
+// expected-note at osl/endian.h:* {{conflicting macro definition is here [loplugin:oslendian]}}
 #endif
 
 #if defined OSL_BIGENDIAN
 #undef OSL_BIGENDIAN
-    // expected-error at -1 {{macro 'OSL_BIGENDIAN' undefinition [loplugin:oslendian]}}
+// expected-error at -1 {{macro 'OSL_BIGENDIAN' undefinition [loplugin:oslendian]}}
 #endif
 
 #if defined OSL_LITENDIAN
 #undef OSL_LITENDIAN
-    // expected-error at -1 {{macro 'OSL_LITENDIAN' undefinition [loplugin:oslendian]}}
+// expected-error at -1 {{macro 'OSL_LITENDIAN' undefinition [loplugin:oslendian]}}
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/compilerplugins/clang/test/redundantcast.hxx b/compilerplugins/clang/test/redundantcast.hxx
index 113dd0f1a8e8..0afab0c2dc07 100644
--- a/compilerplugins/clang/test/redundantcast.hxx
+++ b/compilerplugins/clang/test/redundantcast.hxx
@@ -9,23 +9,24 @@
 
 #pragma once
 
-struct S {
+struct S
+{
     void f1();
     void f2() const;
     void f3();
     void f3() const;
 };
 
-int && nix();
-int const && cix();
+int&& nix();
+int const&& cix();
 int nir();
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wignored-qualifiers"
 int const cir();
 #pragma clang diagnostic pop
 
-S && nsx();
-S const && csx();
+S&& nsx();
+S const&& csx();
 S nsr();
 S const csr();
 
diff --git a/compilerplugins/clang/test/stringconcatauto.cxx b/compilerplugins/clang/test/stringconcatauto.cxx
index 6c9a72c293b3..8318e3c4a26f 100644
--- a/compilerplugins/clang/test/stringconcatauto.cxx
+++ b/compilerplugins/clang/test/stringconcatauto.cxx
@@ -13,24 +13,24 @@
 
 void foo()
 {
-    auto str1 = "str1" + OUString::number( 10 );
+    auto str1 = "str1" + OUString::number(10);
     // expected-error-re at -1 {{creating a variable of type 'rtl::OUStringConcat<{{.*}}>' will make it reference temporaries}}
     // expected-note at -2 {{use OUString instead}}
-    OUString str2 = "str2" + OUString::number( 20 ) + "ing";
-    const auto& str3 = "str3" + OUString::number( 30 );
+    OUString str2 = "str2" + OUString::number(20) + "ing";
+    const auto& str3 = "str3" + OUString::number(30);
     // expected-error-re at -1 {{creating a variable of type 'const rtl::OUStringConcat<{{.*}}> &' will make it reference temporaries}}
     // expected-note at -2 {{use OUString instead}}
-    const auto str4 = "str4" + OString::number( 40 );
+    const auto str4 = "str4" + OString::number(40);
     // expected-error-re at -1 {{creating a variable of type 'const rtl::OStringConcat<{{.*}}>' will make it reference temporaries}}
     // expected-note at -2 {{use OString instead}}
-    auto str5 = OUString::number( 50 );
+    auto str5 = OUString::number(50);
     // expected-error-re at -1 {{creating a variable of type 'rtl::OUStringNumber<{{.*}}>' will make it reference temporaries}}
     // expected-note at -2 {{use OUString instead}}
-    (void) str1;
-    (void) str2;
-    (void) str3;
-    (void) str4;
-    (void) str5;
+    (void)str1;
+    (void)str2;
+    (void)str3;
+    (void)str4;
+    (void)str5;
 }
 
 struct A
@@ -39,29 +39,25 @@ struct A
     // expected-error-re at -1 {{returning a variable of type 'rtl::OStringConcat<{{.*}}>' will make it reference temporaries}}
     // expected-note at -2 {{use OString instead}}
     {
-        return "bar" + OString::number( 110 );
+        return "bar" + OString::number(110);
     }
     auto baz()
     // expected-error-re at -1 {{returning a variable of type 'rtl::OStringNumber<{{.*}}>' will make it reference temporaries}}
     // expected-note at -2 {{use OString instead}}
     {
-        return OString::number( 120 );
+        return OString::number(120);
     }
 };
 
-template< typename T >
-void fun( const T& par )
+template <typename T> void fun(const T& par)
 // parameters are without warnings
 {
     const T& var = par;
     // expected-error-re at -1 {{creating a variable of type 'const rtl::OUStringConcat<{{.*}}> &' will make it reference temporaries}}
     // expected-note at -2 {{use OUString instead}}
-    (void) var;
+    (void)var;
 }
 
-void testfun()
-{
-    fun( "fun" + OUString::number( 200 ));
-}
+void testfun() { fun("fun" + OUString::number(200)); }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index b24cafabf60b..6f22399103dd 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -1565,7 +1565,6 @@ compilerplugins/clang/dodgyswitch.cxx
 compilerplugins/clang/dyncastvisibility.cxx
 compilerplugins/clang/dynexcspec.cxx
 compilerplugins/clang/expandablemethods.cxx
-compilerplugins/clang/expressionalwayszero.cxx
 compilerplugins/clang/externandnotdefined.cxx
 compilerplugins/clang/faileddyncast.cxx
 compilerplugins/clang/fakebool.cxx
@@ -1620,7 +1619,6 @@ compilerplugins/clang/store/bodynotinblock.cxx
 compilerplugins/clang/store/bodynotinblock.hxx
 compilerplugins/clang/store/cascadingassignop.cxx
 compilerplugins/clang/store/cascadingassignop.hxx
-compilerplugins/clang/store/cascadingcondop.cxx
 compilerplugins/clang/store/cascadingcondop.hxx
 compilerplugins/clang/store/changefunctioncalls.cxx
 compilerplugins/clang/store/constantfunction.cxx
@@ -1647,7 +1645,6 @@ compilerplugins/clang/store/sfxitemsetrewrite.cxx
 compilerplugins/clang/store/stdexception.cxx
 compilerplugins/clang/store/stylepolice.cxx
 compilerplugins/clang/store/svstreamoutputoperators.cxx
-compilerplugins/clang/store/test/deadclass.cxx
 compilerplugins/clang/store/tutorial/tutorial1.cxx
 compilerplugins/clang/store/tutorial/tutorial1.hxx
 compilerplugins/clang/store/tutorial/tutorial1_example.cxx
@@ -1671,10 +1668,8 @@ compilerplugins/clang/test/constmethod.cxx
 compilerplugins/clang/test/constparams.cxx
 compilerplugins/clang/test/cppunitassertequals.cxx
 compilerplugins/clang/test/cppunitassertequals.hxx
-compilerplugins/clang/test/datamembershadow.cxx
 compilerplugins/clang/test/dodgyswitch.cxx
 compilerplugins/clang/test/expressionalwayszero.cxx
-compilerplugins/clang/test/external.hxx
 compilerplugins/clang/test/faileddyncast.cxx
 compilerplugins/clang/test/fakebool.cxx
 compilerplugins/clang/test/finalprotected.cxx
@@ -1683,18 +1678,15 @@ compilerplugins/clang/test/indentation.cxx
 compilerplugins/clang/test/loopvartoosmall.cxx
 compilerplugins/clang/test/namespaceindentation.cxx
 compilerplugins/clang/test/oncevar.cxx
-compilerplugins/clang/test/oslendian-1.cxx
 compilerplugins/clang/test/oslendian-2.cxx
 compilerplugins/clang/test/oslendian-3.cxx
 compilerplugins/clang/test/passparamsbyref.cxx
 compilerplugins/clang/test/passstuffbyref.cxx
 compilerplugins/clang/test/redundantcast.cxx
-compilerplugins/clang/test/redundantcast.hxx
 compilerplugins/clang/test/redundantinline.cxx
 compilerplugins/clang/test/redundantinline.hxx
 compilerplugins/clang/test/redundantpointerops.cxx
 compilerplugins/clang/test/salunicodeliteral.cxx
-compilerplugins/clang/test/stringconcatauto.cxx
 compilerplugins/clang/test/stringconstant.cxx
 compilerplugins/clang/test/unnecessarycatchthrow.cxx
 compilerplugins/clang/test/unnecessaryoverride-dtor.cxx


More information about the Libreoffice-commits mailing list