From efe8a96f5965106e6c23df3c0c0681325b66062d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 22 Aug 2008 06:59:15 +0000 Subject: [PATCH] improve pretty printing of objc method declaration, patch contributed by Benjamin Stiglitz! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55170 91177308-0d34-0410-b5e6-96231b3b80d8 --- Driver/ASTConsumers.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp index ea6dc3f765..1e964f076e 100644 --- a/Driver/ASTConsumers.cpp +++ b/Driver/ASTConsumers.cpp @@ -193,15 +193,26 @@ void DeclPrinter::PrintObjCMethodDecl(ObjCMethodDecl *OMD) { else Out << "\n+ "; if (!OMD->getResultType().isNull()) - Out << '(' << OMD->getResultType().getAsString() << ") "; - // FIXME: just print original selector name! - Out << OMD->getSelector().getName(); + Out << '(' << OMD->getResultType().getAsString() << ")"; + std::string name = OMD->getSelector().getName(); + std::string::size_type pos, lastPos = 0; for (unsigned i = 0, e = OMD->getNumParams(); i != e; ++i) { ParmVarDecl *PDecl = OMD->getParamDecl(i); // FIXME: selector is missing here! - Out << " :(" << PDecl->getType().getAsString() << ") " << PDecl->getName(); + pos = name.find_first_of(":", lastPos); + Out << " " << name.substr(lastPos, pos - lastPos); + Out << ":(" << PDecl->getType().getAsString() << ")" << PDecl->getName(); + lastPos = pos + 1; } + + if (OMD->getNumParams() == 0) + Out << " " << name; + + if (OMD->isVariadic()) + Out << ", ..."; + + Out << ";"; } void DeclPrinter::PrintObjCImplementationDecl(ObjCImplementationDecl *OID) {