1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
7 * This file is distributed under the University of Illinois Open Source
8 * License. See LICENSE.TXT for details.
16 #include "config_clang.h"
25 class OptValue
: public loplugin::FilteringPlugin
<OptValue
>
28 explicit OptValue(loplugin::InstantiationData
const& data
)
29 : FilteringPlugin(data
)
33 virtual bool preRun() override
{ return true; }
35 virtual void run() override
38 TraverseDecl(compiler
.getASTContext().getTranslationUnitDecl());
41 bool VisitCXXMemberCallExpr(const CXXMemberCallExpr
*);
44 bool OptValue::VisitCXXMemberCallExpr(const CXXMemberCallExpr
* topExpr
)
46 if (ignoreLocation(topExpr
))
48 const CXXMethodDecl
* methodDecl
= topExpr
->getMethodDecl();
51 if (!methodDecl
->getIdentifier() || methodDecl
->getName() != "value")
53 auto expr1
= topExpr
->getImplicitObjectArgument()->IgnoreImpCasts();
54 if (!isa
<MaterializeTemporaryExpr
>(expr1
))
57 report(DiagnosticsEngine::Warning
, "call to OptValue::value()", topExpr
->getBeginLoc());
62 loplugin::Plugin::Registration
<OptValue
> optvalue("optvalue", false);
66 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */