Clang import: Fix syntax tree for 'case 1'
This commit is contained in:
parent
d37ddc7114
commit
e3ab688597
|
@ -558,8 +558,9 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList)
|
||||||
if (nodeType == CallExpr)
|
if (nodeType == CallExpr)
|
||||||
return createTokensCall(tokenList);
|
return createTokensCall(tokenList);
|
||||||
if (nodeType == CaseStmt) {
|
if (nodeType == CaseStmt) {
|
||||||
addtoken(tokenList, "case");
|
Token *caseToken = addtoken(tokenList, "case");
|
||||||
children[0]->createTokens(tokenList);
|
Token *exprToken = children[0]->createTokens(tokenList);
|
||||||
|
caseToken->astOperand1(exprToken);
|
||||||
addtoken(tokenList, ":");
|
addtoken(tokenList, ":");
|
||||||
children.back()->createTokens(tokenList);
|
children.back()->createTokens(tokenList);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -604,7 +605,7 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (nodeType == ConstantExpr)
|
if (nodeType == ConstantExpr)
|
||||||
return children[0]->createTokens(tokenList);
|
return children.back()->createTokens(tokenList);
|
||||||
if (nodeType == ContinueStmt)
|
if (nodeType == ContinueStmt)
|
||||||
return addtoken(tokenList, "continue");
|
return addtoken(tokenList, "continue");
|
||||||
if (nodeType == CStyleCastExpr) {
|
if (nodeType == CStyleCastExpr) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ def test_ast_calculations():
|
||||||
def test_ast_control_flow():
|
def test_ast_control_flow():
|
||||||
check_ast('void foo(int x) { if (x > 5){} }')
|
check_ast('void foo(int x) { if (x > 5){} }')
|
||||||
check_ast('int dostuff() { for (int x = 0; x < 10; x++); }')
|
check_ast('int dostuff() { for (int x = 0; x < 10; x++); }')
|
||||||
todo_check_ast('void foo(int x) { switch (x) {case 1: break; } }')
|
check_ast('void foo(int x) { switch (x) {case 1: break; } }')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue