From 5388538e8724ddbf1bbebde68fe456507cb2826e Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Mon, 15 Sep 2014 16:45:30 +0000 Subject: [PATCH] Pretty print attributes associated with record declarations. llvm-svn: 217784 --- clang/lib/AST/DeclPrinter.cpp | 6 ++++++ clang/test/Sema/ast-print.c | 3 +++ clang/test/SemaCXX/ast-print.cpp | 5 +++++ clang/test/SemaCXX/attr-print.cpp | 2 +- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index 160e48b6d95b..bfd090ae20d5 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/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/clang/test/Sema/ast-print.c b/clang/test/Sema/ast-print.c index 8ac4960b1191..4b2b43190d42 100644 --- a/clang/test/Sema/ast-print.c +++ b/clang/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/clang/test/SemaCXX/ast-print.cpp b/clang/test/SemaCXX/ast-print.cpp index 4851571283f4..baece3c2b320 100644 --- a/clang/test/SemaCXX/ast-print.cpp +++ b/clang/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/clang/test/SemaCXX/attr-print.cpp b/clang/test/SemaCXX/attr-print.cpp index c430aeacfb71..337a6fb69ba3 100644 --- a/clang/test/SemaCXX/attr-print.cpp +++ b/clang/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")));