@@ -1144,15 +1144,14 @@ void TemplateSimplifier::useDefaultArgumentValues(TokenAndName &declaration)
11441144 while (it != eq.cend ()) {
11451145 // check for end
11461146 if (!it->end ) {
1147- if (mSettings .debugwarnings ) {
1147+ if (mSettings .debugwarnings && mErrorLogger && mSettings . severity . isEnabled (Severity::debug) ) {
11481148 const std::list<const Token*> locationList (1 , it->eq );
11491149 const ErrorMessage errmsg (locationList, &mTokenizer .list ,
11501150 Severity::debug,
11511151 " noparamend" ,
11521152 " TemplateSimplifier couldn't find end of template parameter." ,
11531153 Certainty::normal);
1154- if (mErrorLogger && mSettings .severity .isEnabled (Severity::debug))
1155- mErrorLogger ->reportErr (errmsg);
1154+ mErrorLogger ->reportErr (errmsg);
11561155 }
11571156 break ;
11581157 }
@@ -3045,20 +3044,21 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
30453044 numberOfTemplateInstantiations = mTemplateInstantiations .size ();
30463045 ++recursiveCount;
30473046 if (recursiveCount > mSettings .maxTemplateRecursion ) {
3048- std::list<std::string> typeStringsUsedInTemplateInstantiation;
3049- const std::string typeForNewName = templateDeclaration. name () + " < " + getNewName (instantiation. token (), typeStringsUsedInTemplateInstantiation) + " > " ;
3050-
3051- const std::list< const Token *> callstack ( 1 , instantiation. token ());
3052- const ErrorMessage errmsg ( callstack,
3053- & mTokenizer . list ,
3054- Severity::information ,
3055- " templateRecursion " ,
3056- " TemplateSimplifier: max template recursion ( "
3057- + MathLib::toString ( mSettings . maxTemplateRecursion )
3058- + " ) reached for template ' " +typeForNewName+ " '. You might want to limit Cppcheck recursion. " ,
3059- Certainty::normal);
3060- if ( mErrorLogger && mSettings . severity . isEnabled (Severity::information))
3047+ if ( mErrorLogger && mSettings . severity . isEnabled (Severity::information)) {
3048+ std::list<std:: string> typeStringsUsedInTemplateInstantiation;
3049+ const std::string typeForNewName = templateDeclaration. name () + " < " + getNewName (instantiation. token (), typeStringsUsedInTemplateInstantiation) + " > " ;
3050+
3051+ const std::list< const Token *> callstack ( 1 , instantiation. token ());
3052+ const ErrorMessage errmsg (callstack ,
3053+ & mTokenizer . list ,
3054+ Severity::information ,
3055+ " templateRecursion " ,
3056+ " TemplateSimplifier: max template recursion ( "
3057+ + MathLib::toString ( mSettings . maxTemplateRecursion )
3058+ + " ) reached for template ' " +typeForNewName+ " '. You might want to limit Cppcheck recursion. " ,
3059+ Certainty::normal);
30613060 mErrorLogger ->reportErr (errmsg);
3061+ }
30623062
30633063 // bail out..
30643064 break ;
@@ -3896,15 +3896,14 @@ void TemplateSimplifier::simplifyTemplates(
38963896 }
38973897
38983898 if (passCount == passCountMax) {
3899- if (mSettings .debugwarnings ) {
3899+ if (mSettings .debugwarnings && mErrorLogger ) {
39003900 const std::list<const Token*> locationList (1 , mTokenList .front ());
39013901 const ErrorMessage errmsg (locationList, &mTokenizer .list ,
39023902 Severity::debug,
39033903 " debug" ,
39043904 " TemplateSimplifier: pass count limit hit before simplifications were finished." ,
39053905 Certainty::normal);
3906- if (mErrorLogger )
3907- mErrorLogger ->reportErr (errmsg);
3906+ mErrorLogger ->reportErr (errmsg);
39083907 }
39093908 }
39103909
0 commit comments