From 565e67d37322160256c6dca378f0ca59ae24c12a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 7 Nov 2020 22:27:11 +0100 Subject: [PATCH] Clang import: Ignore VisibilityAttr --- lib/clangimport.cpp | 2 ++ test/testclangimport.cpp | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 14219ee98..812bf10d0 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -530,6 +530,8 @@ Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType if (!children2.empty()) { tokenList->back()->scope(scope); for (AstNodePtr astNode: children2) { + if (astNode->nodeType == "VisibilityAttr") + continue; astNode->createTokens(tokenList); if (scopeType == Scope::ScopeType::eEnum) astNode->addtoken(tokenList, ","); diff --git a/test/testclangimport.cpp b/test/testclangimport.cpp index 0771776a3..eeca5ce34 100644 --- a/test/testclangimport.cpp +++ b/test/testclangimport.cpp @@ -82,7 +82,8 @@ private: TEST_CASE(ifStmt); TEST_CASE(labelStmt); TEST_CASE(memberExpr); - TEST_CASE(namespaceDecl); + TEST_CASE(namespaceDecl1); + TEST_CASE(namespaceDecl2); TEST_CASE(recordDecl); TEST_CASE(switchStmt); TEST_CASE(typedefDecl1); @@ -784,13 +785,21 @@ private: parse(clang)); } - void namespaceDecl() { + void namespaceDecl1() { const char clang[] = "`-NamespaceDecl 0x2e5f658 col:11 x\n" " `-VarDecl 0x2e5f6d8 col:19 var 'int'"; ASSERT_EQUALS("namespace x { int var@1 ; }", parse(clang)); } + void namespaceDecl2() { + const char clang[] = "`-NamespaceDecl 0x1753e60 <1.cpp:1:1, line:4:1> line:1:11 std\n" + " |-VisibilityAttr 0x1753ed0 Default\n" + " `-VarDecl 0x1753f40 col:9 x 'int'"; + ASSERT_EQUALS("namespace std { int x@1 ; }", + parse(clang)); + } + void recordDecl() { const char clang[] = "`-RecordDecl 0x354eac8 <1.c:1:1, line:4:1> line:1:8 struct S definition\n" " |-FieldDecl 0x354eb88 col:7 x 'int'\n"