/* -*- 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/. */ #ifndef LO_CLANG_SHARED_PLUGINS #include "config_clang.h" #include "check.hxx" #include "plugin.hxx" namespace { class UnoAny: public loplugin::FilteringPlugin { public: explicit UnoAny(loplugin::InstantiationData const & data): FilteringPlugin(data) {} bool preRun() override { return compiler.getLangOpts().CPlusPlus; } void run() override { if (preRun()) { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } } bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr); }; bool UnoAny::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const * expr) { if (ignoreLocation(expr)) { return true; } StringRef aFileName = getFilenameOfLocation( compiler.getSourceManager().getSpellingLoc(expr->getBeginLoc())); 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->getSubExpr())) { 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 directly with the 'makeAny'" " argument"), expr->getOperatorLoc()) << expr->getSourceRange(); return true; } } } if (isa(expr2->getSubExpr())) { //expr->getArg(1)->dump(); report( DiagnosticsEngine::Warning, ("unnecessary copy, rather use <<= operator directly with the 'Any' constructor" " argument"), expr->getOperatorLoc()) << expr->getSourceRange(); return true; } } //expr->getArg(1)->dump(); return true; } loplugin::Plugin::Registration unoany("unoany"); } // namespace #endif // LO_CLANG_SHARED_PLUGINS /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ ='distro/collabora/co-24.04.5'>distro/collabora/co-24.04.5 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2018-04-12sw: fix some IWYU warningsMiklos Vajna
2018-03-28sw: fix some IWYU warningsMiklos Vajna
2018-02-28Fix some IWYU warningsMiklos Vajna
2018-02-26RES_CHRATR_SHADOW should be SvxShadowItemMike Kaganski
2018-02-21Fix some IWYU warningsMiklos Vajna
2018-01-09RES_CHRATR_PROPORTIONALFONTSIZE and RES_CHRATR_NOLINEBREAK unusedNoel Grandin
2017-12-24convert RES_FRM constants to TypedWhichIdNoel Grandin
2017-12-20convert RES_FMT constants to TypedWhichIdNoel Grandin
2017-12-13TypedWhichId in sw (TXTATTR)Noel Grandin
2017-12-12remove some dead message constantsNoel Grandin
2017-12-12TypeWhichId in swNoel Grandin
2017-11-30TypedWhichId for RES_PARAATR constantsNoel Grandin
2017-11-24TypedWhichId for RES_CHRATR constantsNoel Grandin
2017-04-28loplugin:salunicodeliteral: swStephan Bergmann
2017-03-14remove noise UUUU tags in commentsNoel Grandin
2017-03-04sw: remove unused id RES_TXTATR_FLDCHGMichael Stahl
2017-02-08remove unused constants from RES_MSGNoel Grandin
2016-12-26use std::vector instead of naked array in SfxItemPoolNoel Grandin
2016-11-29get rid of LegacyModifyHintBjoern Michaelsen
2015-12-08sw: add RES_FLTR_RDFMARKMiklos Vajna