Template simplifier; Write information message when recursion limit is reached.
This commit is contained in:
parent
fdb8cbdb8c
commit
34468f3c1a
|
@ -57,6 +57,7 @@ Settings::Settings()
|
|||
loadAverage(0),
|
||||
maxConfigs(12),
|
||||
maxCtuDepth(2),
|
||||
maxTemplateRecursion(100),
|
||||
preprocessOnly(false),
|
||||
quiet(false),
|
||||
relativePaths(false),
|
||||
|
|
|
@ -202,15 +202,18 @@ public:
|
|||
Library library;
|
||||
|
||||
/** @brief Load average value */
|
||||
unsigned int loadAverage;
|
||||
int loadAverage;
|
||||
|
||||
/** @brief Maximum number of configurations to check before bailing.
|
||||
Default is 12. (--max-configs=N) */
|
||||
unsigned int maxConfigs;
|
||||
int maxConfigs;
|
||||
|
||||
/** @brief --max-ctu-depth */
|
||||
int maxCtuDepth;
|
||||
|
||||
/** @brief max template recursion */
|
||||
int maxTemplateRecursion;
|
||||
|
||||
/** @brief suppress exitcode */
|
||||
Suppressions nofail;
|
||||
|
||||
|
|
|
@ -2929,7 +2929,19 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
|
|||
if (numberOfTemplateInstantiations != mTemplateInstantiations.size()) {
|
||||
numberOfTemplateInstantiations = mTemplateInstantiations.size();
|
||||
++recursiveCount;
|
||||
if (recursiveCount > 100) {
|
||||
if (recursiveCount > mSettings->maxTemplateRecursion) {
|
||||
const std::list<const Token *> callstack(1, instantiation.token());
|
||||
const ErrorMessage errmsg(callstack,
|
||||
&mTokenizer->list,
|
||||
Severity::information,
|
||||
"templateRecursion",
|
||||
"TemplateSimplifier: max template recursion ("
|
||||
+ MathLib::toString(mSettings->maxTemplateRecursion)
|
||||
+ ") reached for template '"+instantiation.fullName()+"'. You might want to limit Cppcheck recursion.",
|
||||
false);
|
||||
if (mErrorLogger && mSettings->isEnabled(Settings::INFORMATION))
|
||||
mErrorLogger->reportErr(errmsg);
|
||||
|
||||
// bail out..
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue