r208706 - Fix the AST printer for attributed statements so that it does not print duplicate attribute introducers. Eg) [[clang::fallthrough]] instead of [[[[clang::fallthrough]]]]
Aaron Ballman
aaron at aaronballman.com
Tue May 13 09:12:14 PDT 2014
Author: aaronballman
Date: Tue May 13 11:12:14 2014
New Revision: 208706
URL: http://llvm.org/viewvc/llvm-project?rev=208706&view=rev
Log:
Fix the AST printer for attributed statements so that it does not print duplicate attribute introducers. Eg) [[clang::fallthrough]] instead of [[[[clang::fallthrough]]]]
Modified:
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/test/PCH/stmt-attrs.cpp
cfe/trunk/test/SemaCXX/ast-print.cpp
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=208706&r1=208705&r2=208706&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Tue May 13 11:12:14 2014
@@ -168,19 +168,8 @@ void StmtPrinter::VisitLabelStmt(LabelSt
}
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);
}
Modified: cfe/trunk/test/PCH/stmt-attrs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/stmt-attrs.cpp?rev=208706&r1=208705&r2=208706&view=diff
==============================================================================
--- cfe/trunk/test/PCH/stmt-attrs.cpp (original)
+++ cfe/trunk/test/PCH/stmt-attrs.cpp Tue May 13 11:12:14 2014
@@ -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;
}
Modified: cfe/trunk/test/SemaCXX/ast-print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print.cpp?rev=208706&r1=208705&r2=208706&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print.cpp Tue May 13 11:12:14 2014
@@ -196,3 +196,15 @@ void foo() {
return;
}
};
+
+namespace {
+void test(int i) {
+ switch (i) {
+ case 1:
+ // CHECK: {{\[\[clang::fallthrough\]\]}}
+ [[clang::fallthrough]];
+ case 2:
+ break;
+ }
+}
+}
More information about the cfe-commits
mailing list