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) == "<") {
// get the instantiated name
Token * closing = start->next()->findClosingBracket();
std::string name;
const Token * type = start;
while (type && type != closing->next()) {
if (!name.empty())
name += " ";
name += type->str();
type = type->next();
}
// check if type is instantiated
for (const auto & inst : mTemplateInstantiations) {
if (Token::simpleMatch(inst.token, name.c_str())) {
// use the instantiated name
dst->insertToken(name, "", true);
start = closing;
break;
if (closing) {
std::string name;
const Token * type = start;
while (type && type != closing->next()) {
if (!name.empty())
name += " ";
name += type->str();
type = type->next();
}
// check if type is instantiated
for (const auto & inst : mTemplateInstantiations) {
if (Token::simpleMatch(inst.token, name.c_str())) {
// use the instantiated name
dst->insertToken(name, "", true);
start = closing;
break;
}
}
}
// just copy the token if it wasn't instantiated