Fixed use-after-free in clang test suite introduced recently (#7087)

This commit is contained in:
PKEuS 2015-11-03 19:23:45 +01:00
parent b97f9e576d
commit 8374e8414b
3 changed files with 12 additions and 6 deletions

View File

@ -9294,7 +9294,9 @@ void Tokenizer::simplifyAsm2()
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (Token::simpleMatch(tok, "^ {")) {
Token * start = tok;
while (start && !Token::Match(start, "[;{})=]")) {
while (start && !Token::Match(start, "[;{}=]")) {
if (start->link() && start->str() == ")")
start = start->link();
start = start->previous();
}
if (start)
@ -9302,8 +9304,11 @@ void Tokenizer::simplifyAsm2()
const Token *last = tok->next()->link();
if (start != tok) {
last = last->next();
while (last && !Token::Match(last->next(), "[;{})]"))
while (last && !Token::Match(last, "[;{})]")) {
last = last->next();
if (last && last->link() && last->str() == "(")
last = last->link()->next();
}
if (last)
last = last->next();
}

View File

@ -657,8 +657,8 @@ private:
}
void garbageCode58() { // #6732, #6762
checkCode("{ }> {= ~A()^{} }P { }");
checkCode("{= ~A()^{} }P { } { }> is");
ASSERT_THROW(checkCode("{ }> {= ~A()^{} }P { }"), InternalError);
ASSERT_THROW(checkCode("{= ~A()^{} }P { } { }> is"), InternalError);
}
void garbageCode59() { // #6735

View File

@ -776,10 +776,11 @@ private:
void tokenize28() {
ASSERT_EQUALS("void f ( ) { asm ( \"^{}\" ) ; }", tokenizeAndStringify("void f() { ^{} }"));
ASSERT_EQUALS("void f ( ) { asm ( \"x(^{});\" ) ; }", tokenizeAndStringify("void f() { x(^{}); }"));
ASSERT_EQUALS("void f ( ) { asm ( \"foo(A(),^{bar();});\" ) ; }", tokenizeAndStringify("void f() { foo(A(), ^{ bar(); }); }"));
ASSERT_EQUALS("int f0 ( Args args ) {\n"
"asm ( \"return^{returnsizeof...(Args);}()\" ) ;\n"
"asm ( \"return^{returnsizeof...(Args);}()+\" ) ;\n"
"\n"
"asm ( \"+^{returnsizeof...(args);}()\" ) ;\n"
"asm ( \"^{returnsizeof...(args);}\" ) ;\n"
"\n"
"\n"
"} ;", tokenizeAndStringify("int f0(Args args) {\n"