/* -*- 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: */ ro/collabora/co-24.04.13 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2017-08-24loplugin:constparam in sc part3Noel Grandin
2017-05-23drop the SCsROW/SCsCOL/SCsTAB typedefsNoel Grandin
2016-09-13loplugin:override: No more need for the "MSVC dtor override" workaroundStephan Bergmann
2016-08-29loplugin:countusersofdefaultparamsNoel Grandin
2016-08-16loplugin:unusedenumvalues in scNoel Grandin
2015-10-28com::sun::star->css in scNoel Grandin
2015-10-12Replace "SAL_OVERRIDE" with "override" in LIBO_INTERNAL_ONLY codeStephan Bergmann
2015-09-18boost->stdCaolán McNamara
2015-09-17revert for mac and win unit case crashes after boost->stdCaolán McNamara
2015-09-17boost->stdCaolán McNamara
2015-02-07loplugin:deletedspecialStephan Bergmann
2014-08-16use scoped_ptr instead of shared_ptrMarkus Mohrhard
2014-06-25remove whitespaceMarkus Mohrhard
2014-05-11fix-includes.pl: scThomas Arnhold
2014-04-19fixincludeguards.sh: scThomas Arnhold
2014-04-08also check if a newly read password protection applies to a rangeEike Rathke
2014-04-08read the defined password attributesEike Rathke
2014-04-08hold security descriptors read from OOXML independentlyEike Rathke
2014-03-27Second batch of adding SAL_OVERRIDE to overriding function declarationsStephan Bergmann
2014-03-22added editable testers to enhanced table protectionEike Rathke
2014-03-20added ScEnhancedProtection to ScTableProtectionEike Rathke
2013-10-04convert sc/inc/t*.hxx from String to OUStringNoel Grandin
2013-08-31fdo#62475 removed pointless commentsJelle van der Waa
2013-07-04Modifying comments to meet Doxygen standardsAlaa.Bukhari
2013-04-07mass removal of rtl:: prefixes for O(U)String*Luboš Luňák