template simplifier: fix another crash (#1774)

This fixes a daca crash in Vc-1.3.3/tests/casts.cpp.
This commit is contained in:
IOBYTE 2019-04-02 03:00:11 -04:00 committed by Daniel Marjamäki
parent b88cc7c19d
commit f5cb289b7d
1 changed files with 17 additions and 15 deletions

View File

@ -1448,21 +1448,23 @@ void TemplateSimplifier::expandTemplate(
if (start->strAt(1) == "<") { if (start->strAt(1) == "<") {
// get the instantiated name // get the instantiated name
Token * closing = start->next()->findClosingBracket(); Token * closing = start->next()->findClosingBracket();
std::string name; if (closing) {
const Token * type = start; std::string name;
while (type && type != closing->next()) { const Token * type = start;
if (!name.empty()) while (type && type != closing->next()) {
name += " "; if (!name.empty())
name += type->str(); name += " ";
type = type->next(); name += type->str();
} type = type->next();
// check if type is instantiated }
for (const auto & inst : mTemplateInstantiations) { // check if type is instantiated
if (Token::simpleMatch(inst.token, name.c_str())) { for (const auto & inst : mTemplateInstantiations) {
// use the instantiated name if (Token::simpleMatch(inst.token, name.c_str())) {
dst->insertToken(name, "", true); // use the instantiated name
start = closing; dst->insertToken(name, "", true);
break; start = closing;
break;
}
} }
} }
// just copy the token if it wasn't instantiated // just copy the token if it wasn't instantiated