Bug fix in StmtPrinter to handle pretty-printing ObjCMessageExprs involving variadic methods (also did some cosmetic cleanups in the printing output).

llvm-svn: 50583
This commit is contained in:
Ted Kremenek 2008-05-02 17:32:38 +00:00
parent a700b2bd0f
commit a06e7120bb
1 changed files with 11 additions and 5 deletions

View File

@ -822,15 +822,21 @@ void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
Expr *receiver = Mess->getReceiver();
if (receiver) PrintExpr(receiver);
else OS << Mess->getClassName()->getName();
OS << ' ';
Selector selector = Mess->getSelector();
if (selector.isUnarySelector()) {
OS << " " << selector.getIdentifierInfoForSlot(0)->getName();
OS << selector.getIdentifierInfoForSlot(0)->getName();
} else {
for (unsigned i = 0, e = Mess->getNumArgs(); i != e; ++i) {
if (selector.getIdentifierInfoForSlot(i))
OS << selector.getIdentifierInfoForSlot(i)->getName() << ":";
else
OS << ":";
if (i < selector.getNumArgs()) {
if (i > 0) OS << ' ';
if (selector.getIdentifierInfoForSlot(i))
OS << selector.getIdentifierInfoForSlot(i)->getName() << ":";
else
OS << ":";
}
else OS << ", "; // Handle variadic methods.
PrintExpr(Mess->getArg(i));
}
}