/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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/.
*/
// pimpl pattern if (loplugin::isSamePathname(fileName, SRCDIR "/include/unotools/closeveto.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/include/svl/svdde.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/include/vcl/toolkit/morebtn.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/include/vcl/toolkit/morebtn.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/include/xmloff/xmlexp.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/include/xmloff/txtparae.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/include/xmloff/controlpropertyhdl.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/cui/source/inc/cuitabarea.hxx")) returntrue;
// std::type_info is not movable or copyable if (loplugin::isSamePathname(fileName,
SRCDIR "/bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.cxx")) returntrue;
// TODO not sure what is going on here, get a compile error if (loplugin::isSamePathname(fileName, SRCDIR "/vcl/inc/unx/printerjob.hxx")) returntrue;
// Seems in bad taste to modify these if (loplugin::isSamePathname(fileName, SRCDIR "/cui/source/tabpages/macroass.cxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/cui/source/inc/cuitabline.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/cui/source/inc/page.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sd/source/ui/sidebar/SlideBackground.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/hwpfilter/source/nodes.h")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/hwpfilter/source/hwpfile.h")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sw/source/uibase/inc/bookmark.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sw/inc/viewsh.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sw/source/uibase/sidebar/PageFormatPanel.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sw/source/uibase/sidebar/PageStylesPanel.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sc/inc/dpsave.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sc/source/ui/inc/dpgroupdlg.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sc/source/ui/inc/pvfundlg.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sc/inc/document.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sc/inc/scmod.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/include/svx/gallery1.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/svx/inc/textchainflow.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/include/svx/graphctl.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/include/svx/float3d.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/dbaccess/source/ui/dlg/generalpage.hxx")) returntrue; if (loplugin::isSamePathname(fileName,
SRCDIR "/extensions/source/propctrlr/cellbindinghandler.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sc/inc/chartlis.hxx")) returntrue;
// header ordering issues make this hard to change if (loplugin::isSamePathname(fileName, SRCDIR "/lotuswordpro/source/filter/lwpdlvlist.hxx")) returntrue;
// the classes being allocate are ref-counted if (loplugin::isSamePathname(fileName, SRCDIR "/sc/source/filter/inc/xeextlst.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sc/source/filter/inc/xestyle.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sc/source/ui/inc/tpcalc.hxx")) returntrue;
// not sure if (fileName.contains("QtInstance.hxx")) // "/vcl/inc/qt5/QtInstance.hxx")) returntrue;
// class is defined inside the module, typically some kind of child/pimpl/listener thing if (loplugin::isSamePathname(fileName, SRCDIR "/include/sfx2/viewfrm.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/include/svx/linectrl.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/include/svx/sidebar/LinePropertyPanelBase.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/vcl/source/fontsubset/ttcr.hxx")) returntrue; if (loplugin::isSamePathname(fileName,
SRCDIR "/extensions/source/propctrlr/defaultforminspection.hxx")) returntrue; if (loplugin::isSamePathname(fileName,
SRCDIR "/extensions/source/propctrlr/propertyhandler.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sc/inc/spellcheckcontext.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sw/source/core/inc/layouter.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sw/source/uibase/inc/numberingtypelistbox.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/lotuswordpro/inc/xfilter/xfdrawstyle.hxx")) returntrue; if (loplugin::isSamePathname(fileName, SRCDIR "/sc/source/ui/inc/scuiimoptdlg.hxx")) returntrue;
// One of the constructors initialises the field by receiving an unique_ptr if (loplugin::isSamePathname(fileName,
SRCDIR "/lotuswordpro/source/filter/lwpbreaksoverride.hxx")) returntrue; if (loplugin::isSamePathname(fileName,
SRCDIR "/lotuswordpro/source/filter/lwpcharborderoverride.hxx")) returntrue; if (loplugin::isSamePathname(fileName,
SRCDIR "/lotuswordpro/source/filter/lwpparaborderoverride.hxx")) returntrue;
if (!loplugin::TypeCheck(fieldDecl->getType()).ClassOrStruct("unique_ptr").StdNamespace()) returntrue;
auto templateDecl = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
fieldDecl->getType()->getAsRecordDecl()); if (!templateDecl) returntrue; if (templateDecl->getTemplateArgs().size() == 0) returntrue; auto firstTemplateParamType = templateDecl->getTemplateArgs()[0].getAsType(); if (!isSmall(firstTemplateParamType)) returntrue; auto paramRecordDecl = firstTemplateParamType->getAsCXXRecordDecl(); if (paramRecordDecl)
{ // if the pointed-to type has a virtual destructor, then we don't know for sure // what size type will be stored there if (!paramRecordDecl->isEffectivelyFinal()) if (CXXDestructorDecl* dd = paramRecordDecl->getDestructor()) if (dd->isVirtual()) returntrue; // If it doesn't have a move constructor, then it would be hard to assign into it // TODO this condition could be relaxed in some situations if (!paramRecordDecl->hasMoveConstructor()) returntrue; // the weld stuff needs to be heap allocated if (loplugin::DeclCheck(paramRecordDecl).Class("CustomWeld").Namespace("weld")) returntrue; // ref-counted classes should be heap allocated if (loplugin::DeclCheck(paramRecordDecl).Class("SvxContourItem")) returntrue; if (loplugin::DeclCheck(paramRecordDecl).Class("SvxAdjustItem")) returntrue; if (loplugin::DeclCheck(paramRecordDecl).Class("SwFormatNoBalancedColumns")) returntrue; if (loplugin::DeclCheck(paramRecordDecl).Class("SwFormatFollowTextFlow")) returntrue;
} // ignore pimpl pattern if (fieldDecl->getName().contains("pImpl")) returntrue; if (fieldDecl->getName().contains("impl_")) returntrue; if (fieldDecl->getName().contains("mxImpl")) returntrue; if (fieldDecl->getName().contains("m_aImpl")) returntrue;
report(DiagnosticsEngine::Warning, "can use std::optional here, heap-stored type is very small",
fieldDecl->getLocation())
<< fieldDecl->getSourceRange(); if (paramRecordDecl)
report(DiagnosticsEngine::Note, "class being allocated is here",
paramRecordDecl->getLocation())
<< paramRecordDecl->getSourceRange(); returntrue;
}
bool Unique2Optional::isSmall(QualType type)
{ if (type->isIncompleteType()) returnfalse;
clang::Type const* t2 = type.getTypePtrOrNull(); if (!t2) returnfalse; // 8 bytes == 1 pointer on 64-bit CPU return compiler.getASTContext().getTypeSizeInChars(t2).getQuantity() <= 16;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.