From: Aaron Ballman Date: Mon, 15 Sep 2014 16:45:30 +0000 (+0000) Subject: Pretty print attributes associated with record declarations. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=085efff2b54a222d8ba2e595666a318dcb150a9c;p=clang Pretty print attributes associated with record declarations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217784 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index 160e48b6d9..bfd090ae20 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -377,6 +377,9 @@ void DeclPrinter::VisitRecordDecl(RecordDecl *D) { if (!Policy.SuppressSpecifiers && D->isModulePrivate()) Out << "__module_private__ "; Out << D->getKindName(); + + prettyPrintAttributes(D); + if (D->getIdentifier()) Out << ' ' << *D; @@ -768,6 +771,9 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) { if (!Policy.SuppressSpecifiers && D->isModulePrivate()) Out << "__module_private__ "; Out << D->getKindName(); + + prettyPrintAttributes(D); + if (D->getIdentifier()) Out << ' ' << *D; diff --git a/test/Sema/ast-print.c b/test/Sema/ast-print.c index 8ac4960b11..4b2b43190d 100644 --- a/test/Sema/ast-print.c +++ b/test/Sema/ast-print.c @@ -42,3 +42,6 @@ int rvarr(int n, int a[restrict static n]) { typedef struct { int f; } T __attribute__ ((__aligned__)); + +// CHECK: struct __attribute__((visibility("default"))) S; +struct __attribute__((visibility("default"))) S; diff --git a/test/SemaCXX/ast-print.cpp b/test/SemaCXX/ast-print.cpp index 4851571283..baece3c2b3 100644 --- a/test/SemaCXX/ast-print.cpp +++ b/test/SemaCXX/ast-print.cpp @@ -208,3 +208,8 @@ void test(int i) { } } } + +namespace { +// CHECK: struct {{\[\[gnu::visibility\(\"hidden\"\)\]\]}} S; +struct [[gnu::visibility("hidden")]] S; +} diff --git a/test/SemaCXX/attr-print.cpp b/test/SemaCXX/attr-print.cpp index c430aeacfb..337a6fb69b 100644 --- a/test/SemaCXX/attr-print.cpp +++ b/test/SemaCXX/attr-print.cpp @@ -26,7 +26,7 @@ int small __attribute__((mode(byte))); // CHECK: int v __attribute__((visibility("hidden"))); int v __attribute__((visibility("hidden"))); -// FIXME: The attribute should be printed with the tag declaration. +// CHECK: class __attribute__((consumable("unknown"))) AttrTester1 class __attribute__((consumable(unknown))) AttrTester1 { // CHECK: void callableWhen() __attribute__((callable_when("unconsumed", "consumed"))); void callableWhen() __attribute__((callable_when("unconsumed", "consumed")));