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),
|
loadAverage(0),
|
||||||
maxConfigs(12),
|
maxConfigs(12),
|
||||||
maxCtuDepth(2),
|
maxCtuDepth(2),
|
||||||
|
maxTemplateRecursion(100),
|
||||||
preprocessOnly(false),
|
preprocessOnly(false),
|
||||||
quiet(false),
|
quiet(false),
|
||||||
relativePaths(false),
|
relativePaths(false),
|
||||||
|
|
|
@ -202,15 +202,18 @@ public:
|
||||||
Library library;
|
Library library;
|
||||||
|
|
||||||
/** @brief Load average value */
|
/** @brief Load average value */
|
||||||
unsigned int loadAverage;
|
int loadAverage;
|
||||||
|
|
||||||
/** @brief Maximum number of configurations to check before bailing.
|
/** @brief Maximum number of configurations to check before bailing.
|
||||||
Default is 12. (--max-configs=N) */
|
Default is 12. (--max-configs=N) */
|
||||||
unsigned int maxConfigs;
|
int maxConfigs;
|
||||||
|
|
||||||
/** @brief --max-ctu-depth */
|
/** @brief --max-ctu-depth */
|
||||||
int maxCtuDepth;
|
int maxCtuDepth;
|
||||||
|
|
||||||
|
/** @brief max template recursion */
|
||||||
|
int maxTemplateRecursion;
|
||||||
|
|
||||||
/** @brief suppress exitcode */
|
/** @brief suppress exitcode */
|
||||||
Suppressions nofail;
|
Suppressions nofail;
|
||||||
|
|
||||||
|
|
|
@ -2929,7 +2929,19 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
|
||||||
if (numberOfTemplateInstantiations != mTemplateInstantiations.size()) {
|
if (numberOfTemplateInstantiations != mTemplateInstantiations.size()) {
|
||||||
numberOfTemplateInstantiations = mTemplateInstantiations.size();
|
numberOfTemplateInstantiations = mTemplateInstantiations.size();
|
||||||
++recursiveCount;
|
++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..
|
// bail out..
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue