Clang import; EnumDecl
This commit is contained in:
parent
fcd6c62a0d
commit
ce77db2b1b
|
@ -60,6 +60,8 @@ static const std::string CXXThrowExpr = "CXXThrowExpr";
|
|||
static const std::string DeclRefExpr = "DeclRefExpr";
|
||||
static const std::string DeclStmt = "DeclStmt";
|
||||
static const std::string DoStmt = "DoStmt";
|
||||
static const std::string EnumConstantDecl = "EnumConstantDecl";
|
||||
static const std::string EnumDecl = "EnumDecl";
|
||||
static const std::string ExprWithCleanups = "ExprWithCleanups";
|
||||
static const std::string FieldDecl = "FieldDecl";
|
||||
static const std::string FloatingLiteral = "FloatingLiteral";
|
||||
|
@ -714,6 +716,21 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList)
|
|||
par1->astOperand2(expr);
|
||||
return nullptr;
|
||||
}
|
||||
if (nodeType == EnumConstantDecl)
|
||||
return addtoken(tokenList, getSpelling());
|
||||
if (nodeType == EnumDecl) {
|
||||
Token *enumtok = addtoken(tokenList, "enum");
|
||||
if (mExtTokens[mExtTokens.size() - 3].compare(0,4,"col:") == 0)
|
||||
addtoken(tokenList, mExtTokens.back());
|
||||
createScope(tokenList, Scope::ScopeType::eEnum, children, enumtok);
|
||||
for (Token *tok = enumtok; tok; tok = tok->next()) {
|
||||
if (Token::simpleMatch(tok, "; }"))
|
||||
tok->deleteThis();
|
||||
else if (tok->str() == ";")
|
||||
tok->str(",");
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
if (nodeType == ExprWithCleanups)
|
||||
return children[0]->createTokens(tokenList);
|
||||
if (nodeType == FieldDecl)
|
||||
|
|
|
@ -59,6 +59,7 @@ private:
|
|||
TEST_CASE(cxxStdInitializerListExpr);
|
||||
TEST_CASE(cxxThrowExpr);
|
||||
TEST_CASE(doStmt);
|
||||
TEST_CASE(enumDecl);
|
||||
TEST_CASE(forStmt);
|
||||
TEST_CASE(funcdecl1);
|
||||
TEST_CASE(funcdecl2);
|
||||
|
@ -484,6 +485,14 @@ private:
|
|||
ASSERT_EQUALS("void foo ( ) { do { ++ x ; } while ( 1 ) ; }", parse(clang));
|
||||
}
|
||||
|
||||
void enumDecl() {
|
||||
const char clang[] = "`-EnumDecl 0x2660660 <line:3:1, col:16> col:6 referenced abc\n"
|
||||
" |-EnumConstantDecl 0x2660720 <col:11> col:11 referenced a 'abc'\n"
|
||||
" |-EnumConstantDecl 0x2660768 <col:13> col:13 b 'abc'\n"
|
||||
" `-EnumConstantDecl 0x26607b0 <col:15> col:15 c 'abc'";
|
||||
ASSERT_EQUALS("enum abc { a , b , c }", 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