diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 681dc205c..153f92f87 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -533,7 +533,8 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList) if (nodeType == CXXOperatorCallExpr) return createTokensCall(tokenList); if (nodeType == CXXRecordDecl) { - createTokensForCXXRecord(tokenList); + if (!children.empty()) + createTokensForCXXRecord(tokenList); return nullptr; } if (nodeType == CXXStaticCastExpr) { diff --git a/test/testclangimport.cpp b/test/testclangimport.cpp index 80d6d5ff6..e6342bb8b 100644 --- a/test/testclangimport.cpp +++ b/test/testclangimport.cpp @@ -43,6 +43,7 @@ private: TEST_CASE(cxxMemberCall); TEST_CASE(cxxNullPtrLiteralExpr); TEST_CASE(cxxOperatorCallExpr); + TEST_CASE(cxxRecordDecl1); TEST_CASE(cxxStaticCastExpr1); TEST_CASE(cxxStaticCastExpr2); TEST_CASE(forStmt); @@ -255,6 +256,11 @@ private: ASSERT_EQUALS("void foo ( ) { C c@1 ; c@1 . operator= ( 4 ) ; }", parse(clang)); } + void cxxRecordDecl1() { + const char clang[] = "`-CXXRecordDecl 0x34cc5f8 <1.cpp:2:1, col:7> col:7 class Foo"; + ASSERT_EQUALS("", parse(clang)); + } + void cxxStaticCastExpr1() { const char clang[] = "`-VarDecl 0x2e0e650 col:5 a 'int' cinit\n" " `-CXXStaticCastExpr 0x2e0e728 'int' static_cast \n"