[PATCH] D28924: [AST Printer] Print attributes on enum constants

Jordan Rose via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 19 16:01:34 PST 2017


jordan_rose created this revision.

The AST printer was dropping attributes on enumerators (enum constants). Now it's not.


Repository:
  rL LLVM

https://reviews.llvm.org/D28924

Files:
  lib/AST/DeclPrinter.cpp
  test/Sema/ast-print.c


Index: test/Sema/ast-print.c
===================================================================
--- test/Sema/ast-print.c
+++ test/Sema/ast-print.c
@@ -65,3 +65,12 @@
   // CHECK: } z = {(struct Z){}};
   } z = {(struct Z){}};
 }
+
+// CHECK-LABEL: enum EnumWithAttributes {
+enum EnumWithAttributes {
+  // CHECK-NEXT: EnumWithAttributesFoo __attribute__((deprecated(""))),
+  EnumWithAttributesFoo __attribute__((deprecated)),
+  // CHECK-NEXT: EnumWithAttributesBar __attribute__((unavailable(""))) = 50
+  EnumWithAttributesBar __attribute__((unavailable)) = 50
+  // CHECK-NEXT: } __attribute__((deprecated("")))
+} __attribute__((deprecated));
Index: lib/AST/DeclPrinter.cpp
===================================================================
--- lib/AST/DeclPrinter.cpp
+++ lib/AST/DeclPrinter.cpp
@@ -438,6 +438,7 @@
 
 void DeclPrinter::VisitEnumConstantDecl(EnumConstantDecl *D) {
   Out << *D;
+  prettyPrintAttributes(D);
   if (Expr *Init = D->getInitExpr()) {
     Out << " = ";
     Init->printPretty(Out, nullptr, Policy, Indentation);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28924.85054.patch
Type: text/x-patch
Size: 1053 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170120/70936c56/attachment.bin>


More information about the cfe-commits mailing list