Files
core/compilerplugins/clang/store/optvalue.cxx
Noel Grandin c6923103a2 move old/unused plugins to store
noting that I have only plugins that I wrote or worked on extensively

Change-Id: Ic4931a6ac2df7902cac3968900330a7ce4eb2d57
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136841
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-06 15:48:29 +02:00

67 lines
1.6 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* Based on LLVM/Clang.
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
*/
#include <cassert>
#include <string>
#include <iostream>
#include <fstream>
#include "config_clang.h"
#include "plugin.hxx"
#include "check.hxx"
/*
*/
namespace
{
class OptValue : public loplugin::FilteringPlugin<OptValue>
{
public:
explicit OptValue(loplugin::InstantiationData const& data)
: FilteringPlugin(data)
{
}
virtual bool preRun() override { return true; }
virtual void run() override
{
if (preRun())
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
}
bool VisitCXXMemberCallExpr(const CXXMemberCallExpr*);
};
bool OptValue::VisitCXXMemberCallExpr(const CXXMemberCallExpr* topExpr)
{
if (ignoreLocation(topExpr))
return true;
const CXXMethodDecl* methodDecl = topExpr->getMethodDecl();
if (!methodDecl)
return true;
if (!methodDecl->getIdentifier() || methodDecl->getName() != "value")
return true;
auto expr1 = topExpr->getImplicitObjectArgument()->IgnoreImpCasts();
if (!isa<MaterializeTemporaryExpr>(expr1))
return true;
report(DiagnosticsEngine::Warning, "call to OptValue::value()", topExpr->getBeginLoc());
return true;
}
loplugin::Plugin::Registration<OptValue> optvalue("optvalue", false);
} // namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */