PR4391: Tweak -ast-print output to generate valid output for edge cases
like "int x = + +3;". llvm-svn: 73356
This commit is contained in:
parent
9b4c85ff62
commit
1cf2536d6c
|
@ -643,7 +643,8 @@ void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
|
|||
if (!Node->isPostfix()) {
|
||||
OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
|
||||
|
||||
// Print a space if this is an "identifier operator" like __real.
|
||||
// Print a space if this is an "identifier operator" like __real, or if
|
||||
// it might be concatenated incorrectly like '+'.
|
||||
switch (Node->getOpcode()) {
|
||||
default: break;
|
||||
case UnaryOperator::Real:
|
||||
|
@ -651,6 +652,11 @@ void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
|
|||
case UnaryOperator::Extension:
|
||||
OS << ' ';
|
||||
break;
|
||||
case UnaryOperator::Plus:
|
||||
case UnaryOperator::Minus:
|
||||
if (isa<UnaryOperator>(Node->getSubExpr()))
|
||||
OS << ' ';
|
||||
break;
|
||||
}
|
||||
}
|
||||
PrintExpr(Node->getSubExpr());
|
||||
|
|
Loading…
Reference in New Issue