Clang import; SwitchStmt
This commit is contained in:
parent
dea6cc3b76
commit
d635ea4b7f
|
@ -68,6 +68,7 @@ static const std::string ParmVarDecl = "ParmVarDecl";
|
|||
static const std::string RecordDecl = "RecordDecl";
|
||||
static const std::string ReturnStmt = "ReturnStmt";
|
||||
static const std::string StringLiteral = "StringLiteral";
|
||||
static const std::string SwitchStmt = "SwitchStmt";
|
||||
static const std::string TemplateArgument = "TemplateArgument";
|
||||
static const std::string TypedefDecl = "TypedefDecl";
|
||||
static const std::string UnaryOperator = "UnaryOperator";
|
||||
|
@ -782,6 +783,18 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList)
|
|||
}
|
||||
if (nodeType == StringLiteral)
|
||||
return addtoken(tokenList, mExtTokens.back());
|
||||
if (nodeType == SwitchStmt) {
|
||||
Token *tok1 = addtoken(tokenList, "switch");
|
||||
Token *par1 = addtoken(tokenList, "(");
|
||||
Token *expr = children[children.size() - 2]->createTokens(tokenList);
|
||||
Token *par2 = addtoken(tokenList, ")");
|
||||
par1->link(par2);
|
||||
par2->link(par1);
|
||||
par1->astOperand1(tok1);
|
||||
par1->astOperand1(expr);
|
||||
createScope(tokenList, Scope::ScopeType::eSwitch, children.back());
|
||||
return nullptr;
|
||||
}
|
||||
if (nodeType == TypedefDecl) {
|
||||
addtoken(tokenList, "typedef");
|
||||
addTypeTokens(tokenList, getType());
|
||||
|
|
|
@ -63,6 +63,7 @@ private:
|
|||
TEST_CASE(memberExpr);
|
||||
TEST_CASE(namespaceDecl);
|
||||
TEST_CASE(recordDecl);
|
||||
TEST_CASE(switchStmt);
|
||||
TEST_CASE(typedefDecl1);
|
||||
TEST_CASE(typedefDecl2);
|
||||
TEST_CASE(typedefDecl3);
|
||||
|
@ -516,6 +517,21 @@ private:
|
|||
parse(clang));
|
||||
}
|
||||
|
||||
void switchStmt() {
|
||||
const char clang[] = "`-FunctionDecl 0x2796ba0 <1.c:1:1, col:35> col:6 foo 'void (int)'\n"
|
||||
" |-ParmVarDecl 0x2796ae0 <col:10, col:14> col:14 used x 'int'\n"
|
||||
" `-CompoundStmt 0x2796d18 <col:17, col:35>\n"
|
||||
" |-SwitchStmt 0x2796cc8 <col:19, col:32>\n"
|
||||
" | |-<<<NULL>>>\n"
|
||||
" | |-<<<NULL>>>\n"
|
||||
" | |-ImplicitCastExpr 0x2796cb0 <col:27> 'int' <LValueToRValue>\n"
|
||||
" | | `-DeclRefExpr 0x2796c88 <col:27> 'int' lvalue ParmVar 0x2796ae0 'x' 'int'\n"
|
||||
" | `-CompoundStmt 0x2796cf8 <col:30, col:32>\n"
|
||||
" `-NullStmt 0x2796d08 <col:33>";
|
||||
ASSERT_EQUALS("void foo ( int x@1 ) { switch ( x@1 ) { } ; }",
|
||||
parse(clang));
|
||||
}
|
||||
|
||||
void typedefDecl1() {
|
||||
const char clang[] = "|-TypedefDecl 0x2d60180 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'\n"
|
||||
"| `-BuiltinType 0x2d5fe80 '__int128'";
|
||||
|
|
Loading…
Reference in New Issue