When providing a code completion for an Objective-C message send, drop
the parameter names from the completions, e.g., provide

  withString:(NSString *)

instead of

  withString:(NSString *)string

since the parameter name is, by convention, redundant with the
selector piece that precedes it and the completions can get
unnecessarily long.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112456 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index a7ac0f1..c154364 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -1758,7 +1758,8 @@
 }
 
 static std::string FormatFunctionParameter(ASTContext &Context,
-                                           ParmVarDecl *Param) {
+                                           ParmVarDecl *Param,
+                                           bool SuppressName = false) {
   bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->getDeclContext());
   if (Param->getType()->isDependentType() ||
       !Param->getType()->isBlockPointerType()) {
@@ -1766,7 +1767,7 @@
     // containing that parameter's type.
     std::string Result;
     
-    if (Param->getIdentifier() && !ObjCMethodParam)
+    if (Param->getIdentifier() && !ObjCMethodParam && !SuppressName)
       Result = Param->getIdentifier()->getName();
     
     Param->getType().getAsStringInternal(Result, 
@@ -1775,7 +1776,7 @@
     if (ObjCMethodParam) {
       Result = "(" + Result;
       Result += ")";
-      if (Param->getIdentifier())
+      if (Param->getIdentifier() && !SuppressName)
         Result += Param->getIdentifier()->getName();
     }
     return Result;
@@ -2188,12 +2189,13 @@
       std::string Arg;
       
       if ((*P)->getType()->isBlockPointerType() && !DeclaringEntity)
-        Arg = FormatFunctionParameter(S.Context, *P);
+        Arg = FormatFunctionParameter(S.Context, *P, true);
       else {
         (*P)->getType().getAsStringInternal(Arg, S.Context.PrintingPolicy);
         Arg = "(" + Arg + ")";
         if (IdentifierInfo *II = (*P)->getIdentifier())
-          Arg += II->getName().str();
+          if (DeclaringEntity || AllParametersAreInformative)
+            Arg += II->getName().str();
       }
       
       if (DeclaringEntity)