Hi all,
The attached patch fixes a bug with printing GCCAsmExprs. Presently,
the required parentheses around input and output arguments are
omitted. Thus, given the code:
__asm__ __volatile__("addl %%ebx,%%eax" : "=a" (added) : "a" (1), "b" (2) );
The expr is presently printed as:
asm volatile ("addl %%ebx,%%eax" : "=a" added : "a" 1, "b" 2);
With the patch, the expr is printed as:
asm volatile ("addl %%ebx,%%eax" : "=a" (added) : "a" (1), "b" (2));
Best,
Nick
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index 46fef8f..5974396 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -396,8 +396,9 @@ void StmtPrinter::VisitGCCAsmStmt(GCCAsmStmt *Node) {
}
VisitStringLiteral(Node->getOutputConstraintLiteral(i));
- OS << " ";
+ OS << " (";
Visit(Node->getOutputExpr(i));
+ OS << ")";
}
// Inputs
@@ -415,8 +416,9 @@ void StmtPrinter::VisitGCCAsmStmt(GCCAsmStmt *Node) {
}
VisitStringLiteral(Node->getInputConstraintLiteral(i));
- OS << " ";
+ OS << " (";
Visit(Node->getInputExpr(i));
+ OS << ")";
}
// Clobbers
diff --git a/test/Sema/ast-print.c b/test/Sema/ast-print.c
index 50e0ca8..e91d1c6 100644
--- a/test/Sema/ast-print.c
+++ b/test/Sema/ast-print.c
@@ -61,3 +61,9 @@ void cast() {
// CHECK: int *x = ((void *)0), *y = ((void *)0);
int *x = ((void *)0), *y = ((void *)0);
}
+
+void assembly() {
+ int added;
+ // CHECK: asm volatile ("addl %%ebx,%%eax" : "=a" (added) : "a" (1), "b" (2));
+ __asm__ __volatile__("addl %%ebx,%%eax" : "=a" (added) : "a" (1), "b" (2) );
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits