From ce4e1e419e89c89f98699f74a453412a328d1cfb Mon Sep 17 00:00:00 2001 From: John Criswell Date: Thu, 14 Jul 2005 19:41:16 +0000 Subject: [PATCH] Fixed PR#596: Add parenthesis around the value being negated; that way, if the value begins with a minus sign (e.g. negative integer), we won't generate a C predecrement operator by mistake. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22437 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/CBackend/CBackend.cpp | 4 ++-- lib/Target/CBackend/Writer.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index f821a77caa5..b29187b154f 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -1361,9 +1361,9 @@ void CWriter::visitBinaryOperator(Instruction &I) { // If this is a negation operation, print it out as such. For FP, we don't // want to print "-0.0 - X". if (BinaryOperator::isNeg(&I)) { - Out << "-"; + Out << "-("; writeOperand(BinaryOperator::getNegArgument(cast(&I))); - + Out << ")"; } else { writeOperand(I.getOperand(0)); diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index f821a77caa5..b29187b154f 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -1361,9 +1361,9 @@ void CWriter::visitBinaryOperator(Instruction &I) { // If this is a negation operation, print it out as such. For FP, we don't // want to print "-0.0 - X". if (BinaryOperator::isNeg(&I)) { - Out << "-"; + Out << "-("; writeOperand(BinaryOperator::getNegArgument(cast(&I))); - + Out << ")"; } else { writeOperand(I.getOperand(0)); -- 2.34.1