lib: Separate statements of the form "assert(a && b)" into "assert(a)" and "assert(b)", for more precise diagnostics. (#1825)

This commit is contained in:
adamjrichter 2019-05-07 08:28:31 +00:00 committed by Daniel Marjamäki
parent 5364c6055f
commit 47ce998e6e
3 changed files with 10 additions and 5 deletions

View File

@ -993,7 +993,8 @@ void SymbolDatabase::createSymbolDatabaseSetScopePointers()
start = const_cast<Token*>(mTokenizer->list.front()); start = const_cast<Token*>(mTokenizer->list.front());
end = const_cast<Token*>(mTokenizer->list.back()); end = const_cast<Token*>(mTokenizer->list.back());
} }
assert(start && end); assert(start);
assert(end);
end->scope(&*it); end->scope(&*it);

View File

@ -1782,7 +1782,8 @@ void TemplateSimplifier::expandTemplate(
} else if (tok3->str() == "[") { } else if (tok3->str() == "[") {
brackets.push(mTokenList.back()); brackets.push(mTokenList.back());
} else if (tok3->str() == "}") { } else if (tok3->str() == "}") {
assert(brackets.empty() == false && brackets.top()->str() == "{"); assert(brackets.empty() == false);
assert(brackets.top()->str() == "{");
Token::createMutualLinks(brackets.top(), mTokenList.back()); Token::createMutualLinks(brackets.top(), mTokenList.back());
if (tok3->strAt(1) == ";") { if (tok3->strAt(1) == ";") {
const Token * tokSemicolon = tok3->next(); const Token * tokSemicolon = tok3->next();
@ -1794,11 +1795,13 @@ void TemplateSimplifier::expandTemplate(
break; break;
} }
} else if (tok3->str() == ")") { } else if (tok3->str() == ")") {
assert(brackets.empty() == false && brackets.top()->str() == "("); assert(brackets.empty() == false);
assert(brackets.top()->str() == "(");
Token::createMutualLinks(brackets.top(), mTokenList.back()); Token::createMutualLinks(brackets.top(), mTokenList.back());
brackets.pop(); brackets.pop();
} else if (tok3->str() == "]") { } else if (tok3->str() == "]") {
assert(brackets.empty() == false && brackets.top()->str() == "["); assert(brackets.empty() == false);
assert(brackets.top()->str() == "[");
Token::createMutualLinks(brackets.top(), mTokenList.back()); Token::createMutualLinks(brackets.top(), mTokenList.back());
brackets.pop(); brackets.pop();
} }

View File

@ -743,7 +743,8 @@ std::size_t Token::getStrLength(const Token *tok)
std::size_t Token::getStrSize(const Token *tok) std::size_t Token::getStrSize(const Token *tok)
{ {
assert(tok != nullptr && tok->tokType() == eString); assert(tok != nullptr);
assert(tok->tokType() == eString);
const std::string &str = tok->str(); const std::string &str = tok->str();
unsigned int sizeofstring = 1U; unsigned int sizeofstring = 1U;
for (unsigned int i = 1U; i < str.size() - 1U; i++) { for (unsigned int i = 1U; i < str.size() - 1U; i++) {