Fix spurious trailing comma when printing some of the __c11_atomic_* builtins. Patch by Joe Sprowes!

llvm-svn: 180867
This commit is contained in:
Richard Smith 2013-05-01 19:02:43 +00:00
parent 9f8400eca4
commit df6bee8081
2 changed files with 17 additions and 5 deletions

View File

@ -1113,24 +1113,25 @@ void StmtPrinter::VisitAtomicExpr(AtomicExpr *Node) {
// AtomicExpr stores its subexpressions in a permuted order.
PrintExpr(Node->getPtr());
OS << ", ";
if (Node->getOp() != AtomicExpr::AO__c11_atomic_load &&
Node->getOp() != AtomicExpr::AO__atomic_load_n) {
PrintExpr(Node->getVal1());
OS << ", ";
PrintExpr(Node->getVal1());
}
if (Node->getOp() == AtomicExpr::AO__atomic_exchange ||
Node->isCmpXChg()) {
PrintExpr(Node->getVal2());
OS << ", ";
PrintExpr(Node->getVal2());
}
if (Node->getOp() == AtomicExpr::AO__atomic_compare_exchange ||
Node->getOp() == AtomicExpr::AO__atomic_compare_exchange_n) {
PrintExpr(Node->getWeak());
OS << ", ";
PrintExpr(Node->getWeak());
}
if (Node->getOp() != AtomicExpr::AO__c11_atomic_init)
if (Node->getOp() != AtomicExpr::AO__c11_atomic_init) {
OS << ", ";
PrintExpr(Node->getOrder());
}
if (Node->isCmpXChg()) {
OS << ", ";
PrintExpr(Node->getOrderFail());

View File

@ -137,3 +137,14 @@ void test12() {
ConstrWithCleanupsClass cwcExplicitArg(VirualDestrClass(56));
}
// CHECK: void test13() {
// CHECK: _Atomic(int) i;
// CHECK: __c11_atomic_init(&i, 0);
// CHECK: __c11_atomic_load(&i, 0);
// CHECK: }
void test13() {
_Atomic(int) i;
__c11_atomic_init(&i, 0);
__c11_atomic_load(&i, 0);
}