From 05a34142aa45c98ef0375e0c2061d55470c487b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 11 Jan 2020 15:58:31 +0100 Subject: [PATCH] Clang import; forward class declaration --- lib/clangimport.cpp | 3 ++- test/testclangimport.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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"