[cfe-dev] [PATCH] Improved pretty-printing for Objective-C method declaration
Benjamin Stiglitz
stig at apple.com
Mon Aug 18 19:57:26 PDT 2008
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.)
-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) {
More information about the cfe-dev
mailing list