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@googlemail.com>
This commit is contained in:
committed by
Christian Lohmaier
parent
b35232bdf5
commit
c096ab87c8
@@ -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
|
||||
{
|
||||
@@ -60,6 +62,7 @@ public:
|
||||
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);
|
||||
@@ -86,12 +89,10 @@ bool ExpressionAlwaysZero::VisitBinaryOperator( BinaryOperator const * binaryOpe
|
||||
; // ok
|
||||
else
|
||||
return true;
|
||||
report(
|
||||
DiagnosticsEngine::Warning, "expression always evaluates to zero, lhs=%0 rhs=%1",
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -118,12 +119,10 @@ bool ExpressionAlwaysZero::VisitCXXOperatorCallExpr( CXXOperatorCallExpr const *
|
||||
; // ok
|
||||
else
|
||||
return true;
|
||||
report(
|
||||
DiagnosticsEngine::Warning, "expression always evaluates to zero, lhs=%0 rhs=%1",
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -131,7 +130,8 @@ 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;
|
||||
}
|
||||
bool ExpressionAlwaysZero::TraverseStaticAssertDecl(StaticAssertDecl*) { return true; }
|
||||
|
||||
loplugin::Plugin::Registration<ExpressionAlwaysZero> X("expressionalwayszero", false);
|
||||
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -30,7 +30,6 @@ static const int stmtlimit = 50;
|
||||
|
||||
namespace loplugin
|
||||
{
|
||||
|
||||
struct WalkCounter
|
||||
{
|
||||
int stmtcount;
|
||||
|
@@ -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&);
|
||||
};
|
||||
|
||||
|
@@ -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]}}
|
||||
};
|
||||
|
||||
|
@@ -11,10 +11,9 @@
|
||||
|
||||
extern int n0;
|
||||
|
||||
namespace N {
|
||||
|
||||
namespace N
|
||||
{
|
||||
extern int v1;
|
||||
|
||||
}
|
||||
|
||||
struct S;
|
||||
|
@@ -9,7 +9,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
struct S {
|
||||
struct S
|
||||
{
|
||||
void f1();
|
||||
void f2() const;
|
||||
void f3();
|
||||
|
@@ -49,8 +49,7 @@ struct A
|
||||
}
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
void fun( const T& par )
|
||||
template <typename T> void fun(const T& par)
|
||||
// parameters are without warnings
|
||||
{
|
||||
const T& var = par;
|
||||
@@ -59,9 +58,6 @@ void fun( const T& par )
|
||||
(void)var;
|
||||
}
|
||||
|
||||
void testfun()
|
||||
{
|
||||
fun( "fun" + OUString::number( 200 ));
|
||||
}
|
||||
void testfun() { fun("fun" + OUString::number(200)); }
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user