diff options
author | John Criswell <criswell@uiuc.edu> | 2005-07-14 19:41:16 +0000 |
---|---|---|
committer | John Criswell <criswell@uiuc.edu> | 2005-07-14 19:41:16 +0000 |
commit | ce4e1e419e89c89f98699f74a453412a328d1cfb (patch) | |
tree | 245810e91abf2678e778c93abf9c750e9bc2edb7 /lib/Target/CBackend/Writer.cpp | |
parent | c5f44add43bf9ecb7f1f63a320e4440f8f0784c3 (diff) |
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
Diffstat (limited to 'lib/Target/CBackend/Writer.cpp')
-rw-r--r-- | lib/Target/CBackend/Writer.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index f821a77caa..b29187b154 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<BinaryOperator>(&I))); - + Out << ")"; } else { writeOperand(I.getOperand(0)); |