diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 3942f9f79..612ca10a5 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -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) { diff --git a/test/cli/test-clang-import.py b/test/cli/test-clang-import.py index 4cbdd7e35..c3b0f9f00 100644 --- a/test/cli/test-clang-import.py +++ b/test/cli/test-clang-import.py @@ -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(); }')