From: Dan Gohman Date: Fri, 16 Apr 2010 15:03:25 +0000 (+0000) Subject: Fix SCEVCommutativeExpr::print to be robust in the case of improper X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=a5145c8d5ad6433cd490ce2e19584256b380d6b3;p=oota-llvm.git 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 --- diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 9e101370d40..14e6bcb1815 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 << ")"; }