Clang import; DoStmt
This commit is contained in:
parent
cd3ad89777
commit
78fcf93342
|
@ -51,6 +51,7 @@ static const std::string CXXStaticCastExpr = "CXXStaticCastExpr";
|
|||
static const std::string CXXThisExpr = "CXXThisExpr";
|
||||
static const std::string DeclRefExpr = "DeclRefExpr";
|
||||
static const std::string DeclStmt = "DeclStmt";
|
||||
static const std::string DoStmt = "DoStmt";
|
||||
static const std::string ExprWithCleanups = "ExprWithCleanups";
|
||||
static const std::string FieldDecl = "FieldDecl";
|
||||
static const std::string FloatingLiteral = "FloatingLiteral";
|
||||
|
@ -646,6 +647,19 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList)
|
|||
}
|
||||
if (nodeType == DeclStmt)
|
||||
return children[0]->createTokens(tokenList);
|
||||
if (nodeType == DoStmt) {
|
||||
addtoken(tokenList, "do");
|
||||
createScope(tokenList, Scope::ScopeType::eDo, children[0]);
|
||||
Token *tok1 = addtoken(tokenList, "while");
|
||||
Token *par1 = addtoken(tokenList, "(");
|
||||
Token *expr = children[1]->createTokens(tokenList);
|
||||
Token *par2 = addtoken(tokenList, ")");
|
||||
par1->link(par2);
|
||||
par2->link(par1);
|
||||
par1->astOperand1(tok1);
|
||||
par1->astOperand2(expr);
|
||||
return nullptr;
|
||||
}
|
||||
if (nodeType == ExprWithCleanups)
|
||||
return children[0]->createTokens(tokenList);
|
||||
if (nodeType == FieldDecl)
|
||||
|
|
|
@ -52,6 +52,7 @@ private:
|
|||
TEST_CASE(cxxRecordDecl1);
|
||||
TEST_CASE(cxxStaticCastExpr1);
|
||||
TEST_CASE(cxxStaticCastExpr2);
|
||||
TEST_CASE(doStmt);
|
||||
TEST_CASE(forStmt);
|
||||
TEST_CASE(funcdecl1);
|
||||
TEST_CASE(funcdecl2);
|
||||
|
@ -395,6 +396,17 @@ private:
|
|||
ASSERT_EQUALS("int a@1 = static_cast<structstd::_Rb_tree_iterator<structstd::pair<constclassstd::__cxx11::basic_string<char>,structLibrary::AllocFunc>>&&> ( <NoName> ) ;", parse(clang));
|
||||
}
|
||||
|
||||
void doStmt() {
|
||||
const char clang[] = "`-FunctionDecl 0x27fbbc8 <line:2:1, col:34> col:6 foo 'void ()'\n"
|
||||
" `-CompoundStmt 0x27fbd08 <col:12, col:34>\n"
|
||||
" `-DoStmt 0x27fbce8 <col:14, col:31>\n"
|
||||
" |-CompoundStmt 0x27fbcb0 <col:17, col:22>\n"
|
||||
" | `-UnaryOperator 0x27fbc90 <col:18, col:19> 'int' postfix '++'\n"
|
||||
" | `-DeclRefExpr 0x27fbc68 <col:18> 'int' lvalue Var 0x27fbae0 'x' 'int'\n"
|
||||
" `-IntegerLiteral 0x27fbcc8 <col:30> 'int' 1";
|
||||
ASSERT_EQUALS("void foo ( ) { do { ++ x ; } while ( 1 ) ; }", parse(clang));
|
||||
}
|
||||
|
||||
void forStmt() {
|
||||
const char clang[] = "`-FunctionDecl 0x2f93ae0 <1.c:1:1, col:56> col:5 main 'int ()'\n"
|
||||
" `-CompoundStmt 0x2f93dc0 <col:12, col:56>\n"
|
||||
|
|
Loading…
Reference in New Issue