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|
|
Generally a mistake when people meant to use | or operator|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
class ExpressionAlwaysZero:
|
class ExpressionAlwaysZero : public loplugin::FilteringPlugin<ExpressionAlwaysZero>
|
||||||
public loplugin::FilteringPlugin<ExpressionAlwaysZero>
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ExpressionAlwaysZero(loplugin::InstantiationData const & data): FilteringPlugin(data) {}
|
explicit ExpressionAlwaysZero(loplugin::InstantiationData const& data)
|
||||||
|
: FilteringPlugin(data)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual void run() override
|
virtual void run() override
|
||||||
{
|
{
|
||||||
@@ -60,6 +62,7 @@ public:
|
|||||||
bool VisitBinaryOperator(BinaryOperator const*);
|
bool VisitBinaryOperator(BinaryOperator const*);
|
||||||
bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const*);
|
bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const*);
|
||||||
bool TraverseStaticAssertDecl(StaticAssertDecl*);
|
bool TraverseStaticAssertDecl(StaticAssertDecl*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// note, abusing std::unique_ptr as a std::optional lookalike
|
// note, abusing std::unique_ptr as a std::optional lookalike
|
||||||
std::unique_ptr<APSInt> getExprValue(const Expr* arg);
|
std::unique_ptr<APSInt> getExprValue(const Expr* arg);
|
||||||
@@ -86,12 +89,10 @@ bool ExpressionAlwaysZero::VisitBinaryOperator( BinaryOperator const * binaryOpe
|
|||||||
; // ok
|
; // ok
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
report(
|
report(DiagnosticsEngine::Warning, "expression always evaluates to zero, lhs=%0 rhs=%1",
|
||||||
DiagnosticsEngine::Warning, "expression always evaluates to zero, lhs=%0 rhs=%1",
|
|
||||||
compat::getBeginLoc(binaryOperator))
|
compat::getBeginLoc(binaryOperator))
|
||||||
<< (lhsValue ? lhsValue->toString(10) : "unknown")
|
<< (lhsValue ? lhsValue->toString(10) : "unknown")
|
||||||
<< (rhsValue ? rhsValue->toString(10) : "unknown")
|
<< (rhsValue ? rhsValue->toString(10) : "unknown") << binaryOperator->getSourceRange();
|
||||||
<< binaryOperator->getSourceRange();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,12 +119,10 @@ bool ExpressionAlwaysZero::VisitCXXOperatorCallExpr( CXXOperatorCallExpr const *
|
|||||||
; // ok
|
; // ok
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
report(
|
report(DiagnosticsEngine::Warning, "expression always evaluates to zero, lhs=%0 rhs=%1",
|
||||||
DiagnosticsEngine::Warning, "expression always evaluates to zero, lhs=%0 rhs=%1",
|
|
||||||
compat::getBeginLoc(cxxOperatorCallExpr))
|
compat::getBeginLoc(cxxOperatorCallExpr))
|
||||||
<< (lhsValue ? lhsValue->toString(10) : "unknown")
|
<< (lhsValue ? lhsValue->toString(10) : "unknown")
|
||||||
<< (rhsValue ? rhsValue->toString(10) : "unknown")
|
<< (rhsValue ? rhsValue->toString(10) : "unknown") << cxxOperatorCallExpr->getSourceRange();
|
||||||
<< cxxOperatorCallExpr->getSourceRange();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +130,8 @@ std::unique_ptr<APSInt> ExpressionAlwaysZero::getExprValue(Expr const * expr)
|
|||||||
{
|
{
|
||||||
expr = expr->IgnoreParenCasts();
|
expr = expr->IgnoreParenCasts();
|
||||||
// ignore this, it seems to trigger an infinite recursion
|
// ignore this, it seems to trigger an infinite recursion
|
||||||
if (isa<UnaryExprOrTypeTraitExpr>(expr)) {
|
if (isa<UnaryExprOrTypeTraitExpr>(expr))
|
||||||
|
{
|
||||||
return std::unique_ptr<APSInt>();
|
return std::unique_ptr<APSInt>();
|
||||||
}
|
}
|
||||||
APSInt x1;
|
APSInt x1;
|
||||||
@@ -141,13 +141,9 @@ std::unique_ptr<APSInt> ExpressionAlwaysZero::getExprValue(Expr const * expr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// these will often evaluate to zero harmlessly
|
// these will often evaluate to zero harmlessly
|
||||||
bool ExpressionAlwaysZero::TraverseStaticAssertDecl( StaticAssertDecl * )
|
bool ExpressionAlwaysZero::TraverseStaticAssertDecl(StaticAssertDecl*) { return true; }
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
loplugin::Plugin::Registration<ExpressionAlwaysZero> X("expressionalwayszero", false);
|
loplugin::Plugin::Registration<ExpressionAlwaysZero> X("expressionalwayszero", false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -30,7 +30,6 @@ static const int stmtlimit = 50;
|
|||||||
|
|
||||||
namespace loplugin
|
namespace loplugin
|
||||||
{
|
{
|
||||||
|
|
||||||
struct WalkCounter
|
struct WalkCounter
|
||||||
{
|
{
|
||||||
int stmtcount;
|
int stmtcount;
|
||||||
|
@@ -7,7 +7,8 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* 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&);
|
Foo(Foo&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -11,11 +11,13 @@
|
|||||||
|
|
||||||
#include <config_clang.h>
|
#include <config_clang.h>
|
||||||
|
|
||||||
struct Bar {
|
struct Bar
|
||||||
|
{
|
||||||
int x; // expected-note {{superclass member here [loplugin:datamembershadow]}}
|
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]}}
|
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;
|
extern int n0;
|
||||||
|
|
||||||
namespace N {
|
namespace N
|
||||||
|
{
|
||||||
extern int v1;
|
extern int v1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct S;
|
struct S;
|
||||||
|
@@ -9,7 +9,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
struct S {
|
struct S
|
||||||
|
{
|
||||||
void f1();
|
void f1();
|
||||||
void f2() const;
|
void f2() const;
|
||||||
void f3();
|
void f3();
|
||||||
|
@@ -49,8 +49,7 @@ struct A
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename T >
|
template <typename T> void fun(const T& par)
|
||||||
void fun( const T& par )
|
|
||||||
// parameters are without warnings
|
// parameters are without warnings
|
||||||
{
|
{
|
||||||
const T& var = par;
|
const T& var = par;
|
||||||
@@ -59,9 +58,6 @@ void fun( const T& par )
|
|||||||
(void)var;
|
(void)var;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testfun()
|
void testfun() { fun("fun" + OUString::number(200)); }
|
||||||
{
|
|
||||||
fun( "fun" + OUString::number( 200 ));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -1565,7 +1565,6 @@ compilerplugins/clang/dodgyswitch.cxx
|
|||||||
compilerplugins/clang/dyncastvisibility.cxx
|
compilerplugins/clang/dyncastvisibility.cxx
|
||||||
compilerplugins/clang/dynexcspec.cxx
|
compilerplugins/clang/dynexcspec.cxx
|
||||||
compilerplugins/clang/expandablemethods.cxx
|
compilerplugins/clang/expandablemethods.cxx
|
||||||
compilerplugins/clang/expressionalwayszero.cxx
|
|
||||||
compilerplugins/clang/externandnotdefined.cxx
|
compilerplugins/clang/externandnotdefined.cxx
|
||||||
compilerplugins/clang/faileddyncast.cxx
|
compilerplugins/clang/faileddyncast.cxx
|
||||||
compilerplugins/clang/fakebool.cxx
|
compilerplugins/clang/fakebool.cxx
|
||||||
@@ -1620,7 +1619,6 @@ compilerplugins/clang/store/bodynotinblock.cxx
|
|||||||
compilerplugins/clang/store/bodynotinblock.hxx
|
compilerplugins/clang/store/bodynotinblock.hxx
|
||||||
compilerplugins/clang/store/cascadingassignop.cxx
|
compilerplugins/clang/store/cascadingassignop.cxx
|
||||||
compilerplugins/clang/store/cascadingassignop.hxx
|
compilerplugins/clang/store/cascadingassignop.hxx
|
||||||
compilerplugins/clang/store/cascadingcondop.cxx
|
|
||||||
compilerplugins/clang/store/cascadingcondop.hxx
|
compilerplugins/clang/store/cascadingcondop.hxx
|
||||||
compilerplugins/clang/store/changefunctioncalls.cxx
|
compilerplugins/clang/store/changefunctioncalls.cxx
|
||||||
compilerplugins/clang/store/constantfunction.cxx
|
compilerplugins/clang/store/constantfunction.cxx
|
||||||
@@ -1647,7 +1645,6 @@ compilerplugins/clang/store/sfxitemsetrewrite.cxx
|
|||||||
compilerplugins/clang/store/stdexception.cxx
|
compilerplugins/clang/store/stdexception.cxx
|
||||||
compilerplugins/clang/store/stylepolice.cxx
|
compilerplugins/clang/store/stylepolice.cxx
|
||||||
compilerplugins/clang/store/svstreamoutputoperators.cxx
|
compilerplugins/clang/store/svstreamoutputoperators.cxx
|
||||||
compilerplugins/clang/store/test/deadclass.cxx
|
|
||||||
compilerplugins/clang/store/tutorial/tutorial1.cxx
|
compilerplugins/clang/store/tutorial/tutorial1.cxx
|
||||||
compilerplugins/clang/store/tutorial/tutorial1.hxx
|
compilerplugins/clang/store/tutorial/tutorial1.hxx
|
||||||
compilerplugins/clang/store/tutorial/tutorial1_example.cxx
|
compilerplugins/clang/store/tutorial/tutorial1_example.cxx
|
||||||
@@ -1671,10 +1668,8 @@ compilerplugins/clang/test/constmethod.cxx
|
|||||||
compilerplugins/clang/test/constparams.cxx
|
compilerplugins/clang/test/constparams.cxx
|
||||||
compilerplugins/clang/test/cppunitassertequals.cxx
|
compilerplugins/clang/test/cppunitassertequals.cxx
|
||||||
compilerplugins/clang/test/cppunitassertequals.hxx
|
compilerplugins/clang/test/cppunitassertequals.hxx
|
||||||
compilerplugins/clang/test/datamembershadow.cxx
|
|
||||||
compilerplugins/clang/test/dodgyswitch.cxx
|
compilerplugins/clang/test/dodgyswitch.cxx
|
||||||
compilerplugins/clang/test/expressionalwayszero.cxx
|
compilerplugins/clang/test/expressionalwayszero.cxx
|
||||||
compilerplugins/clang/test/external.hxx
|
|
||||||
compilerplugins/clang/test/faileddyncast.cxx
|
compilerplugins/clang/test/faileddyncast.cxx
|
||||||
compilerplugins/clang/test/fakebool.cxx
|
compilerplugins/clang/test/fakebool.cxx
|
||||||
compilerplugins/clang/test/finalprotected.cxx
|
compilerplugins/clang/test/finalprotected.cxx
|
||||||
@@ -1683,18 +1678,15 @@ compilerplugins/clang/test/indentation.cxx
|
|||||||
compilerplugins/clang/test/loopvartoosmall.cxx
|
compilerplugins/clang/test/loopvartoosmall.cxx
|
||||||
compilerplugins/clang/test/namespaceindentation.cxx
|
compilerplugins/clang/test/namespaceindentation.cxx
|
||||||
compilerplugins/clang/test/oncevar.cxx
|
compilerplugins/clang/test/oncevar.cxx
|
||||||
compilerplugins/clang/test/oslendian-1.cxx
|
|
||||||
compilerplugins/clang/test/oslendian-2.cxx
|
compilerplugins/clang/test/oslendian-2.cxx
|
||||||
compilerplugins/clang/test/oslendian-3.cxx
|
compilerplugins/clang/test/oslendian-3.cxx
|
||||||
compilerplugins/clang/test/passparamsbyref.cxx
|
compilerplugins/clang/test/passparamsbyref.cxx
|
||||||
compilerplugins/clang/test/passstuffbyref.cxx
|
compilerplugins/clang/test/passstuffbyref.cxx
|
||||||
compilerplugins/clang/test/redundantcast.cxx
|
compilerplugins/clang/test/redundantcast.cxx
|
||||||
compilerplugins/clang/test/redundantcast.hxx
|
|
||||||
compilerplugins/clang/test/redundantinline.cxx
|
compilerplugins/clang/test/redundantinline.cxx
|
||||||
compilerplugins/clang/test/redundantinline.hxx
|
compilerplugins/clang/test/redundantinline.hxx
|
||||||
compilerplugins/clang/test/redundantpointerops.cxx
|
compilerplugins/clang/test/redundantpointerops.cxx
|
||||||
compilerplugins/clang/test/salunicodeliteral.cxx
|
compilerplugins/clang/test/salunicodeliteral.cxx
|
||||||
compilerplugins/clang/test/stringconcatauto.cxx
|
|
||||||
compilerplugins/clang/test/stringconstant.cxx
|
compilerplugins/clang/test/stringconstant.cxx
|
||||||
compilerplugins/clang/test/unnecessarycatchthrow.cxx
|
compilerplugins/clang/test/unnecessarycatchthrow.cxx
|
||||||
compilerplugins/clang/test/unnecessaryoverride-dtor.cxx
|
compilerplugins/clang/test/unnecessaryoverride-dtor.cxx
|
||||||
|
Reference in New Issue
Block a user