Author: jdenny
Date: Tue May 15 15:16:47 2018
New Revision: 332411

URL: http://llvm.org/viewvc/llvm-project?rev=332411&view=rev
Log:
[Attr] Don't print implicit attributes

Fixes bug reported at:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180514/228390.html

Reviewed by: aaron.ballman

Differential Revision: https://reviews.llvm.org/D46894

Modified:
    cfe/trunk/lib/AST/DeclPrinter.cpp
    cfe/trunk/test/Misc/ast-print-record-decl.c

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=332411&r1=332410&r2=332411&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Tue May 15 15:16:47 2018
@@ -215,7 +215,7 @@ void DeclPrinter::prettyPrintAttributes(
   if (D->hasAttrs()) {
     AttrVec &Attrs = D->getAttrs();
     for (auto *A : Attrs) {
-      if (A->isInherited())
+      if (A->isInherited() || A->isImplicit())
         continue;
       switch (A->getKind()) {
 #define ATTR(X)

Modified: cfe/trunk/test/Misc/ast-print-record-decl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-record-decl.c?rev=332411&r1=332410&r2=332411&view=diff
==============================================================================
--- cfe/trunk/test/Misc/ast-print-record-decl.c (original)
+++ cfe/trunk/test/Misc/ast-print-record-decl.c Tue May 15 15:16:47 2018
@@ -54,20 +54,34 @@
 //   RUN:        -DKW=struct -DBASES=' : B' -o - -xc++ %s \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print -DKW=struct 
-DBASES=' : B' -xc++ %s \
-//   RUN: > %t.cpp
+//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++ %s \
+//   RUN:            > %t.cpp
 //   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
 //   RUN:           -DBASES=' : B' %s --input-file %t.cpp
 //
 //   Now check compiling and printing of the printed file.
 //
-//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.cpp
-//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.cpp
+//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" > %t.diags
+//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.diags
+//   RUN: cat %t.diags >> %t.cpp
 //
 //   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm -o - 
%t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print %t.cpp \
+//   RUN: %clang_cc1 -verify -ast-print %t.cpp \
+//   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
+//   RUN:             -DBASES=' : B' %s
+//
+//   Make sure implicit attributes aren't printed.  See comments in inMemberPtr
+//   for details.
+//
+//   RUN: %clang_cc1 -triple i686-pc-win32 -verify -ast-print -DKW=struct \
+//   RUN:            -DBASES=' : B' -xc++ %s > %t.cpp
+//   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
+//   RUN:           -DBASES=' : B' %s --input-file %t.cpp
+//
+//   RUN: cat %t.diags >> %t.cpp
+//   RUN: %clang_cc1 -triple i686-pc-win32 -verify -ast-print %t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
 //   RUN:             -DBASES=' : B' %s
 
@@ -236,6 +250,9 @@ void inInit() {
 #ifdef __cplusplus
 // PRINT-CXX-LABEL: inMemberPtr
 void inMemberPtr() {
+  // Under windows, the implicit attribute __single_inheritance used to print
+  // between KW and T1 here, but that wasn't faithful to the original source.
+  //
   // PRINT-CXX-NEXT: [[KW]] T1 {
   // PRINT-CXX-NEXT:   int i;
   // PRINT-CXX-NEXT: };


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to