[cfe-dev] [PATCH] Improved pretty-printing for Objective-C method declaration
Chris Lattner
clattner at apple.com
Mon Aug 18 21:02:29 PDT 2008
On Aug 18, 2008, at 7:57 PM, Benjamin Stiglitz wrote:
> I haven’t dabbled with C++ for ages, so please feel free to improve my
> string split. (I think the MultiKeywordSelector needs to be exposed a
> bit more to avoid this ugliness.)
Hi Ben,
Can you please resend the patch as an attachment? Your mailer (or the
mailing list) wrapped a bunch of the lines. Also, please fit the
lines in 80 columns.
Thanks!
-Chris
>
>
> -Ben
>
> Index: Driver/ASTConsumers.cpp
> ===================================================================
> --- Driver/ASTConsumers.cpp (revision 54971)
> +++ Driver/ASTConsumers.cpp (working copy)
> @@ -193,15 +193,25 @@
> 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) << ":(" <<
> PDecl->getType().getAsString() << ")" << PDecl->getName();
> + lastPos = pos + 1;
> }
> +
> + if (OMD->getNumParams() == 0)
> + Out << " " << name;
> +
> + if (OMD->isVariadic())
> + Out << ", ...";
> +
> + Out << ";";
> }
>
> void DeclPrinter::PrintObjCImplementationDecl(ObjCImplementationDecl
> *OID) {
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list