Skip to content

Commit 565e67d

Browse files
committed
Clang import: Ignore VisibilityAttr
1 parent 1c2e480 commit 565e67d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/clangimport.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,8 @@ Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType
530530
if (!children2.empty()) {
531531
tokenList->back()->scope(scope);
532532
for (AstNodePtr astNode: children2) {
533+
if (astNode->nodeType == "VisibilityAttr")
534+
continue;
533535
astNode->createTokens(tokenList);
534536
if (scopeType == Scope::ScopeType::eEnum)
535537
astNode->addtoken(tokenList, ",");

test/testclangimport.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ class TestClangImport: public TestFixture {
8282
TEST_CASE(ifStmt);
8383
TEST_CASE(labelStmt);
8484
TEST_CASE(memberExpr);
85-
TEST_CASE(namespaceDecl);
85+
TEST_CASE(namespaceDecl1);
86+
TEST_CASE(namespaceDecl2);
8687
TEST_CASE(recordDecl);
8788
TEST_CASE(switchStmt);
8889
TEST_CASE(typedefDecl1);
@@ -784,13 +785,21 @@ class TestClangImport: public TestFixture {
784785
parse(clang));
785786
}
786787

787-
void namespaceDecl() {
788+
void namespaceDecl1() {
788789
const char clang[] = "`-NamespaceDecl 0x2e5f658 <hello.cpp:1:1, col:24> col:11 x\n"
789790
" `-VarDecl 0x2e5f6d8 <col:15, col:19> col:19 var 'int'";
790791
ASSERT_EQUALS("namespace x { int var@1 ; }",
791792
parse(clang));
792793
}
793794

795+
void namespaceDecl2() {
796+
const char clang[] = "`-NamespaceDecl 0x1753e60 <1.cpp:1:1, line:4:1> line:1:11 std\n"
797+
" |-VisibilityAttr 0x1753ed0 <col:31, col:56> Default\n"
798+
" `-VarDecl 0x1753f40 <line:3:5, col:9> col:9 x 'int'";
799+
ASSERT_EQUALS("namespace std { int x@1 ; }",
800+
parse(clang));
801+
}
802+
794803
void recordDecl() {
795804
const char clang[] = "`-RecordDecl 0x354eac8 <1.c:1:1, line:4:1> line:1:8 struct S definition\n"
796805
" |-FieldDecl 0x354eb88 <line:2:3, col:7> col:7 x 'int'\n"

0 commit comments

Comments
 (0)