diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 82ccbf671..cf5ce408b 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -48,6 +48,7 @@ static const std::string CXXDefaultArgExpr = "CXXDefaultArgExpr"; static const std::string CXXDeleteExpr = "CXXDeleteExpr"; static const std::string CXXDestructorDecl = "CXXDestructorDecl"; static const std::string CXXForRangeStmt = "CXXForRangeStmt"; +static const std::string CXXFunctionalCastExpr = "CXXFunctionalCastExpr"; static const std::string CXXMemberCallExpr = "CXXMemberCallExpr"; static const std::string CXXMethodDecl = "CXXMethodDecl"; static const std::string CXXNewExpr = "CXXNewExpr"; @@ -712,7 +713,7 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList) createTokensForCXXRecord(tokenList); return nullptr; } - if (nodeType == CXXStaticCastExpr) { + if (nodeType == CXXStaticCastExpr || nodeType == CXXFunctionalCastExpr) { Token *cast = addtoken(tokenList, getSpelling()); Token *par1 = addtoken(tokenList, "("); Token *expr = children[0]->createTokens(tokenList); diff --git a/test/testclangimport.cpp b/test/testclangimport.cpp index 09fc42fec..afb56bf46 100644 --- a/test/testclangimport.cpp +++ b/test/testclangimport.cpp @@ -50,6 +50,7 @@ private: TEST_CASE(cxxDestructorDecl); TEST_CASE(cxxForRangeStmt1); TEST_CASE(cxxForRangeStmt2); + TEST_CASE(cxxFunctionalCastExpr); TEST_CASE(cxxMemberCall); TEST_CASE(cxxMethodDecl1); TEST_CASE(cxxMethodDecl2); @@ -433,6 +434,24 @@ private: parse(clang)); } + void cxxFunctionalCastExpr() { + const char clang[] = "`-FunctionDecl 0x156fe98 line:1:5 main 'int (int, char **)'\n" + " |-ParmVarDecl 0x156fd00 col:14 argc 'int'\n" + " |-ParmVarDecl 0x156fdb8 col:27 argv 'char **'\n" + " `-CompoundStmt 0x1596410 \n" + " |-DeclStmt 0x15946a8 \n" + " | `-VarDecl 0x1570118 col:11 used setCode 'MyVar':'MyVar' cinit\n" + " | `-ExprWithCleanups 0x1594690 'MyVar':'MyVar'\n" + " | `-CXXConstructExpr 0x1594660 'MyVar':'MyVar' 'void (MyVar &&) noexcept' elidable\n" + " | `-MaterializeTemporaryExpr 0x1592b68 'MyVar':'MyVar' xvalue\n" + " | `-CXXFunctionalCastExpr 0x1592b40 'MyVar':'MyVar' functional cast to MyVar \n" + " | `-CXXConstructExpr 0x15929f0 'MyVar':'MyVar' 'void (int)'\n" + " | `-IntegerLiteral 0x1570248 'int' 5\n"; + ASSERT_EQUALS("int main ( int argc@1 , char ** argv@2 ) {\n" + "MyVar setCode@3 = MyVar ( 5 ) ; }", + parse(clang)); + } + void cxxMemberCall() { const char clang[] = "`-FunctionDecl 0x320dc80 col:6 bar 'void ()'\n" " `-CompoundStmt 0x323bb08 \n"