/* -*- 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/.
*/
bool VisitCXXMemberCallExpr(const CXXMemberCallExpr* memberCall)
{ if (ignoreLocation(memberCall)) returntrue; if (m_ignoreIfCondition == memberCall) returntrue; // check if we are calling a 'operator bool' conversion method auto conversionDecl = dyn_cast_or_null<CXXConversionDecl>(memberCall->getMethodDecl()); if (!conversionDecl || !conversionDecl->getConversionType()->isBooleanType()) returntrue; auto ctsd = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
memberCall->getObjectType()->getAsRecordDecl()); if (!ctsd || ctsd->getTemplateArgs().size() < 1) returntrue; if (ctsd->getName() != "optional") returntrue; if (!ctsd->getTemplateArgs().get(0).getAsType()->isBooleanType()) returntrue;
report(DiagnosticsEngine::Warning, "using conversion call to convert std::optional to bool probably does not do " "what you expect, rather use has_value() or value_or()",
memberCall->getBeginLoc())
<< memberCall->getSourceRange(); returntrue;
}
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.