Clang import: fixed AST for 'return new S()'
This commit is contained in:
parent
ef42b82a49
commit
e044d6e219
|
@ -473,7 +473,6 @@ void clangimport::AstNode::setValueType(Token *tok)
|
|||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, AstNodePtr astNode, const Token *def)
|
||||
|
@ -630,10 +629,12 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList)
|
|||
if (!children.empty())
|
||||
return children[0]->createTokens(tokenList);
|
||||
addTypeTokens(tokenList, '\'' + getType() + '\'');
|
||||
Token *type = tokenList->back();
|
||||
Token *par1 = addtoken(tokenList, "(");
|
||||
Token *par2 = addtoken(tokenList, ")");
|
||||
par1->link(par2);
|
||||
par2->link(par1);
|
||||
par1->astOperand1(type);
|
||||
return par1;
|
||||
}
|
||||
if (nodeType == CXXConstructorDecl) {
|
||||
|
|
|
@ -16,6 +16,12 @@ def get_debug_section(title, stdout):
|
|||
s = re.sub(r'needInitialization: .*', 'needInitialization: ---', s)
|
||||
s = re.sub(r'functionOf: .*', 'functionOf: ---', s)
|
||||
s = re.sub(r'0x12345678 Struct', '0x12345678 Class', s)
|
||||
|
||||
if title == '##AST':
|
||||
# TODO set types
|
||||
s = re.sub(r"return '[a-zA-Z0-9: *]+'", "return", s)
|
||||
s = re.sub(r"new '[a-zA-Z0-9: *]+'", "new", s)
|
||||
|
||||
pos1 = s.find(title)
|
||||
assert pos1 > 0
|
||||
pos1 = s.find('\n', pos1) + 1
|
||||
|
@ -95,5 +101,7 @@ def test_ast_control_flow():
|
|||
check_ast('void foo(int x) { switch (x) {case 1: break; } }')
|
||||
check_ast('void foo(int a, int b, int c) { foo(a,b,c); }')
|
||||
|
||||
def test_ast():
|
||||
check_ast('struct S { int x; }; S* foo() { return new S(); }')
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue