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
diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp
index ea6dc3f..1e964f0 100644
--- a/Driver/ASTConsumers.cpp
+++ b/Driver/ASTConsumers.cpp
@@ -193,15 +193,26 @@
   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) {