]> granicus.if.org Git - clang/commitdiff
improve pretty printing of objc method declaration,
authorChris Lattner <sabre@nondot.org>
Fri, 22 Aug 2008 06:59:15 +0000 (06:59 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 22 Aug 2008 06:59:15 +0000 (06:59 +0000)
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

index ea6dc3f76511c99ab2f639059f808d98b5fc7af0..1e964f076e101f97bbeb558f3c374597e51cf91e 100644 (file)
@@ -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) {