Clang import; GotoStmt, LabelStmt
This commit is contained in:
parent
6722ee9d3f
commit
cd3ad89777
|
@ -57,10 +57,12 @@ static const std::string FloatingLiteral = "FloatingLiteral";
|
|||
static const std::string ForStmt = "ForStmt";
|
||||
static const std::string FunctionDecl = "FunctionDecl";
|
||||
static const std::string FunctionTemplateDecl = "FunctionTemplateDecl";
|
||||
static const std::string GotoStmt = "GotoStmt";
|
||||
static const std::string IfStmt = "IfStmt";
|
||||
static const std::string ImplicitCastExpr = "ImplicitCastExpr";
|
||||
static const std::string InitListExpr = "InitListExpr";
|
||||
static const std::string IntegerLiteral = "IntegerLiteral";
|
||||
static const std::string LabelStmt = "LabelStmt";
|
||||
static const std::string MemberExpr = "MemberExpr";
|
||||
static const std::string NamespaceDecl = "NamespaceDecl";
|
||||
static const std::string NullStmt = "NullStmt";
|
||||
|
@ -686,6 +688,12 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList)
|
|||
}
|
||||
return nullptr;
|
||||
}
|
||||
if (nodeType == GotoStmt) {
|
||||
addtoken(tokenList, "goto");
|
||||
addtoken(tokenList, unquote(mExtTokens[mExtTokens.size() - 2]));
|
||||
addtoken(tokenList, ";");
|
||||
return nullptr;
|
||||
}
|
||||
if (nodeType == IfStmt) {
|
||||
AstNodePtr cond = children[children.size() - 3];
|
||||
AstNodePtr then = children[children.size() - 2];
|
||||
|
@ -727,6 +735,13 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList)
|
|||
}
|
||||
if (nodeType == IntegerLiteral)
|
||||
return addtoken(tokenList, mExtTokens.back());
|
||||
if (nodeType == LabelStmt) {
|
||||
addtoken(tokenList, unquote(mExtTokens.back()));
|
||||
addtoken(tokenList, ":");
|
||||
for (auto child: children)
|
||||
child->createTokens(tokenList);
|
||||
return nullptr;
|
||||
}
|
||||
if (nodeType == NullStmt)
|
||||
return addtoken(tokenList, ";");
|
||||
if (nodeType == NamespaceDecl) {
|
||||
|
|
|
@ -61,6 +61,7 @@ private:
|
|||
TEST_CASE(functionTemplateDecl2);
|
||||
TEST_CASE(initListExpr);
|
||||
TEST_CASE(ifelse);
|
||||
TEST_CASE(labelStmt);
|
||||
TEST_CASE(memberExpr);
|
||||
TEST_CASE(namespaceDecl);
|
||||
TEST_CASE(recordDecl);
|
||||
|
@ -513,6 +514,14 @@ private:
|
|||
ASSERT_EQUALS("const int [3] ints@1 = { 1 , 2 , 3 } ;", parse(clang));
|
||||
}
|
||||
|
||||
void labelStmt() {
|
||||
const char clang[] = "`-FunctionDecl 0x2ed1ba0 <1.c:1:1, col:36> col:6 foo 'void (int)'\n"
|
||||
" `-CompoundStmt 0x2ed1d00 <col:17, col:36>\n"
|
||||
" `-LabelStmt 0x2ed1ce8 <col:19, col:30> 'loop'\n"
|
||||
" `-GotoStmt 0x2ed1cd0 <col:25, col:30> 'loop' 0x2ed1c88";
|
||||
ASSERT_EQUALS("void foo ( ) { loop : goto loop ; }", parse(clang));
|
||||
}
|
||||
|
||||
void memberExpr() {
|
||||
// C code:
|
||||
// struct S { int x };
|
||||
|
|
Loading…
Reference in New Issue