for (auto& pair : problemFunctions)
{ auto functionDecl = pair.first; auto canonicalDecl = functionDecl->getCanonicalDecl(); if (getFunctionsWithAddressTaken().find(canonicalDecl)
!= getFunctionsWithAddressTaken().end()) continue;
report(DiagnosticsEngine::Warning, "Method only returns a single constant value %0, does it make sense?",
functionDecl->getBeginLoc())
<< pair.second << functionDecl->getSourceRange(); if (functionDecl != functionDecl->getCanonicalDecl())
report(DiagnosticsEngine::Note, "decl here",
functionDecl->getCanonicalDecl()->getBeginLoc())
<< functionDecl->getCanonicalDecl()->getSourceRange();
}
}
bool ReturnConstant::TraverseCXXMethodDecl(CXXMethodDecl* functionDecl)
{ if (ignoreLocation(functionDecl)) returntrue; if (isInUnoIncludeFile(functionDecl)) returntrue;
if (!functionDecl->hasBody()) returntrue; if (!functionDecl->isThisDeclarationADefinition()) returntrue; if (functionDecl->isConstexpr()) returntrue; if (functionDecl->getReturnType()->isVoidType()) returntrue; if (functionDecl->isVirtual()) returntrue; // static with inline body will be optimised at compile-time to a constant anyway if (functionDecl->isStatic()
&& (functionDecl->hasInlineBody() || functionDecl->isInlineSpecified())) returntrue; // this catches some stuff in templates if (functionDecl->hasAttr<OverrideAttr>()) returntrue;
// include/unotools/localedatawrapper.hxx if (functionDecl->getIdentifier() && functionDecl->getName() == "getCurrZeroChar") returntrue; // sc/inc/stlalgorithm.hxx if (loplugin::DeclCheck(functionDecl->getParent())
.Class("AlignedAllocator")
.Namespace("sc")
.GlobalNamespace()) returntrue;
switch (functionDecl->getOverloadedOperator())
{ case OO_Delete: case OO_EqualEqual: case OO_Call: returntrue; default: break;
}
// gtk signals and slots stuff if (loplugin::TypeCheck(functionDecl->getReturnType()).Typedef("gboolean")) 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.