Clang import; CStyleCastExpr
This commit is contained in:
parent
75fd4809e6
commit
8f1a50ffc0
|
@ -35,6 +35,7 @@ static const std::string ClassTemplateDecl = "ClassTemplateDecl";
|
||||||
static const std::string ClassTemplateSpecializationDecl = "ClassTemplateSpecializationDecl";
|
static const std::string ClassTemplateSpecializationDecl = "ClassTemplateSpecializationDecl";
|
||||||
static const std::string CompoundStmt = "CompoundStmt";
|
static const std::string CompoundStmt = "CompoundStmt";
|
||||||
static const std::string ContinueStmt = "ContinueStmt";
|
static const std::string ContinueStmt = "ContinueStmt";
|
||||||
|
static const std::string CStyleCastExpr = "CStyleCastExpr";
|
||||||
static const std::string CXXBoolLiteralExpr = "CXXBoolLiteralExpr";
|
static const std::string CXXBoolLiteralExpr = "CXXBoolLiteralExpr";
|
||||||
static const std::string CXXConstructorDecl = "CXXConstructorDecl";
|
static const std::string CXXConstructorDecl = "CXXConstructorDecl";
|
||||||
static const std::string CXXMemberCallExpr = "CXXMemberCallExpr";
|
static const std::string CXXMemberCallExpr = "CXXMemberCallExpr";
|
||||||
|
@ -248,6 +249,10 @@ std::string clangastdump::AstNode::getType() const
|
||||||
{
|
{
|
||||||
if (nodeType == BinaryOperator)
|
if (nodeType == BinaryOperator)
|
||||||
return unquote(mExtTokens[mExtTokens.size() - 2]);
|
return unquote(mExtTokens[mExtTokens.size() - 2]);
|
||||||
|
if (nodeType == CStyleCastExpr)
|
||||||
|
return unquote((mExtTokens.back() == "<NoOp>") ?
|
||||||
|
mExtTokens[mExtTokens.size() - 2] :
|
||||||
|
mExtTokens.back());
|
||||||
if (nodeType == CXXStaticCastExpr)
|
if (nodeType == CXXStaticCastExpr)
|
||||||
return unquote(mExtTokens[mExtTokens.size() - 3]);
|
return unquote(mExtTokens[mExtTokens.size() - 3]);
|
||||||
if (nodeType == DeclRefExpr)
|
if (nodeType == DeclRefExpr)
|
||||||
|
@ -497,6 +502,15 @@ Token *clangastdump::AstNode::createTokens(TokenList *tokenList)
|
||||||
createTokensFunctionDecl(tokenList);
|
createTokensFunctionDecl(tokenList);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
if (nodeType == CStyleCastExpr) {
|
||||||
|
Token *par1 = addtoken(tokenList, "(");
|
||||||
|
addTypeTokens(tokenList, '\'' + getType() + '\'');
|
||||||
|
Token *par2 = addtoken(tokenList, ")");
|
||||||
|
par1->link(par2);
|
||||||
|
par2->link(par1);
|
||||||
|
par1->astOperand1(children[0]->createTokens(tokenList));
|
||||||
|
return par1;
|
||||||
|
}
|
||||||
if (nodeType == CXXBoolLiteralExpr) {
|
if (nodeType == CXXBoolLiteralExpr) {
|
||||||
addtoken(tokenList, mExtTokens.back());
|
addtoken(tokenList, mExtTokens.back());
|
||||||
tokenList->back()->setValueType(new ValueType(ValueType::Sign::UNKNOWN_SIGN, ValueType::Type::BOOL, 0));
|
tokenList->back()->setValueType(new ValueType(ValueType::Sign::UNKNOWN_SIGN, ValueType::Type::BOOL, 0));
|
||||||
|
|
|
@ -35,6 +35,7 @@ private:
|
||||||
TEST_CASE(classTemplateDecl1);
|
TEST_CASE(classTemplateDecl1);
|
||||||
TEST_CASE(classTemplateDecl2);
|
TEST_CASE(classTemplateDecl2);
|
||||||
TEST_CASE(continueStmt);
|
TEST_CASE(continueStmt);
|
||||||
|
TEST_CASE(cstyleCastExpr);
|
||||||
TEST_CASE(cxxBoolLiteralExpr);
|
TEST_CASE(cxxBoolLiteralExpr);
|
||||||
TEST_CASE(cxxConstructorDecl);
|
TEST_CASE(cxxConstructorDecl);
|
||||||
TEST_CASE(cxxMemberCall);
|
TEST_CASE(cxxMemberCall);
|
||||||
|
@ -175,6 +176,13 @@ private:
|
||||||
ASSERT_EQUALS("void foo ( ) { while ( 0 ) { continue ; } }", parse(clang));
|
ASSERT_EQUALS("void foo ( ) { while ( 0 ) { continue ; } }", parse(clang));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cstyleCastExpr() {
|
||||||
|
const char clang[] = "`-VarDecl 0x2336aa0 <1.c:1:1, col:14> col:5 x 'int' cinit\n"
|
||||||
|
" `-CStyleCastExpr 0x2336b70 <col:9, col:14> 'int' <NoOp>\n"
|
||||||
|
" `-CharacterLiteral 0x2336b40 <col:14> 'int' 97";
|
||||||
|
ASSERT_EQUALS("int x@1 = ( int ) 'a' ;", parse(clang));
|
||||||
|
}
|
||||||
|
|
||||||
void cxxBoolLiteralExpr() {
|
void cxxBoolLiteralExpr() {
|
||||||
const char clang[] = "`-VarDecl 0x3940608 <a.cpp:1:1, col:10> col:6 x 'bool' cinit\n"
|
const char clang[] = "`-VarDecl 0x3940608 <a.cpp:1:1, col:10> col:6 x 'bool' cinit\n"
|
||||||
" `-CXXBoolLiteralExpr 0x39406a8 <col:10> 'bool' true";
|
" `-CXXBoolLiteralExpr 0x39406a8 <col:10> 'bool' true";
|
||||||
|
|
Loading…
Reference in New Issue