Clang import: Ignore VisibilityAttr

This commit is contained in:
Daniel Marjamäki 2020-11-07 22:27:11 +01:00
parent 1c2e480449
commit 565e67d373
2 changed files with 13 additions and 2 deletions

View File

@ -530,6 +530,8 @@ Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType
if (!children2.empty()) { if (!children2.empty()) {
tokenList->back()->scope(scope); tokenList->back()->scope(scope);
for (AstNodePtr astNode: children2) { for (AstNodePtr astNode: children2) {
if (astNode->nodeType == "VisibilityAttr")
continue;
astNode->createTokens(tokenList); astNode->createTokens(tokenList);
if (scopeType == Scope::ScopeType::eEnum) if (scopeType == Scope::ScopeType::eEnum)
astNode->addtoken(tokenList, ","); astNode->addtoken(tokenList, ",");

View File

@ -82,7 +82,8 @@ private:
TEST_CASE(ifStmt); TEST_CASE(ifStmt);
TEST_CASE(labelStmt); TEST_CASE(labelStmt);
TEST_CASE(memberExpr); TEST_CASE(memberExpr);
TEST_CASE(namespaceDecl); TEST_CASE(namespaceDecl1);
TEST_CASE(namespaceDecl2);
TEST_CASE(recordDecl); TEST_CASE(recordDecl);
TEST_CASE(switchStmt); TEST_CASE(switchStmt);
TEST_CASE(typedefDecl1); TEST_CASE(typedefDecl1);
@ -784,13 +785,21 @@ private:
parse(clang)); parse(clang));
} }
void namespaceDecl() { void namespaceDecl1() {
const char clang[] = "`-NamespaceDecl 0x2e5f658 <hello.cpp:1:1, col:24> col:11 x\n" const char clang[] = "`-NamespaceDecl 0x2e5f658 <hello.cpp:1:1, col:24> col:11 x\n"
" `-VarDecl 0x2e5f6d8 <col:15, col:19> col:19 var 'int'"; " `-VarDecl 0x2e5f6d8 <col:15, col:19> col:19 var 'int'";
ASSERT_EQUALS("namespace x { int var@1 ; }", ASSERT_EQUALS("namespace x { int var@1 ; }",
parse(clang)); parse(clang));
} }
void namespaceDecl2() {
const char clang[] = "`-NamespaceDecl 0x1753e60 <1.cpp:1:1, line:4:1> line:1:11 std\n"
" |-VisibilityAttr 0x1753ed0 <col:31, col:56> Default\n"
" `-VarDecl 0x1753f40 <line:3:5, col:9> col:9 x 'int'";
ASSERT_EQUALS("namespace std { int x@1 ; }",
parse(clang));
}
void recordDecl() { void recordDecl() {
const char clang[] = "`-RecordDecl 0x354eac8 <1.c:1:1, line:4:1> line:1:8 struct S definition\n" const char clang[] = "`-RecordDecl 0x354eac8 <1.c:1:1, line:4:1> line:1:8 struct S definition\n"
" |-FieldDecl 0x354eb88 <line:2:3, col:7> col:7 x 'int'\n" " |-FieldDecl 0x354eb88 <line:2:3, col:7> col:7 x 'int'\n"