/* -*- 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/.
*/
bool TrivialConstructor::VisitCXXConstructorDecl(CXXConstructorDecl const* constructorDecl)
{ if (ignoreLocation(constructorDecl)) returntrue; if (!constructorDecl->hasTrivialBody()) returntrue; if (constructorDecl->isExplicit()) returntrue; if (!constructorDecl->isDefaultConstructor()) returntrue; if (constructorDecl->getNumParams() != 0) returntrue; if (!constructorDecl->inits().empty()) returntrue; if (constructorDecl->getExceptionSpecType() != EST_None) returntrue; if (constructorDecl->getAccess() != AS_public) returntrue; if (!constructorDecl->isThisDeclarationADefinition()) returntrue; if (isInUnoIncludeFile(
compiler.getSourceManager().getSpellingLoc(constructorDecl->getLocation()))) returntrue; const CXXRecordDecl* recordDecl = constructorDecl->getParent(); if (std::distance(recordDecl->ctor_begin(), recordDecl->ctor_end()) != 1) returntrue; // Constructor templates are not included in ctor_begin()..ctor_end() above, so also do a slow // check across all decls(): for (auto d : recordDecl->decls())
{ if (autoconst d2 = dyn_cast<FunctionTemplateDecl>(d))
{ if (isa<CXXConstructorDecl>(d2->getTemplatedDecl()))
{ returntrue;
}
}
} if (!HasTrivialConstructorBody(recordDecl, recordDecl)) returntrue;
report(DiagnosticsEngine::Warning, "no need for explicit constructor decl",
constructorDecl->getLocation())
<< constructorDecl->getSourceRange(); if (constructorDecl->getCanonicalDecl() != constructorDecl)
{
constructorDecl = constructorDecl->getCanonicalDecl();
report(DiagnosticsEngine::Warning, "no need for explicit constructor decl",
constructorDecl->getLocation())
<< constructorDecl->getSourceRange();
} returntrue;
}
// The constructor for an implicit anonymous union member is never invoked. if (FieldClassDecl->isUnion() && FieldClassDecl->isAnonymousStructOrUnion()) returnfalse;
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.