@@ -1144,15 +1144,14 @@ void TemplateSimplifier::useDefaultArgumentValues(TokenAndName &declaration)
1144
1144
while (it != eq.cend ()) {
1145
1145
// check for end
1146
1146
if (!it->end ) {
1147
- if (mSettings .debugwarnings ) {
1147
+ if (mSettings .debugwarnings && mErrorLogger && mSettings . severity . isEnabled (Severity::debug) ) {
1148
1148
const std::list<const Token*> locationList (1 , it->eq );
1149
1149
const ErrorMessage errmsg (locationList, &mTokenizer .list ,
1150
1150
Severity::debug,
1151
1151
" noparamend" ,
1152
1152
" TemplateSimplifier couldn't find end of template parameter." ,
1153
1153
Certainty::normal);
1154
- if (mErrorLogger && mSettings .severity .isEnabled (Severity::debug))
1155
- mErrorLogger ->reportErr (errmsg);
1154
+ mErrorLogger ->reportErr (errmsg);
1156
1155
}
1157
1156
break ;
1158
1157
}
@@ -3045,20 +3044,21 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
3045
3044
numberOfTemplateInstantiations = mTemplateInstantiations .size ();
3046
3045
++recursiveCount;
3047
3046
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);
3061
3060
mErrorLogger ->reportErr (errmsg);
3061
+ }
3062
3062
3063
3063
// bail out..
3064
3064
break ;
@@ -3896,15 +3896,14 @@ void TemplateSimplifier::simplifyTemplates(
3896
3896
}
3897
3897
3898
3898
if (passCount == passCountMax) {
3899
- if (mSettings .debugwarnings ) {
3899
+ if (mSettings .debugwarnings && mErrorLogger ) {
3900
3900
const std::list<const Token*> locationList (1 , mTokenList .front ());
3901
3901
const ErrorMessage errmsg (locationList, &mTokenizer .list ,
3902
3902
Severity::debug,
3903
3903
" debug" ,
3904
3904
" TemplateSimplifier: pass count limit hit before simplifications were finished." ,
3905
3905
Certainty::normal);
3906
- if (mErrorLogger )
3907
- mErrorLogger ->reportErr (errmsg);
3906
+ mErrorLogger ->reportErr (errmsg);
3908
3907
}
3909
3908
}
3910
3909
0 commit comments