diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index f3ecff9ad3c5..e5f24dc5d5e9 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -168,19 +168,8 @@ void StmtPrinter::VisitLabelStmt(LabelStmt *Node) { } void StmtPrinter::VisitAttributedStmt(AttributedStmt *Node) { - OS << "[["; - bool first = true; - for (ArrayRef::iterator it = Node->getAttrs().begin(), - end = Node->getAttrs().end(); - it != end; ++it) { - if (!first) { - OS << ", "; - first = false; - } - // TODO: check this - (*it)->printPretty(OS, Policy); - } - OS << "]] "; + for (const auto *Attr : Node->getAttrs()) + Attr->printPretty(OS, Policy); PrintStmt(Node->getSubStmt(), 0); } diff --git a/clang/test/PCH/stmt-attrs.cpp b/clang/test/PCH/stmt-attrs.cpp index 59134500031f..3d7c7a27a7e2 100644 --- a/clang/test/PCH/stmt-attrs.cpp +++ b/clang/test/PCH/stmt-attrs.cpp @@ -1,6 +1,5 @@ // RUN: %clang_cc1 -std=c++11 -emit-pch -o %t.a %s -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -include-pch %t.a %s -// expected-no-diagnostics +// RUN: %clang_cc1 -std=c++11 -include-pch %t.a %s -ast-print -o - | FileCheck %s #ifndef HEADER #define HEADER @@ -9,7 +8,8 @@ inline void test(int i) { switch (i) { case 1: // Notice that the NullStmt has two attributes. - [[clang::fallthrough]][[clang::fallthrough]]; + // CHECK: {{\[\[clang::fallthrough\]\] \[\[clang::fallthrough\]\]}} + [[clang::fallthrough]] [[clang::fallthrough]]; case 2: break; } diff --git a/clang/test/SemaCXX/ast-print.cpp b/clang/test/SemaCXX/ast-print.cpp index 3d98fd8ef3a8..4851571283f4 100644 --- a/clang/test/SemaCXX/ast-print.cpp +++ b/clang/test/SemaCXX/ast-print.cpp @@ -196,3 +196,15 @@ void foo() { return; } }; + +namespace { +void test(int i) { + switch (i) { + case 1: + // CHECK: {{\[\[clang::fallthrough\]\]}} + [[clang::fallthrough]]; + case 2: + break; + } +} +}