#6276 clang: -fsanitize=integer warnings. Fix unwanted integer overflow in TemplateSimplifier::useDefaultArgumentValues() and Tokenizer::simplifyQtSignalsSlots()

This commit is contained in:
Alexander Mai 2015-05-03 15:21:58 +02:00
parent 71cb8e9f64
commit 6f96634759
2 changed files with 7 additions and 5 deletions

View File

@ -569,9 +569,10 @@ void TemplateSimplifier::useDefaultArgumentValues(const std::list<Token *> &temp
if (tok->str() == ">") { if (tok->str() == ">") {
if (Token::Match(tok, "> class|struct %name%")) if (Token::Match(tok, "> class|struct %name%"))
classname = tok->strAt(2); classname = tok->strAt(2);
--templateParmDepth; if (templateParmDepth<2)
if (0 == templateParmDepth)
break; break;
else
--templateParmDepth;
} }
// next template parameter // next template parameter
@ -601,7 +602,7 @@ void TemplateSimplifier::useDefaultArgumentValues(const std::list<Token *> &temp
// count the parameters.. // count the parameters..
tok = tok->next(); tok = tok->next();
unsigned int usedpar = TemplateSimplifier::templateParameters(tok); const unsigned int usedpar = TemplateSimplifier::templateParameters(tok);
tok = tok->findClosingBracket(); tok = tok->findClosingBracket();
if (tok && tok->str() == ">") { if (tok && tok->str() == ">") {

View File

@ -9860,9 +9860,10 @@ void Tokenizer::simplifyQtSignalsSlots()
else else
tok2 = tok2->link(); tok2 = tok2->link();
} else if (tok2->str() == "}") { } else if (tok2->str() == "}") {
--indentlevel; if (indentlevel<2)
if (indentlevel == 0)
break; break;
else
--indentlevel;
} }
if (tok2->strAt(1) == "Q_OBJECT") { if (tok2->strAt(1) == "Q_OBJECT") {