diff options
author | Dan Gohman <gohman@apple.com> | 2010-04-16 15:03:25 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-04-16 15:03:25 +0000 |
commit | a5145c8d5ad6433cd490ce2e19584256b380d6b3 (patch) | |
tree | 8973851f3ff32e1455a88898152da40928732450 /lib/Analysis/ScalarEvolution.cpp | |
parent | 630b58bb5aacd573c870af55eb0e475ed3aa95f7 (diff) |
Fix SCEVCommutativeExpr::print to be robust in the case of improper
expression canonicalization. Its job is to print what's there, not to
make judgements about it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101461 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 9e101370d4..14e6bcb181 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -247,11 +247,13 @@ void SCEVSignExtendExpr::print(raw_ostream &OS) const { } void SCEVCommutativeExpr::print(raw_ostream &OS) const { - assert(NumOperands > 1 && "This plus expr shouldn't exist!"); const char *OpStr = getOperationStr(); - OS << "(" << *Operands[0]; - for (unsigned i = 1, e = NumOperands; i != e; ++i) - OS << OpStr << *Operands[i]; + OS << "("; + for (op_iterator I = op_begin(), E = op_end(); I != E; ++I) { + OS << **I; + if (next(I) != E) + OS << OpStr; + } OS << ")"; } |