Fix the AST printer for attributed statements so that it does not print duplicate attribute introducers. Eg) [[clang::fallthrough]] instead of [[[[clang::fallthrough]]]]

llvm-svn: 208706
This commit is contained in:
Aaron Ballman 2014-05-13 16:12:14 +00:00
parent 12a8bf09d0
commit 8063c3b80c
3 changed files with 17 additions and 16 deletions

View File

@ -168,19 +168,8 @@ void StmtPrinter::VisitLabelStmt(LabelStmt *Node) {
}
void StmtPrinter::VisitAttributedStmt(AttributedStmt *Node) {
OS << "[[";
bool first = true;
for (ArrayRef<const Attr*>::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);
}

View File

@ -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;
}

View File

@ -196,3 +196,15 @@ void foo() {
return;
}
};
namespace {
void test(int i) {
switch (i) {
case 1:
// CHECK: {{\[\[clang::fallthrough\]\]}}
[[clang::fallthrough]];
case 2:
break;
}
}
}