/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "check.hxx" #include "plugin.hxx" class UnoAny: public RecursiveASTVisitor, public loplugin::Plugin { public: explicit UnoAny(InstantiationData const & data): Plugin(data) {} void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr); }; bool UnoAny::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr) { if (ignoreLocation(expr)) { return true; } StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(expr->getLocStart())); if (loplugin::isSamePathname(aFileName, SRCDIR "/include/com/sun/star/uno/Any.hxx")) { return true; } if (expr->getOperator() != OO_Equal) { return true; } if (!loplugin::TypeCheck(expr->getArg(0)->getType()).Class("Any"). Namespace("uno").Namespace("star").Namespace("sun").Namespace("com").GlobalNamespace()) { return true; } if (auto expr2 = dyn_cast(expr->getArg(1))) { if (auto expr3 = dyn_cast(expr2->GetTemporaryExpr())) { if (auto expr4 = dyn_cast(expr3->getSubExpr())) { if (loplugin::DeclCheck(expr4->getDirectCallee()).Function("makeAny"). Namespace("uno").Namespace("star").Namespace("sun").Namespace("com").GlobalNamespace()) { report( DiagnosticsEngine::Warning, "unnecessary copy, rather use <<= operator", expr->getOperatorLoc()) << expr->getSourceRange(); return true; } } } if (isa(expr2->GetTemporaryExpr())) { //expr->getArg(1)->dump(); report( DiagnosticsEngine::Warning, "unnecessary copy, rather use <<= operator", expr->getOperatorLoc()) << expr->getSourceRange(); return true; } } //expr->getArg(1)->dump(); return true; } loplugin::Plugin::Registration X("unoany"); /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ >distro/collabora/co-24.04.3 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2013-01-03writerfilter: remove Junit complex testMichael Stahl
2012-12-25Get rid of (most uses of) GUITor Lillqvist
2012-12-18Replace GUIBASE checks with equivalent OS checksTor Lillqvist
2012-11-24fdo#51304 Remove @author annotationJosé Guilherme Vanz
2012-11-01rework filters test to squeeze through extra flagsCaolán McNamara
2012-10-23RtfFilter::filter: not allowed to throw WrongFormatException:Michael Stahl
2012-10-23fdo#51145 give better error message on import invalid RTFMiklos Vajna
2012-09-17targetted make reversion.Bjoern Michaelsen
2012-09-14Improvement on previous commit, UCB clean upStephan Bergmann
2012-09-06Java cleanup, remove unnecessary importsNoel Grandin
2012-07-31various rtf regression testsCaolán McNamara
2012-07-26writerfilter/qa: clean up rtl:: and RTL_CONSTASCII_* usageMiklos Vajna
2012-07-21writerfilter: rtl::OUString -> OUStringMiklos Vajna
2012-07-02writerfilter is now RTL_CONSTASCII..PARAM-freeMiklos Vajna
2012-06-28re-base on ALv2 code. Includes:Michael Meeks
2012-06-27targetted re-work of cppunit pieces.Michael Meeks
2012-06-21re-base on ALv2 code.Michael Meeks
2012-06-21re-base on ALv2 code.Michael Meeks
2012-06-02targeted string re-workNorbert Thiebaud
2012-06-02targeted string re-workNorbert Thiebaud
2012-05-14Add helpful instructions nearby encrypted CVE files.Michael Meeks
2012-03-06use a consistent naming schemeCaolán McNamara
2012-02-19Get rid of size() == 0Elton Chung
2012-01-18writerfilter: drop exec bit on non-script filesMiklos Vajna
2012-01-11fix prefix of command line switches (-- instead of -)Andras Timar
2012-01-09catch exception by constant referenceTakeshi Abe