r226670 - Initial support for C++ parameter completion

Francisco Lopes da Silva oblita at gmail.com
Wed Jan 21 08:24:11 PST 2015


Author: francisco.lopes
Date: Wed Jan 21 10:24:11 2015
New Revision: 226670

URL: http://llvm.org/viewvc/llvm-project?rev=226670&view=rev
Log:
Initial support for C++ parameter completion

The improved completion in call context now works with:

 - Functions.
 - Member functions.
 - Constructors.
 - New expressions.
 - Function call expressions.
 - Template variants of the previous.

There are still rough edges to be fixed:

 - Provide support for optional parameters.         (fix known)
 - Provide support for member initializers.         (fix known)
 - Provide support for variadic template functions. (fix unknown)
 - Others?

Added:
    cfe/trunk/test/Index/complete-call.cpp
    cfe/trunk/test/Index/complete-constructor-params.cpp
    cfe/trunk/test/Index/complete-functor-call.cpp
Modified:
    cfe/trunk/include/clang-c/Index.h
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/include/clang/Sema/Sema.h
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/lib/Parse/ParseExprCXX.cpp
    cfe/trunk/lib/Sema/SemaCodeComplete.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
    cfe/trunk/test/Index/code-completion.cpp
    cfe/trunk/test/Index/complete-type-factors.m
    cfe/trunk/tools/libclang/CIndex.cpp
    cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=226670&r1=226669&r2=226670&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Jan 21 10:24:11 2015
@@ -2276,7 +2276,12 @@ enum CXCursorKind {
    */
   CXCursor_ModuleImportDecl              = 600,
   CXCursor_FirstExtraDecl                = CXCursor_ModuleImportDecl,
-  CXCursor_LastExtraDecl                 = CXCursor_ModuleImportDecl
+  CXCursor_LastExtraDecl                 = CXCursor_ModuleImportDecl,
+
+  /**
+   * \brief A code completion overload candidate.
+   */
+  CXCursor_OverloadCandidate             = 700
 };
 
 /**

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=226670&r1=226669&r2=226670&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Jan 21 10:24:11 2015
@@ -1362,12 +1362,9 @@ private:
   typedef SmallVector<SourceLocation, 20> CommaLocsTy;
 
   /// ParseExpressionList - Used for C/C++ (argument-)expression-list.
-  bool
-  ParseExpressionList(SmallVectorImpl<Expr *> &Exprs,
-                      SmallVectorImpl<SourceLocation> &CommaLocs,
-                      void (Sema::*Completer)(Scope *S, Expr *Data,
-                                              ArrayRef<Expr *> Args) = nullptr,
-                      Expr *Data = nullptr);
+  bool ParseExpressionList(SmallVectorImpl<Expr *> &Exprs,
+                           SmallVectorImpl<SourceLocation> &CommaLocs,
+                           std::function<void()> Completer = nullptr);
 
   /// ParseSimpleExpressionList - A simple comma-separated list of expressions,
   /// used for misc language extensions.

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=226670&r1=226669&r2=226670&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan 21 10:24:11 2015
@@ -2279,8 +2279,9 @@ public:
   void AddFunctionCandidates(const UnresolvedSetImpl &Functions,
                       ArrayRef<Expr *> Args,
                       OverloadCandidateSet &CandidateSet,
+                      TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
                       bool SuppressUserConversions = false,
-                      TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
+                      bool PartialOverloading = false);
   void AddMethodCandidate(DeclAccessPair FoundDecl,
                           QualType ObjectType,
                           Expr::Classification ObjectClassification,
@@ -2293,7 +2294,8 @@ public:
                           Expr::Classification ObjectClassification,
                           ArrayRef<Expr *> Args,
                           OverloadCandidateSet& CandidateSet,
-                          bool SuppressUserConversions = false);
+                          bool SuppressUserConversions = false,
+                          bool PartialOverloading = false);
   void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl,
                                   DeclAccessPair FoundDecl,
                                   CXXRecordDecl *ActingContext,
@@ -2302,13 +2304,15 @@ public:
                                   Expr::Classification ObjectClassification,
                                   ArrayRef<Expr *> Args,
                                   OverloadCandidateSet& CandidateSet,
-                                  bool SuppressUserConversions = false);
+                                  bool SuppressUserConversions = false,
+                                  bool PartialOverloading = false);
   void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate,
                                     DeclAccessPair FoundDecl,
                                  TemplateArgumentListInfo *ExplicitTemplateArgs,
                                     ArrayRef<Expr *> Args,
                                     OverloadCandidateSet& CandidateSet,
-                                    bool SuppressUserConversions = false);
+                                    bool SuppressUserConversions = false,
+                                    bool PartialOverloading = false);
   void AddConversionCandidate(CXXConversionDecl *Conversion,
                               DeclAccessPair FoundDecl,
                               CXXRecordDecl *ActingContext,
@@ -6182,14 +6186,16 @@ public:
                                   unsigned NumExplicitlySpecified,
                                   FunctionDecl *&Specialization,
                                   sema::TemplateDeductionInfo &Info,
-           SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs = nullptr);
+           SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs = nullptr,
+                                  bool PartialOverloading = false);
 
   TemplateDeductionResult
   DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
                           TemplateArgumentListInfo *ExplicitTemplateArgs,
                           ArrayRef<Expr *> Args,
                           FunctionDecl *&Specialization,
-                          sema::TemplateDeductionInfo &Info);
+                          sema::TemplateDeductionInfo &Info,
+                          bool PartialOverloading = false);
 
   TemplateDeductionResult
   DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
@@ -8411,6 +8417,8 @@ public:
   void CodeCompleteTypeQualifiers(DeclSpec &DS);
   void CodeCompleteCase(Scope *S);
   void CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef<Expr *> Args);
+  void CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc,
+                               ArrayRef<Expr *> Args);
   void CodeCompleteInitializer(Scope *S, Decl *D);
   void CodeCompleteReturn(Scope *S);
   void CodeCompleteAfterIf(Scope *S);
@@ -8729,6 +8737,16 @@ public:
       DC = CatD->getClassInterface();
     return DC;
   }
+
+  /// \brief To be used for checking whether the arguments being passed to
+  /// function exceeds the number of parameters expected for it.
+  bool TooManyArguments(size_t NumParams, size_t NumArgs,
+                        bool PartialOverloading = false) const {
+    // We check whether we're just after a comma in code-completion.
+    if (NumArgs > 0 && PartialOverloading)
+      return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
+    return NumArgs > NumParams;
+  }
 };
 
 /// \brief RAII object that enters a new expression evaluation context.

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=226670&r1=226669&r2=226670&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Jan 21 10:24:11 2015
@@ -1993,7 +1993,11 @@ Decl *Parser::ParseDeclarationAfterDecla
       Actions.ActOnCXXEnterDeclInitializer(getCurScope(), ThisDecl);
     }
 
-    if (ParseExpressionList(Exprs, CommaLocs)) {
+    if (ParseExpressionList(Exprs, CommaLocs, [&] {
+          Actions.CodeCompleteConstructor(getCurScope(),
+                 cast<VarDecl>(ThisDecl)->getType()->getCanonicalTypeInternal(),
+                                          ThisDecl->getLocation(), Exprs);
+       })) {
       Actions.ActOnInitializerError(ThisDecl);
       SkipUntil(tok::r_paren, StopAtSemi);
 

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=226670&r1=226669&r2=226670&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Jan 21 10:24:11 2015
@@ -1454,8 +1454,9 @@ Parser::ParsePostfixExpressionSuffix(Exp
 
       if (OpKind == tok::l_paren || !LHS.isInvalid()) {
         if (Tok.isNot(tok::r_paren)) {
-          if (ParseExpressionList(ArgExprs, CommaLocs, &Sema::CodeCompleteCall,
-                                  LHS.get())) {
+          if (ParseExpressionList(ArgExprs, CommaLocs, [&] {
+                Actions.CodeCompleteCall(getCurScope(), LHS.get(), ArgExprs);
+             })) {
             (void)Actions.CorrectDelayedTyposInExpr(LHS);
             LHS = ExprError();
           }
@@ -2506,17 +2507,14 @@ ExprResult Parser::ParseFoldExpression(E
 /// [C++0x]   assignment-expression
 /// [C++0x]   braced-init-list
 /// \endverbatim
-bool Parser::ParseExpressionList(SmallVectorImpl<Expr*> &Exprs,
+bool Parser::ParseExpressionList(SmallVectorImpl<Expr *> &Exprs,
                                  SmallVectorImpl<SourceLocation> &CommaLocs,
-                                 void (Sema::*Completer)(Scope *S,
-                                                         Expr *Data,
-                                                         ArrayRef<Expr *> Args),
-                                 Expr *Data) {
+                                 std::function<void()> Completer) {
   bool SawError = false;
   while (1) {
     if (Tok.is(tok::code_completion)) {
       if (Completer)
-        (Actions.*Completer)(getCurScope(), Data, Exprs);
+        Completer();
       else
         Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Expression);
       cutOffParsing();

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=226670&r1=226669&r2=226670&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Wed Jan 21 10:24:11 2015
@@ -1597,7 +1597,11 @@ Parser::ParseCXXTypeConstructExpression(
     CommaLocsTy CommaLocs;
 
     if (Tok.isNot(tok::r_paren)) {
-      if (ParseExpressionList(Exprs, CommaLocs)) {
+      if (ParseExpressionList(Exprs, CommaLocs, [&] {
+            Actions.CodeCompleteConstructor(getCurScope(),
+                                      TypeRep.get()->getCanonicalTypeInternal(),
+                                            DS.getLocEnd(), Exprs);
+         })) {
         SkipUntil(tok::r_paren, StopAtSemi);
         return ExprError();
       }
@@ -2668,7 +2672,14 @@ Parser::ParseCXXNewExpression(bool UseGl
     ConstructorLParen = T.getOpenLocation();
     if (Tok.isNot(tok::r_paren)) {
       CommaLocsTy CommaLocs;
-      if (ParseExpressionList(ConstructorArgs, CommaLocs)) {
+      if (ParseExpressionList(ConstructorArgs, CommaLocs, [&] {
+            ParsedType TypeRep = Actions.ActOnTypeName(getCurScope(),
+                                                       DeclaratorInfo).get();
+            Actions.CodeCompleteConstructor(getCurScope(),
+                                      TypeRep.get()->getCanonicalTypeInternal(),
+                                            DeclaratorInfo.getLocEnd(),
+                                            ConstructorArgs);
+      })) {
         SkipUntil(tok::semi, StopAtSemi | StopBeforeMatch);
         return ExprError();
       }

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=226670&r1=226669&r2=226670&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Wed Jan 21 10:24:11 2015
@@ -3819,7 +3819,73 @@ static bool anyNullArguments(ArrayRef<Ex
   return false;
 }
 
-void Sema::CodeCompleteCall(Scope *S, Expr *FnIn, ArrayRef<Expr *> Args) {
+typedef CodeCompleteConsumer::OverloadCandidate ResultCandidate;
+
+void mergeCandidatesWithResults(Sema &SemaRef,
+                                SmallVectorImpl<ResultCandidate> &Results,
+                                OverloadCandidateSet &CandidateSet,
+                                SourceLocation Loc) {
+  if (!CandidateSet.empty()) {
+    // Sort the overload candidate set by placing the best overloads first.
+    std::stable_sort(
+        CandidateSet.begin(), CandidateSet.end(),
+        [&](const OverloadCandidate &X, const OverloadCandidate &Y) {
+          return isBetterOverloadCandidate(SemaRef, X, Y, Loc);
+        });
+
+    // Add the remaining viable overload candidates as code-completion results.
+    for (auto &Candidate : CandidateSet)
+      if (Candidate.Viable)
+        Results.push_back(ResultCandidate(Candidate.Function));
+  }
+}
+
+/// \brief Get the type of the Nth parameter from a given set of overload
+/// candidates.
+QualType getParamType(Sema &SemaRef, ArrayRef<ResultCandidate> Candidates,
+                      unsigned N) {
+
+  // Given the overloads 'Candidates' for a function call matching all arguments
+  // up to N, return the type of the Nth parameter if it is the same for all
+  // overload candidates.
+  QualType ParamType;
+  for (auto &Candidate : Candidates) {
+    if (auto FType = Candidate.getFunctionType())
+      if (auto Proto = dyn_cast<FunctionProtoType>(FType))
+        if (N < Proto->getNumParams()) {
+          if (ParamType.isNull())
+            ParamType = Proto->getParamType(N);
+          else if (!SemaRef.Context.hasSameUnqualifiedType(
+                        ParamType.getNonReferenceType(),
+                        Proto->getParamType(N).getNonReferenceType()))
+            // Otherwise return a default-constructed QualType.
+            return QualType();
+        }
+  }
+
+  return ParamType;
+}
+
+void CodeCompleteOverloadResults(Sema &SemaRef, Scope *S,
+                                 MutableArrayRef<ResultCandidate> Candidates,
+                                 unsigned CurrentArg,
+                                 bool CompleteExpressionWithCurrentArg = true) {
+  QualType ParamType;
+  if (CompleteExpressionWithCurrentArg)
+    ParamType = getParamType(SemaRef, Candidates, CurrentArg);
+
+  if (ParamType.isNull())
+    SemaRef.CodeCompleteOrdinaryName(S, Sema::PCC_Expression);
+  else
+    SemaRef.CodeCompleteExpression(S, ParamType);
+
+  if (!Candidates.empty())
+    SemaRef.CodeCompleter->ProcessOverloadCandidates(SemaRef, CurrentArg,
+                                                     Candidates.data(),
+                                                     Candidates.size());
+}
+
+void Sema::CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef<Expr *> Args) {
   if (!CodeCompleter)
     return;
 
@@ -3828,7 +3894,8 @@ void Sema::CodeCompleteCall(Scope *S, Ex
   // results. We may want to revisit this strategy in the future,
   // e.g., by merging the two kinds of results.
 
-  Expr *Fn = (Expr *)FnIn;
+  // FIXME: Provide support for highlighting optional parameters.
+  // FIXME: Provide support for variadic template functions.
 
   // Ignore type-dependent call expressions entirely.
   if (!Fn || Fn->isTypeDependent() || anyNullArguments(Args) ||
@@ -3841,92 +3908,99 @@ void Sema::CodeCompleteCall(Scope *S, Ex
   SourceLocation Loc = Fn->getExprLoc();
   OverloadCandidateSet CandidateSet(Loc, OverloadCandidateSet::CSK_Normal);
 
-  // FIXME: What if we're calling something that isn't a function declaration?
-  // FIXME: What if we're calling a pseudo-destructor?
-  // FIXME: What if we're calling a member function?
-  
-  typedef CodeCompleteConsumer::OverloadCandidate ResultCandidate;
   SmallVector<ResultCandidate, 8> Results;
 
   Expr *NakedFn = Fn->IgnoreParenCasts();
-  if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn))
+  if (auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn))
     AddOverloadedCallCandidates(ULE, Args, CandidateSet,
-                                /*PartialOverloading=*/ true);
-  else if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(NakedFn)) {
-    FunctionDecl *FDecl = dyn_cast<FunctionDecl>(DRE->getDecl());
-    if (FDecl) {
+                                /*PartialOverloading=*/true);
+  else if (auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
+    TemplateArgumentListInfo TemplateArgsBuffer, *TemplateArgs = nullptr;
+    if (UME->hasExplicitTemplateArgs()) {
+      UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
+      TemplateArgs = &TemplateArgsBuffer;
+    }
+    SmallVector<Expr *, 12> ArgExprs(1, UME->getBase());
+    ArgExprs.append(Args.begin(), Args.end());
+    UnresolvedSet<8> Decls;
+    Decls.append(UME->decls_begin(), UME->decls_end());
+    AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
+                          /*SuppressUsedConversions=*/false,
+                          /*PartialOverloading=*/true);
+  } else if (auto DC = NakedFn->getType()->getCanonicalTypeInternal()
+                       ->getAsCXXRecordDecl()) {
+    // If it's a CXXRecordDecl, it may overload the function call operator,
+    // so we check if it does and add them as candidates.
+    DeclarationName OpName = Context.DeclarationNames
+                             .getCXXOperatorName(OO_Call);
+    LookupResult R(*this, OpName, Loc, LookupOrdinaryName);
+    LookupQualifiedName(R, DC);
+    R.suppressDiagnostics();
+    SmallVector<Expr *, 12> ArgExprs(1, NakedFn);
+    ArgExprs.append(Args.begin(), Args.end());
+    AddFunctionCandidates(R.asUnresolvedSet(), ArgExprs, CandidateSet,
+                          /*ExplicitArgs=*/nullptr,
+                          /*SuppressUsedConversions=*/false,
+                          /*PartialOverloading=*/true);
+  } else {
+    // Lastly we check, as a possibly resolved expression, whether it can be
+    // converted to a function.
+    FunctionDecl *FD = nullptr;
+    if (auto MCE = dyn_cast<MemberExpr>(NakedFn))
+      FD = dyn_cast<FunctionDecl>(MCE->getMemberDecl());
+    else if (auto DRE = dyn_cast<DeclRefExpr>(NakedFn))
+      FD = dyn_cast<FunctionDecl>(DRE->getDecl());
+    if (FD) {
       if (!getLangOpts().CPlusPlus || 
-          !FDecl->getType()->getAs<FunctionProtoType>())
-        Results.push_back(ResultCandidate(FDecl));
+          !FD->getType()->getAs<FunctionProtoType>())
+        Results.push_back(ResultCandidate(FD));
       else
-        // FIXME: access?
-        AddOverloadCandidate(FDecl, DeclAccessPair::make(FDecl, AS_none), Args,
-                             CandidateSet, false, /*PartialOverloading*/true);
+        AddOverloadCandidate(FD, DeclAccessPair::make(FD, FD->getAccess()),
+                             Args, CandidateSet,
+                             /*SuppressUsedConversions=*/false,
+                             /*PartialOverloading=*/true);
     }
   }
-  
-  QualType ParamType;
-  
-  if (!CandidateSet.empty()) {
-    // Sort the overload candidate set by placing the best overloads first.
-    std::stable_sort(
-        CandidateSet.begin(), CandidateSet.end(),
-        [&](const OverloadCandidate &X, const OverloadCandidate &Y) {
-          return isBetterOverloadCandidate(*this, X, Y, Loc);
-        });
 
-    // Add the remaining viable overload candidates as code-completion reslults.
-    for (OverloadCandidateSet::iterator Cand = CandidateSet.begin(),
-                                     CandEnd = CandidateSet.end();
-         Cand != CandEnd; ++Cand) {
-      if (Cand->Viable)
-        Results.push_back(ResultCandidate(Cand->Function));
-    }
+  mergeCandidatesWithResults(*this, Results, CandidateSet, Loc);
+  CodeCompleteOverloadResults(*this, S, Results, Args.size(),
+                              !CandidateSet.empty());
+}
 
-    // From the viable candidates, try to determine the type of this parameter.
-    for (unsigned I = 0, N = Results.size(); I != N; ++I) {
-      if (const FunctionType *FType = Results[I].getFunctionType())
-        if (const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FType))
-          if (Args.size() < Proto->getNumParams()) {
-            if (ParamType.isNull())
-              ParamType = Proto->getParamType(Args.size());
-            else if (!Context.hasSameUnqualifiedType(
-                          ParamType.getNonReferenceType(),
-                          Proto->getParamType(Args.size())
-                              .getNonReferenceType())) {
-              ParamType = QualType();
-              break;
-            }
-          }
-    }
-  } else {
-    // Try to determine the parameter type from the type of the expression
-    // being called.
-    QualType FunctionType = Fn->getType();
-    if (const PointerType *Ptr = FunctionType->getAs<PointerType>())
-      FunctionType = Ptr->getPointeeType();
-    else if (const BlockPointerType *BlockPtr
-                                    = FunctionType->getAs<BlockPointerType>())
-      FunctionType = BlockPtr->getPointeeType();
-    else if (const MemberPointerType *MemPtr
-                                    = FunctionType->getAs<MemberPointerType>())
-      FunctionType = MemPtr->getPointeeType();
-    
-    if (const FunctionProtoType *Proto
-                                  = FunctionType->getAs<FunctionProtoType>()) {
-      if (Args.size() < Proto->getNumParams())
-        ParamType = Proto->getParamType(Args.size());
+void Sema::CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc,
+                                   ArrayRef<Expr *> Args) {
+  if (!CodeCompleter)
+    return;
+
+  // A complete type is needed to lookup for constructors.
+  if (RequireCompleteType(Loc, Type, 0))
+    return;
+
+  // FIXME: Provide support for member initializers.
+  // FIXME: Provide support for variadic template constructors.
+  // FIXME: Provide support for highlighting optional parameters.
+
+  OverloadCandidateSet CandidateSet(Loc, OverloadCandidateSet::CSK_Normal);
+
+  for (auto C : LookupConstructors(Type->getAsCXXRecordDecl())) {
+    if (auto FD = dyn_cast<FunctionDecl>(C)) {
+      AddOverloadCandidate(FD, DeclAccessPair::make(FD, C->getAccess()),
+                           Args, CandidateSet,
+                           /*SuppressUsedConversions=*/false,
+                           /*PartialOverloading=*/true);
+    } else if (auto FTD = dyn_cast<FunctionTemplateDecl>(C)) {
+      AddTemplateOverloadCandidate(FTD,
+                                   DeclAccessPair::make(FTD, C->getAccess()),
+                                   /*ExplicitTemplateArgs=*/nullptr,
+                                   Args, CandidateSet,
+                                   /*SuppressUsedConversions=*/false,
+                                   /*PartialOverloading=*/true);
     }
   }
 
-  if (ParamType.isNull())
-    CodeCompleteOrdinaryName(S, PCC_Expression);
-  else
-    CodeCompleteExpression(S, ParamType);
-  
-  if (!Results.empty())
-    CodeCompleter->ProcessOverloadCandidates(*this, Args.size(), Results.data(),
-                                             Results.size());
+  SmallVector<ResultCandidate, 8> Results;
+  mergeCandidatesWithResults(*this, Results, CandidateSet, Loc);
+  CodeCompleteOverloadResults(*this, S, Results, Args.size());
 }
 
 void Sema::CodeCompleteInitializer(Scope *S, Decl *D) {

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=226670&r1=226669&r2=226670&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Jan 21 10:24:11 2015
@@ -5554,7 +5554,8 @@ Sema::AddOverloadCandidate(FunctionDecl
       // is irrelevant.
       AddMethodCandidate(Method, FoundDecl, Method->getParent(),
                          QualType(), Expr::Classification::makeSimpleLValue(),
-                         Args, CandidateSet, SuppressUserConversions);
+                         Args, CandidateSet, SuppressUserConversions,
+                         PartialOverloading);
       return;
     }
     // We treat a constructor like a non-member function, since its object
@@ -5615,7 +5616,7 @@ Sema::AddOverloadCandidate(FunctionDecl
   // (C++ 13.3.2p2): A candidate function having fewer than m
   // parameters is viable only if it has an ellipsis in its parameter
   // list (8.3.5).
-  if ((Args.size() + (PartialOverloading && Args.size())) > NumParams &&
+  if (TooManyArguments(NumParams, Args.size(), PartialOverloading) &&
       !Proto->isVariadic()) {
     Candidate.Viable = false;
     Candidate.FailureKind = ovl_fail_too_many_arguments;
@@ -5850,8 +5851,9 @@ EnableIfAttr *Sema::CheckEnableIf(Functi
 void Sema::AddFunctionCandidates(const UnresolvedSetImpl &Fns,
                                  ArrayRef<Expr *> Args,
                                  OverloadCandidateSet& CandidateSet,
+                                 TemplateArgumentListInfo *ExplicitTemplateArgs,
                                  bool SuppressUserConversions,
-                               TemplateArgumentListInfo *ExplicitTemplateArgs) {
+                                 bool PartialOverloading) {
   for (UnresolvedSetIterator F = Fns.begin(), E = Fns.end(); F != E; ++F) {
     NamedDecl *D = F.getDecl()->getUnderlyingDecl();
     if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
@@ -5860,10 +5862,10 @@ void Sema::AddFunctionCandidates(const U
                            cast<CXXMethodDecl>(FD)->getParent(),
                            Args[0]->getType(), Args[0]->Classify(Context),
                            Args.slice(1), CandidateSet,
-                           SuppressUserConversions);
+                           SuppressUserConversions, PartialOverloading);
       else
         AddOverloadCandidate(FD, F.getPair(), Args, CandidateSet,
-                             SuppressUserConversions);
+                             SuppressUserConversions, PartialOverloading);
     } else {
       FunctionTemplateDecl *FunTmpl = cast<FunctionTemplateDecl>(D);
       if (isa<CXXMethodDecl>(FunTmpl->getTemplatedDecl()) &&
@@ -5873,11 +5875,13 @@ void Sema::AddFunctionCandidates(const U
                                    ExplicitTemplateArgs,
                                    Args[0]->getType(),
                                    Args[0]->Classify(Context), Args.slice(1),
-                                   CandidateSet, SuppressUserConversions);
+                                   CandidateSet, SuppressUserConversions,
+                                   PartialOverloading);
       else
         AddTemplateOverloadCandidate(FunTmpl, F.getPair(),
                                      ExplicitTemplateArgs, Args,
-                                     CandidateSet, SuppressUserConversions);
+                                     CandidateSet, SuppressUserConversions,
+                                     PartialOverloading);
     }
   }
 }
@@ -5925,7 +5929,8 @@ Sema::AddMethodCandidate(CXXMethodDecl *
                          Expr::Classification ObjectClassification,
                          ArrayRef<Expr *> Args,
                          OverloadCandidateSet &CandidateSet,
-                         bool SuppressUserConversions) {
+                         bool SuppressUserConversions,
+                         bool PartialOverloading) {
   const FunctionProtoType *Proto
     = dyn_cast<FunctionProtoType>(Method->getType()->getAs<FunctionType>());
   assert(Proto && "Methods without a prototype cannot be overloaded");
@@ -5958,7 +5963,8 @@ Sema::AddMethodCandidate(CXXMethodDecl *
   // (C++ 13.3.2p2): A candidate function having fewer than m
   // parameters is viable only if it has an ellipsis in its parameter
   // list (8.3.5).
-  if (Args.size() > NumParams && !Proto->isVariadic()) {
+  if (TooManyArguments(NumParams, Args.size(), PartialOverloading) &&
+      !Proto->isVariadic()) {
     Candidate.Viable = false;
     Candidate.FailureKind = ovl_fail_too_many_arguments;
     return;
@@ -5970,7 +5976,7 @@ Sema::AddMethodCandidate(CXXMethodDecl *
   // parameter list is truncated on the right, so that there are
   // exactly m parameters.
   unsigned MinRequiredArgs = Method->getMinRequiredArguments();
-  if (Args.size() < MinRequiredArgs) {
+  if (Args.size() < MinRequiredArgs && !PartialOverloading) {
     // Not enough arguments.
     Candidate.Viable = false;
     Candidate.FailureKind = ovl_fail_too_few_arguments;
@@ -6052,7 +6058,8 @@ Sema::AddMethodTemplateCandidate(Functio
                                  Expr::Classification ObjectClassification,
                                  ArrayRef<Expr *> Args,
                                  OverloadCandidateSet& CandidateSet,
-                                 bool SuppressUserConversions) {
+                                 bool SuppressUserConversions,
+                                 bool PartialOverloading) {
   if (!CandidateSet.isNewCandidate(MethodTmpl))
     return;
 
@@ -6069,7 +6076,7 @@ Sema::AddMethodTemplateCandidate(Functio
   FunctionDecl *Specialization = nullptr;
   if (TemplateDeductionResult Result
       = DeduceTemplateArguments(MethodTmpl, ExplicitTemplateArgs, Args,
-                                Specialization, Info)) {
+                                Specialization, Info, PartialOverloading)) {
     OverloadCandidate &Candidate = CandidateSet.addCandidate();
     Candidate.FoundDecl = FoundDecl;
     Candidate.Function = MethodTmpl->getTemplatedDecl();
@@ -6090,7 +6097,7 @@ Sema::AddMethodTemplateCandidate(Functio
          "Specialization is not a member function?");
   AddMethodCandidate(cast<CXXMethodDecl>(Specialization), FoundDecl,
                      ActingContext, ObjectType, ObjectClassification, Args,
-                     CandidateSet, SuppressUserConversions);
+                     CandidateSet, SuppressUserConversions, PartialOverloading);
 }
 
 /// \brief Add a C++ function template specialization as a candidate
@@ -6102,7 +6109,8 @@ Sema::AddTemplateOverloadCandidate(Funct
                                  TemplateArgumentListInfo *ExplicitTemplateArgs,
                                    ArrayRef<Expr *> Args,
                                    OverloadCandidateSet& CandidateSet,
-                                   bool SuppressUserConversions) {
+                                   bool SuppressUserConversions,
+                                   bool PartialOverloading) {
   if (!CandidateSet.isNewCandidate(FunctionTemplate))
     return;
 
@@ -6119,7 +6127,7 @@ Sema::AddTemplateOverloadCandidate(Funct
   FunctionDecl *Specialization = nullptr;
   if (TemplateDeductionResult Result
         = DeduceTemplateArguments(FunctionTemplate, ExplicitTemplateArgs, Args,
-                                  Specialization, Info)) {
+                                  Specialization, Info, PartialOverloading)) {
     OverloadCandidate &Candidate = CandidateSet.addCandidate();
     Candidate.FoundDecl = FoundDecl;
     Candidate.Function = FunctionTemplate->getTemplatedDecl();
@@ -6137,7 +6145,7 @@ Sema::AddTemplateOverloadCandidate(Funct
   // deduction as a candidate.
   assert(Specialization && "Missing function template specialization?");
   AddOverloadCandidate(Specialization, FoundDecl, Args, CandidateSet,
-                       SuppressUserConversions);
+                       SuppressUserConversions, PartialOverloading);
 }
 
 /// Determine whether this is an allowable conversion from the result
@@ -8291,7 +8299,7 @@ Sema::AddArgumentDependentLookupCandidat
     } else
       AddTemplateOverloadCandidate(cast<FunctionTemplateDecl>(*I),
                                    FoundDecl, ExplicitTemplateArgs,
-                                   Args, CandidateSet);
+                                   Args, CandidateSet, PartialOverloading);
   }
 }
 
@@ -10363,7 +10371,8 @@ static void AddOverloadedCallCandidate(S
       assert(!KnownValid && "Explicit template arguments?");
       return;
     }
-    S.AddOverloadCandidate(Func, FoundDecl, Args, CandidateSet, false,
+    S.AddOverloadCandidate(Func, FoundDecl, Args, CandidateSet,
+                           /*SuppressUsedConversions=*/false,
                            PartialOverloading);
     return;
   }
@@ -10371,7 +10380,9 @@ static void AddOverloadedCallCandidate(S
   if (FunctionTemplateDecl *FuncTemplate
       = dyn_cast<FunctionTemplateDecl>(Callee)) {
     S.AddTemplateOverloadCandidate(FuncTemplate, FoundDecl,
-                                   ExplicitTemplateArgs, Args, CandidateSet);
+                                   ExplicitTemplateArgs, Args, CandidateSet,
+                                   /*SuppressUsedConversions=*/false,
+                                   PartialOverloading);
     return;
   }
 
@@ -10896,7 +10907,7 @@ Sema::CreateOverloadedUnaryOp(SourceLoca
   OverloadCandidateSet CandidateSet(OpLoc, OverloadCandidateSet::CSK_Operator);
 
   // Add the candidates from the given function set.
-  AddFunctionCandidates(Fns, ArgsArray, CandidateSet, false);
+  AddFunctionCandidates(Fns, ArgsArray, CandidateSet);
 
   // Add operator candidates that are member functions.
   AddMemberOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
@@ -11105,7 +11116,7 @@ Sema::CreateOverloadedBinOp(SourceLocati
   OverloadCandidateSet CandidateSet(OpLoc, OverloadCandidateSet::CSK_Operator);
 
   // Add the candidates from the given function set.
-  AddFunctionCandidates(Fns, Args, CandidateSet, false);
+  AddFunctionCandidates(Fns, Args, CandidateSet);
 
   // Add operator candidates that are member functions.
   AddMemberOperatorCandidates(Op, OpLoc, Args, CandidateSet);
@@ -12154,8 +12165,8 @@ ExprResult Sema::BuildLiteralOperatorCal
 
   OverloadCandidateSet CandidateSet(UDSuffixLoc,
                                     OverloadCandidateSet::CSK_Normal);
-  AddFunctionCandidates(R.asUnresolvedSet(), Args, CandidateSet, true,
-                        TemplateArgs);
+  AddFunctionCandidates(R.asUnresolvedSet(), Args, CandidateSet, TemplateArgs,
+                        /*SuppressUserConversions=*/true);
 
   bool HadMultipleCandidates = (CandidateSet.size() > 1);
 

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=226670&r1=226669&r2=226670&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed Jan 21 10:24:11 2015
@@ -2784,7 +2784,8 @@ Sema::FinishTemplateArgumentDeduction(Fu
                                       unsigned NumExplicitlySpecified,
                                       FunctionDecl *&Specialization,
                                       TemplateDeductionInfo &Info,
-        SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs) {
+        SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs,
+                                      bool PartialOverloading) {
   TemplateParameterList *TemplateParams
     = FunctionTemplate->getTemplateParameters();
 
@@ -2911,6 +2912,8 @@ Sema::FinishTemplateArgumentDeduction(Fu
                          const_cast<NamedDecl *>(TemplateParams->getParam(I)));
       Info.reset(TemplateArgumentList::CreateCopy(Context, Builder.data(),
                                                   Builder.size()));
+      if (PartialOverloading) break;
+
       return HasDefaultArg ? TDK_SubstitutionFailure : TDK_Incomplete;
     }
 
@@ -3285,26 +3288,28 @@ DeduceTemplateArgumentByListElement(Sema
 Sema::TemplateDeductionResult Sema::DeduceTemplateArguments(
     FunctionTemplateDecl *FunctionTemplate,
     TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
-    FunctionDecl *&Specialization, TemplateDeductionInfo &Info) {
+    FunctionDecl *&Specialization, TemplateDeductionInfo &Info,
+    bool PartialOverloading) {
   if (FunctionTemplate->isInvalidDecl())
     return TDK_Invalid;
 
   FunctionDecl *Function = FunctionTemplate->getTemplatedDecl();
+  unsigned NumParams = Function->getNumParams();
 
   // C++ [temp.deduct.call]p1:
   //   Template argument deduction is done by comparing each function template
   //   parameter type (call it P) with the type of the corresponding argument
   //   of the call (call it A) as described below.
   unsigned CheckArgs = Args.size();
-  if (Args.size() < Function->getMinRequiredArguments())
+  if (Args.size() < Function->getMinRequiredArguments() && !PartialOverloading)
     return TDK_TooFewArguments;
-  else if (Args.size() > Function->getNumParams()) {
+  else if (TooManyArguments(NumParams, Args.size(), PartialOverloading)) {
     const FunctionProtoType *Proto
       = Function->getType()->getAs<FunctionProtoType>();
     if (Proto->isTemplateVariadic())
       /* Do nothing */;
     else if (Proto->isVariadic())
-      CheckArgs = Function->getNumParams();
+      CheckArgs = NumParams;
     else
       return TDK_TooManyArguments;
   }
@@ -3331,7 +3336,7 @@ Sema::TemplateDeductionResult Sema::Dedu
     NumExplicitlySpecified = Deduced.size();
   } else {
     // Just fill in the parameter types from the function declaration.
-    for (unsigned I = 0, N = Function->getNumParams(); I != N; ++I)
+    for (unsigned I = 0; I != NumParams; ++I)
       ParamTypes.push_back(Function->getParamDecl(I)->getType());
   }
 
@@ -3339,8 +3344,8 @@ Sema::TemplateDeductionResult Sema::Dedu
   Deduced.resize(TemplateParams->size());
   unsigned ArgIdx = 0;
   SmallVector<OriginalCallArg, 4> OriginalCallArgs;
-  for (unsigned ParamIdx = 0, NumParams = ParamTypes.size();
-       ParamIdx != NumParams; ++ParamIdx) {
+  for (unsigned ParamIdx = 0, NumParamTypes = ParamTypes.size();
+       ParamIdx != NumParamTypes; ++ParamIdx) {
     QualType OrigParamType = ParamTypes[ParamIdx];
     QualType ParamType = OrigParamType;
     
@@ -3409,7 +3414,7 @@ Sema::TemplateDeductionResult Sema::Dedu
     //   the function parameter pack. For a function parameter pack that does
     //   not occur at the end of the parameter-declaration-list, the type of
     //   the parameter pack is a non-deduced context.
-    if (ParamIdx + 1 < NumParams)
+    if (ParamIdx + 1 < NumParamTypes)
       break;
 
     QualType ParamPattern = ParamExpansion->getPattern();
@@ -3479,7 +3484,8 @@ Sema::TemplateDeductionResult Sema::Dedu
 
   return FinishTemplateArgumentDeduction(FunctionTemplate, Deduced,
                                          NumExplicitlySpecified, Specialization,
-                                         Info, &OriginalCallArgs);
+                                         Info, &OriginalCallArgs,
+                                         PartialOverloading);
 }
 
 QualType Sema::adjustCCAndNoReturn(QualType ArgFunctionType,

Modified: cfe/trunk/test/Index/code-completion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/code-completion.cpp?rev=226670&r1=226669&r2=226670&view=diff
==============================================================================
--- cfe/trunk/test/Index/code-completion.cpp (original)
+++ cfe/trunk/test/Index/code-completion.cpp Wed Jan 21 10:24:11 2015
@@ -58,9 +58,9 @@ Z::operator int() const {
 // CHECK-MEMBER-NEXT: Container is complete
 // CHECK-MEMBER-NEXT: Container USR: c:@S at Z
 
-// CHECK-OVERLOAD: NotImplemented:{ResultType int &}{Text overloaded}{LeftParen (}{Text Z z}{Comma , }{CurrentParameter int second}{RightParen )}
-// CHECK-OVERLOAD: NotImplemented:{ResultType float &}{Text overloaded}{LeftParen (}{Text int i}{Comma , }{CurrentParameter long second}{RightParen )}
-// CHECK-OVERLOAD: NotImplemented:{ResultType double &}{Text overloaded}{LeftParen (}{Text float f}{Comma , }{CurrentParameter int second}{RightParen )}
+// CHECK-OVERLOAD: OverloadCandidate:{ResultType int &}{Text overloaded}{LeftParen (}{Text Z z}{Comma , }{CurrentParameter int second}{RightParen )}
+// CHECK-OVERLOAD: OverloadCandidate:{ResultType float &}{Text overloaded}{LeftParen (}{Text int i}{Comma , }{CurrentParameter long second}{RightParen )}
+// CHECK-OVERLOAD: OverloadCandidate:{ResultType double &}{Text overloaded}{LeftParen (}{Text float f}{Comma , }{CurrentParameter int second}{RightParen )}
 // CHECK-OVERLOAD: Completion contexts:
 // CHECK-OVERLOAD-NEXT: Any type
 // CHECK-OVERLOAD-NEXT: Any value

Added: cfe/trunk/test/Index/complete-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-call.cpp?rev=226670&view=auto
==============================================================================
--- cfe/trunk/test/Index/complete-call.cpp (added)
+++ cfe/trunk/test/Index/complete-call.cpp Wed Jan 21 10:24:11 2015
@@ -0,0 +1,805 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+void foo_1();
+void foo_2(int);
+void foo_2(void *);
+void foo_3(int, int);
+void foo_3(void *, void *);
+void foo_4(int, int);
+void foo_4(void *, int);
+void foo_5(int, int);
+void foo_5(int, void *);
+template<class T> void foo_6();
+template<class T> void foo_7(T);
+template<class T> void foo_8(T, T);
+template<class T> void foo_9(int, T);
+template<class T> void foo_9(void *, T);
+template<class T> void foo_10(T, int, int);
+template<class U> void foo_10(U, void *, void *);
+template<class T, class U> void foo_11(T, U);
+template<class T = int> void foo_12(T, T);
+template<class V>
+struct S {
+  void foo_1();
+  void foo_2(int);
+  void foo_2(void *);
+  void foo_3(int, int);
+  void foo_3(void *, void *);
+  void foo_4(int, int);
+  void foo_4(void *, int);
+  void foo_5(int, int);
+  void foo_5(int, void *);
+  template<class T> void foo_6();
+  template<class T> void foo_7(T);
+  template<class T> void foo_8(T, T);
+  template<class T> void foo_9(int, T);
+  template<class T> void foo_9(void *, T);
+  template<class T> void foo_10(T, int, int);
+  template<class U> void foo_10(U, void *, void *);
+  template<class T, class U> void foo_11(T, U);
+  template<class T = int> void foo_12(T, T);
+  template<class T> void foo_13(V, T, T);
+};
+
+int main() {
+  void *p = 0;
+  foo_1();
+  foo_2(42);
+  foo_3(42, 42);
+  foo_3(p, p);
+  foo_4(42, 42);
+  foo_4(p, 42);
+  foo_5(42, 42);
+  foo_6<int>();
+  foo_7(42);
+  foo_7<int>(42);
+  foo_8(42, 42);
+  foo_9(42, 42);
+  foo_9(p, 42);
+  foo_10(42, 42, 42);
+  foo_11(42, 42);
+  foo_11<int>(42, 42);
+  foo_11<int, void *>(42, p);
+  foo_12(p, p);
+
+  S<int> s;
+  s.foo_1();
+  s.foo_2(42);
+  s.foo_3(42, 42);
+  s.foo_3(p, p);
+  s.foo_4(42, 42);
+  s.foo_4(p, 42);
+  s.foo_5(42, 42);
+  s.foo_6<int>();
+  s.foo_7(42);
+  s.foo_7<int>(42);
+  s.foo_8(42, 42);
+  s.foo_9(42, 42);
+  s.foo_9(p, 42);
+  s.foo_10(42, 42, 42);
+  s.foo_11(42, 42);
+  s.foo_11<int>(42, 42);
+  s.foo_11<int, void *>(42, p);
+  s.foo_12(p, p);
+  s.foo_13(42, 42, 42);
+
+  foo_1(42,);
+  foo_2(42,);
+  foo_6<int>(42,);
+  foo_7(42,);
+  s.foo_1(42,);
+  s.foo_2(42,);
+  s.foo_6<int>(42,);
+  s.foo_7(42,);
+}
+
+// RUN: c-index-test -code-completion-at=%s:47:9 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1)
+// CHECK-CC1: Completion contexts:
+// CHECK-CC1-NEXT: Any type
+// CHECK-CC1-NEXT: Any value
+// CHECK-CC1-NEXT: Enum tag
+// CHECK-CC1-NEXT: Union tag
+// CHECK-CC1-NEXT: Struct tag
+// CHECK-CC1-NEXT: Class name
+// CHECK-CC1-NEXT: Nested name specifier
+// CHECK-CC1-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:48:9 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: OverloadCandidate:{ResultType void}{Text foo_2}{LeftParen (}{CurrentParameter void *}{RightParen )} (1)
+// CHECK-CC2: OverloadCandidate:{ResultType void}{Text foo_2}{LeftParen (}{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC2: Completion contexts:
+// CHECK-CC2-NEXT: Any type
+// CHECK-CC2-NEXT: Any value
+// CHECK-CC2-NEXT: Enum tag
+// CHECK-CC2-NEXT: Union tag
+// CHECK-CC2-NEXT: Struct tag
+// CHECK-CC2-NEXT: Class name
+// CHECK-CC2-NEXT: Nested name specifier
+// CHECK-CC2-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:49:9 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: OverloadCandidate:{ResultType void}{Text foo_3}{LeftParen (}{CurrentParameter void *}{Comma , }{Text void *}{RightParen )} (1)
+// CHECK-CC3: OverloadCandidate:{ResultType void}{Text foo_3}{LeftParen (}{CurrentParameter int}{Comma , }{Text int}{RightParen )} (1)
+// CHECK-CC3: Completion contexts:
+// CHECK-CC3-NEXT: Any type
+// CHECK-CC3-NEXT: Any value
+// CHECK-CC3-NEXT: Enum tag
+// CHECK-CC3-NEXT: Union tag
+// CHECK-CC3-NEXT: Struct tag
+// CHECK-CC3-NEXT: Class name
+// CHECK-CC3-NEXT: Nested name specifier
+// CHECK-CC3-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:49:12 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: OverloadCandidate:{ResultType void}{Text foo_3}{LeftParen (}{Text int}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC4: Completion contexts:
+// CHECK-CC4-NEXT: Any type
+// CHECK-CC4-NEXT: Any value
+// CHECK-CC4-NEXT: Enum tag
+// CHECK-CC4-NEXT: Union tag
+// CHECK-CC4-NEXT: Struct tag
+// CHECK-CC4-NEXT: Class name
+// CHECK-CC4-NEXT: Nested name specifier
+// CHECK-CC4-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:50:11 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: OverloadCandidate:{ResultType void}{Text foo_3}{LeftParen (}{Text void *}{Comma , }{CurrentParameter void *}{RightParen )} (1)
+// CHECK-CC5: Completion contexts:
+// CHECK-CC5-NEXT: Any type
+// CHECK-CC5-NEXT: Any value
+// CHECK-CC5-NEXT: Enum tag
+// CHECK-CC5-NEXT: Union tag
+// CHECK-CC5-NEXT: Struct tag
+// CHECK-CC5-NEXT: Class name
+// CHECK-CC5-NEXT: Nested name specifier
+// CHECK-CC5-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:51:12 %s | FileCheck -check-prefix=CHECK-CC6 %s
+// CHECK-CC6: OverloadCandidate:{ResultType void}{Text foo_4}{LeftParen (}{Text int}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC6: Completion contexts:
+// CHECK-CC6-NEXT: Any type
+// CHECK-CC6-NEXT: Any value
+// CHECK-CC6-NEXT: Enum tag
+// CHECK-CC6-NEXT: Union tag
+// CHECK-CC6-NEXT: Struct tag
+// CHECK-CC6-NEXT: Class name
+// CHECK-CC6-NEXT: Nested name specifier
+// CHECK-CC6-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:52:11 %s | FileCheck -check-prefix=CHECK-CC7 %s
+// CHECK-CC7: OverloadCandidate:{ResultType void}{Text foo_4}{LeftParen (}{Text void *}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC7: Completion contexts:
+// CHECK-CC7-NEXT: Any type
+// CHECK-CC7-NEXT: Any value
+// CHECK-CC7-NEXT: Enum tag
+// CHECK-CC7-NEXT: Union tag
+// CHECK-CC7-NEXT: Struct tag
+// CHECK-CC7-NEXT: Class name
+// CHECK-CC7-NEXT: Nested name specifier
+// CHECK-CC7-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:53:12 %s | FileCheck -check-prefix=CHECK-CC8 %s
+// CHECK-CC8: OverloadCandidate:{ResultType void}{Text foo_5}{LeftParen (}{Text int}{Comma , }{CurrentParameter void *}{RightParen )} (1)
+// CHECK-CC8: OverloadCandidate:{ResultType void}{Text foo_5}{LeftParen (}{Text int}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC8: Completion contexts:
+// CHECK-CC8-NEXT: Any type
+// CHECK-CC8-NEXT: Any value
+// CHECK-CC8-NEXT: Enum tag
+// CHECK-CC8-NEXT: Union tag
+// CHECK-CC8-NEXT: Struct tag
+// CHECK-CC8-NEXT: Class name
+// CHECK-CC8-NEXT: Nested name specifier
+// CHECK-CC8-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:54:14 %s | FileCheck -check-prefix=CHECK-CC9 %s
+// CHECK-CC9: OverloadCandidate:{ResultType void}{Text foo_6}{LeftParen (}{RightParen )} (1)
+// CHECK-CC9: Completion contexts:
+// CHECK-CC9-NEXT: Any type
+// CHECK-CC9-NEXT: Any value
+// CHECK-CC9-NEXT: Enum tag
+// CHECK-CC9-NEXT: Union tag
+// CHECK-CC9-NEXT: Struct tag
+// CHECK-CC9-NEXT: Class name
+// CHECK-CC9-NEXT: Nested name specifier
+// CHECK-CC9-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:55:9 %s | FileCheck -check-prefix=CHECK-CC10 %s
+// CHECK-CC10: OverloadCandidate:{ResultType void}{Text foo_7}{LeftParen (}{CurrentParameter T}{RightParen )} (1)
+// CHECK-CC10: Completion contexts:
+// CHECK-CC10-NEXT: Any type
+// CHECK-CC10-NEXT: Any value
+// CHECK-CC10-NEXT: Enum tag
+// CHECK-CC10-NEXT: Union tag
+// CHECK-CC10-NEXT: Struct tag
+// CHECK-CC10-NEXT: Class name
+// CHECK-CC10-NEXT: Nested name specifier
+// CHECK-CC10-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:56:14 %s | FileCheck -check-prefix=CHECK-CC11 %s
+// CHECK-CC11: OverloadCandidate:{ResultType void}{Text foo_7}{LeftParen (}{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC11: Completion contexts:
+// CHECK-CC11-NEXT: Any type
+// CHECK-CC11-NEXT: Any value
+// CHECK-CC11-NEXT: Enum tag
+// CHECK-CC11-NEXT: Union tag
+// CHECK-CC11-NEXT: Struct tag
+// CHECK-CC11-NEXT: Class name
+// CHECK-CC11-NEXT: Nested name specifier
+// CHECK-CC11-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:57:12 %s | FileCheck -check-prefix=CHECK-CC12 %s
+// CHECK-CC12: OverloadCandidate:{ResultType void}{Text foo_8}{LeftParen (}{Text int}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC12: Completion contexts:
+// CHECK-CC12-NEXT: Any type
+// CHECK-CC12-NEXT: Any value
+// CHECK-CC12-NEXT: Enum tag
+// CHECK-CC12-NEXT: Union tag
+// CHECK-CC12-NEXT: Struct tag
+// CHECK-CC12-NEXT: Class name
+// CHECK-CC12-NEXT: Nested name specifier
+// CHECK-CC12-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:58:12 %s | FileCheck -check-prefix=CHECK-CC13 %s
+// CHECK-CC13: OverloadCandidate:{ResultType void}{Text foo_9}{LeftParen (}{Text int}{Comma , }{CurrentParameter T}{RightParen )} (1)
+// CHECK-CC13: Completion contexts:
+// CHECK-CC13-NEXT: Any type
+// CHECK-CC13-NEXT: Any value
+// CHECK-CC13-NEXT: Enum tag
+// CHECK-CC13-NEXT: Union tag
+// CHECK-CC13-NEXT: Struct tag
+// CHECK-CC13-NEXT: Class name
+// CHECK-CC13-NEXT: Nested name specifier
+// CHECK-CC13-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:59:11 %s | FileCheck -check-prefix=CHECK-CC14 %s
+// CHECK-CC14: OverloadCandidate:{ResultType void}{Text foo_9}{LeftParen (}{Text void *}{Comma , }{CurrentParameter T}{RightParen )} (1)
+// CHECK-CC14: Completion contexts:
+// CHECK-CC14-NEXT: Any type
+// CHECK-CC14-NEXT: Any value
+// CHECK-CC14-NEXT: Enum tag
+// CHECK-CC14-NEXT: Union tag
+// CHECK-CC14-NEXT: Struct tag
+// CHECK-CC14-NEXT: Class name
+// CHECK-CC14-NEXT: Nested name specifier
+// CHECK-CC14-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:60:10 %s | FileCheck -check-prefix=CHECK-CC15 %s
+// CHECK-CC15: OverloadCandidate:{ResultType void}{Text foo_10}{LeftParen (}{CurrentParameter U}{Comma , }{Text void *}{Comma , }{Text void *}{RightParen )} (1)
+// CHECK-CC15: OverloadCandidate:{ResultType void}{Text foo_10}{LeftParen (}{CurrentParameter T}{Comma , }{Text int}{Comma , }{Text int}{RightParen )} (1)
+// CHECK-CC15: Completion contexts:
+// CHECK-CC15-NEXT: Any type
+// CHECK-CC15-NEXT: Any value
+// CHECK-CC15-NEXT: Enum tag
+// CHECK-CC15-NEXT: Union tag
+// CHECK-CC15-NEXT: Struct tag
+// CHECK-CC15-NEXT: Class name
+// CHECK-CC15-NEXT: Nested name specifier
+// CHECK-CC15-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:60:13 %s | FileCheck -check-prefix=CHECK-CC16 %s
+// CHECK-CC16: OverloadCandidate:{ResultType void}{Text foo_10}{LeftParen (}{Text int}{Comma , }{CurrentParameter void *}{Comma , }{Text void *}{RightParen )} (1)
+// CHECK-CC16: OverloadCandidate:{ResultType void}{Text foo_10}{LeftParen (}{Text int}{Comma , }{CurrentParameter int}{Comma , }{Text int}{RightParen )} (1)
+// CHECK-CC16: Completion contexts:
+// CHECK-CC16-NEXT: Any type
+// CHECK-CC16-NEXT: Any value
+// CHECK-CC16-NEXT: Enum tag
+// CHECK-CC16-NEXT: Union tag
+// CHECK-CC16-NEXT: Struct tag
+// CHECK-CC16-NEXT: Class name
+// CHECK-CC16-NEXT: Nested name specifier
+// CHECK-CC16-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:60:17 %s | FileCheck -check-prefix=CHECK-CC17 %s
+// CHECK-CC17: OverloadCandidate:{ResultType void}{Text foo_10}{LeftParen (}{Text int}{Comma , }{Text int}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC17: Completion contexts:
+// CHECK-CC17-NEXT: Any type
+// CHECK-CC17-NEXT: Any value
+// CHECK-CC17-NEXT: Enum tag
+// CHECK-CC17-NEXT: Union tag
+// CHECK-CC17-NEXT: Struct tag
+// CHECK-CC17-NEXT: Class name
+// CHECK-CC17-NEXT: Nested name specifier
+// CHECK-CC17-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:61:10 %s | FileCheck -check-prefix=CHECK-CC18 %s
+// CHECK-CC18: OverloadCandidate:{ResultType void}{Text foo_11}{LeftParen (}{CurrentParameter T}{Comma , }{Text U}{RightParen )} (1)
+// CHECK-CC18: Completion contexts:
+// CHECK-CC18-NEXT: Any type
+// CHECK-CC18-NEXT: Any value
+// CHECK-CC18-NEXT: Enum tag
+// CHECK-CC18-NEXT: Union tag
+// CHECK-CC18-NEXT: Struct tag
+// CHECK-CC18-NEXT: Class name
+// CHECK-CC18-NEXT: Nested name specifier
+// CHECK-CC18-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:61:13 %s | FileCheck -check-prefix=CHECK-CC19 %s
+// CHECK-CC19: OverloadCandidate:{ResultType void}{Text foo_11}{LeftParen (}{Text int}{Comma , }{CurrentParameter U}{RightParen )} (1)
+// CHECK-CC19: Completion contexts:
+// CHECK-CC19-NEXT: Any type
+// CHECK-CC19-NEXT: Any value
+// CHECK-CC19-NEXT: Enum tag
+// CHECK-CC19-NEXT: Union tag
+// CHECK-CC19-NEXT: Struct tag
+// CHECK-CC19-NEXT: Class name
+// CHECK-CC19-NEXT: Nested name specifier
+// CHECK-CC19-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:62:15 %s | FileCheck -check-prefix=CHECK-CC20 %s
+// CHECK-CC20: OverloadCandidate:{ResultType void}{Text foo_11}{LeftParen (}{CurrentParameter int}{Comma , }{Text U}{RightParen )} (1)
+// CHECK-CC20: Completion contexts:
+// CHECK-CC20-NEXT: Any type
+// CHECK-CC20-NEXT: Any value
+// CHECK-CC20-NEXT: Enum tag
+// CHECK-CC20-NEXT: Union tag
+// CHECK-CC20-NEXT: Struct tag
+// CHECK-CC20-NEXT: Class name
+// CHECK-CC20-NEXT: Nested name specifier
+// CHECK-CC20-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:62:18 %s | FileCheck -check-prefix=CHECK-CC21 %s
+// CHECK-CC21: OverloadCandidate:{ResultType void}{Text foo_11}{LeftParen (}{Text int}{Comma , }{CurrentParameter U}{RightParen )} (1)
+// CHECK-CC21: Completion contexts:
+// CHECK-CC21-NEXT: Any type
+// CHECK-CC21-NEXT: Any value
+// CHECK-CC21-NEXT: Enum tag
+// CHECK-CC21-NEXT: Union tag
+// CHECK-CC21-NEXT: Struct tag
+// CHECK-CC21-NEXT: Class name
+// CHECK-CC21-NEXT: Nested name specifier
+// CHECK-CC21-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:63:26 %s | FileCheck -check-prefix=CHECK-CC22 %s
+// CHECK-CC22: OverloadCandidate:{ResultType void}{Text foo_11}{LeftParen (}{Text int}{Comma , }{CurrentParameter void *}{RightParen )} (1)
+// CHECK-CC22: Completion contexts:
+// CHECK-CC22-NEXT: Any type
+// CHECK-CC22-NEXT: Any value
+// CHECK-CC22-NEXT: Enum tag
+// CHECK-CC22-NEXT: Union tag
+// CHECK-CC22-NEXT: Struct tag
+// CHECK-CC22-NEXT: Class name
+// CHECK-CC22-NEXT: Nested name specifier
+// CHECK-CC22-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:64:10 %s | FileCheck -check-prefix=CHECK-CC23 %s
+// CHECK-CC23: OverloadCandidate:{ResultType void}{Text foo_12}{LeftParen (}{CurrentParameter int}{Comma , }{Text int}{RightParen )} (1)
+// CHECK-CC23: Completion contexts:
+// CHECK-CC23-NEXT: Any type
+// CHECK-CC23-NEXT: Any value
+// CHECK-CC23-NEXT: Enum tag
+// CHECK-CC23-NEXT: Union tag
+// CHECK-CC23-NEXT: Struct tag
+// CHECK-CC23-NEXT: Class name
+// CHECK-CC23-NEXT: Nested name specifier
+// CHECK-CC23-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:64:12 %s | FileCheck -check-prefix=CHECK-CC24 %s
+// CHECK-CC24: OverloadCandidate:{ResultType void}{Text foo_12}{LeftParen (}{Text void *}{Comma , }{CurrentParameter void *}{RightParen )} (1)
+// CHECK-CC24: Completion contexts:
+// CHECK-CC24-NEXT: Any type
+// CHECK-CC24-NEXT: Any value
+// CHECK-CC24-NEXT: Enum tag
+// CHECK-CC24-NEXT: Union tag
+// CHECK-CC24-NEXT: Struct tag
+// CHECK-CC24-NEXT: Class name
+// CHECK-CC24-NEXT: Nested name specifier
+// CHECK-CC24-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:67:11 %s | FileCheck -check-prefix=CHECK-CC25 %s
+// CHECK-CC25: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1)
+// CHECK-CC25: Completion contexts:
+// CHECK-CC25-NEXT: Any type
+// CHECK-CC25-NEXT: Any value
+// CHECK-CC25-NEXT: Enum tag
+// CHECK-CC25-NEXT: Union tag
+// CHECK-CC25-NEXT: Struct tag
+// CHECK-CC25-NEXT: Class name
+// CHECK-CC25-NEXT: Nested name specifier
+// CHECK-CC25-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:68:11 %s | FileCheck -check-prefix=CHECK-CC26 %s
+// CHECK-CC26: OverloadCandidate:{ResultType void}{Text foo_2}{LeftParen (}{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC26: OverloadCandidate:{ResultType void}{Text foo_2}{LeftParen (}{CurrentParameter void *}{RightParen )} (1)
+// CHECK-CC26: Completion contexts:
+// CHECK-CC26-NEXT: Any type
+// CHECK-CC26-NEXT: Any value
+// CHECK-CC26-NEXT: Enum tag
+// CHECK-CC26-NEXT: Union tag
+// CHECK-CC26-NEXT: Struct tag
+// CHECK-CC26-NEXT: Class name
+// CHECK-CC26-NEXT: Nested name specifier
+// CHECK-CC26-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:69:11 %s | FileCheck -check-prefix=CHECK-CC27 %s
+// CHECK-CC27: OverloadCandidate:{ResultType void}{Text foo_3}{LeftParen (}{CurrentParameter int}{Comma , }{Text int}{RightParen )} (1)
+// CHECK-CC27: OverloadCandidate:{ResultType void}{Text foo_3}{LeftParen (}{CurrentParameter void *}{Comma , }{Text void *}{RightParen )} (1)
+// CHECK-CC27: Completion contexts:
+// CHECK-CC27-NEXT: Any type
+// CHECK-CC27-NEXT: Any value
+// CHECK-CC27-NEXT: Enum tag
+// CHECK-CC27-NEXT: Union tag
+// CHECK-CC27-NEXT: Struct tag
+// CHECK-CC27-NEXT: Class name
+// CHECK-CC27-NEXT: Nested name specifier
+// CHECK-CC27-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:69:14 %s | FileCheck -check-prefix=CHECK-CC28 %s
+// CHECK-CC28: OverloadCandidate:{ResultType void}{Text foo_3}{LeftParen (}{Text int}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC28: Completion contexts:
+// CHECK-CC28-NEXT: Any type
+// CHECK-CC28-NEXT: Any value
+// CHECK-CC28-NEXT: Enum tag
+// CHECK-CC28-NEXT: Union tag
+// CHECK-CC28-NEXT: Struct tag
+// CHECK-CC28-NEXT: Class name
+// CHECK-CC28-NEXT: Nested name specifier
+// CHECK-CC28-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:70:13 %s | FileCheck -check-prefix=CHECK-CC29 %s
+// CHECK-CC29: OverloadCandidate:{ResultType void}{Text foo_3}{LeftParen (}{Text void *}{Comma , }{CurrentParameter void *}{RightParen )} (1)
+// CHECK-CC29: Completion contexts:
+// CHECK-CC29-NEXT: Any type
+// CHECK-CC29-NEXT: Any value
+// CHECK-CC29-NEXT: Enum tag
+// CHECK-CC29-NEXT: Union tag
+// CHECK-CC29-NEXT: Struct tag
+// CHECK-CC29-NEXT: Class name
+// CHECK-CC29-NEXT: Nested name specifier
+// CHECK-CC29-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:71:14 %s | FileCheck -check-prefix=CHECK-CC30 %s
+// CHECK-CC30: OverloadCandidate:{ResultType void}{Text foo_4}{LeftParen (}{Text int}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC30: Completion contexts:
+// CHECK-CC30-NEXT: Any type
+// CHECK-CC30-NEXT: Any value
+// CHECK-CC30-NEXT: Enum tag
+// CHECK-CC30-NEXT: Union tag
+// CHECK-CC30-NEXT: Struct tag
+// CHECK-CC30-NEXT: Class name
+// CHECK-CC30-NEXT: Nested name specifier
+// CHECK-CC30-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:72:13 %s | FileCheck -check-prefix=CHECK-CC31 %s
+// CHECK-CC31: OverloadCandidate:{ResultType void}{Text foo_4}{LeftParen (}{Text void *}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC31: Completion contexts:
+// CHECK-CC31-NEXT: Any type
+// CHECK-CC31-NEXT: Any value
+// CHECK-CC31-NEXT: Enum tag
+// CHECK-CC31-NEXT: Union tag
+// CHECK-CC31-NEXT: Struct tag
+// CHECK-CC31-NEXT: Class name
+// CHECK-CC31-NEXT: Nested name specifier
+// CHECK-CC31-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:73:14 %s | FileCheck -check-prefix=CHECK-CC32 %s
+// CHECK-CC32: OverloadCandidate:{ResultType void}{Text foo_5}{LeftParen (}{Text int}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC32: OverloadCandidate:{ResultType void}{Text foo_5}{LeftParen (}{Text int}{Comma , }{CurrentParameter void *}{RightParen )} (1)
+// CHECK-CC32: Completion contexts:
+// CHECK-CC32-NEXT: Any type
+// CHECK-CC32-NEXT: Any value
+// CHECK-CC32-NEXT: Enum tag
+// CHECK-CC32-NEXT: Union tag
+// CHECK-CC32-NEXT: Struct tag
+// CHECK-CC32-NEXT: Class name
+// CHECK-CC32-NEXT: Nested name specifier
+// CHECK-CC32-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:74:16 %s | FileCheck -check-prefix=CHECK-CC33 %s
+// CHECK-CC33: OverloadCandidate:{ResultType void}{Text foo_6}{LeftParen (}{RightParen )} (1)
+// CHECK-CC33: Completion contexts:
+// CHECK-CC33-NEXT: Any type
+// CHECK-CC33-NEXT: Any value
+// CHECK-CC33-NEXT: Enum tag
+// CHECK-CC33-NEXT: Union tag
+// CHECK-CC33-NEXT: Struct tag
+// CHECK-CC33-NEXT: Class name
+// CHECK-CC33-NEXT: Nested name specifier
+// CHECK-CC33-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:75:11 %s | FileCheck -check-prefix=CHECK-CC34 %s
+// CHECK-CC34: OverloadCandidate:{ResultType void}{Text foo_7}{LeftParen (}{CurrentParameter T}{RightParen )} (1)
+// CHECK-CC34: Completion contexts:
+// CHECK-CC34-NEXT: Any type
+// CHECK-CC34-NEXT: Any value
+// CHECK-CC34-NEXT: Enum tag
+// CHECK-CC34-NEXT: Union tag
+// CHECK-CC34-NEXT: Struct tag
+// CHECK-CC34-NEXT: Class name
+// CHECK-CC34-NEXT: Nested name specifier
+// CHECK-CC34-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:76:16 %s | FileCheck -check-prefix=CHECK-CC35 %s
+// CHECK-CC35: OverloadCandidate:{ResultType void}{Text foo_7}{LeftParen (}{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC35: Completion contexts:
+// CHECK-CC35-NEXT: Any type
+// CHECK-CC35-NEXT: Any value
+// CHECK-CC35-NEXT: Enum tag
+// CHECK-CC35-NEXT: Union tag
+// CHECK-CC35-NEXT: Struct tag
+// CHECK-CC35-NEXT: Class name
+// CHECK-CC35-NEXT: Nested name specifier
+// CHECK-CC35-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:77:14 %s | FileCheck -check-prefix=CHECK-CC36 %s
+// CHECK-CC36: OverloadCandidate:{ResultType void}{Text foo_8}{LeftParen (}{Text int}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC36: Completion contexts:
+// CHECK-CC36-NEXT: Any type
+// CHECK-CC36-NEXT: Any value
+// CHECK-CC36-NEXT: Enum tag
+// CHECK-CC36-NEXT: Union tag
+// CHECK-CC36-NEXT: Struct tag
+// CHECK-CC36-NEXT: Class name
+// CHECK-CC36-NEXT: Nested name specifier
+// CHECK-CC36-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:78:14 %s | FileCheck -check-prefix=CHECK-CC37 %s
+// CHECK-CC37: OverloadCandidate:{ResultType void}{Text foo_9}{LeftParen (}{Text int}{Comma , }{CurrentParameter T}{RightParen )} (1)
+// CHECK-CC37: Completion contexts:
+// CHECK-CC37-NEXT: Any type
+// CHECK-CC37-NEXT: Any value
+// CHECK-CC37-NEXT: Enum tag
+// CHECK-CC37-NEXT: Union tag
+// CHECK-CC37-NEXT: Struct tag
+// CHECK-CC37-NEXT: Class name
+// CHECK-CC37-NEXT: Nested name specifier
+// CHECK-CC37-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:79:13 %s | FileCheck -check-prefix=CHECK-CC38 %s
+// CHECK-CC38: OverloadCandidate:{ResultType void}{Text foo_9}{LeftParen (}{Text void *}{Comma , }{CurrentParameter T}{RightParen )} (1)
+// CHECK-CC38: Completion contexts:
+// CHECK-CC38-NEXT: Any type
+// CHECK-CC38-NEXT: Any value
+// CHECK-CC38-NEXT: Enum tag
+// CHECK-CC38-NEXT: Union tag
+// CHECK-CC38-NEXT: Struct tag
+// CHECK-CC38-NEXT: Class name
+// CHECK-CC38-NEXT: Nested name specifier
+// CHECK-CC38-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:80:12 %s | FileCheck -check-prefix=CHECK-CC39 %s
+// CHECK-CC39: OverloadCandidate:{ResultType void}{Text foo_10}{LeftParen (}{CurrentParameter T}{Comma , }{Text int}{Comma , }{Text int}{RightParen )} (1)
+// CHECK-CC39: OverloadCandidate:{ResultType void}{Text foo_10}{LeftParen (}{CurrentParameter U}{Comma , }{Text void *}{Comma , }{Text void *}{RightParen )} (1)
+// CHECK-CC39: Completion contexts:
+// CHECK-CC39-NEXT: Any type
+// CHECK-CC39-NEXT: Any value
+// CHECK-CC39-NEXT: Enum tag
+// CHECK-CC39-NEXT: Union tag
+// CHECK-CC39-NEXT: Struct tag
+// CHECK-CC39-NEXT: Class name
+// CHECK-CC39-NEXT: Nested name specifier
+// CHECK-CC39-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:80:15 %s | FileCheck -check-prefix=CHECK-CC40 %s
+// CHECK-CC40: OverloadCandidate:{ResultType void}{Text foo_10}{LeftParen (}{Text int}{Comma , }{CurrentParameter int}{Comma , }{Text int}{RightParen )} (1)
+// CHECK-CC40: OverloadCandidate:{ResultType void}{Text foo_10}{LeftParen (}{Text int}{Comma , }{CurrentParameter void *}{Comma , }{Text void *}{RightParen )} (1)
+// CHECK-CC40: Completion contexts:
+// CHECK-CC40-NEXT: Any type
+// CHECK-CC40-NEXT: Any value
+// CHECK-CC40-NEXT: Enum tag
+// CHECK-CC40-NEXT: Union tag
+// CHECK-CC40-NEXT: Struct tag
+// CHECK-CC40-NEXT: Class name
+// CHECK-CC40-NEXT: Nested name specifier
+// CHECK-CC40-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:80:19 %s | FileCheck -check-prefix=CHECK-CC41 %s
+// CHECK-CC41: OverloadCandidate:{ResultType void}{Text foo_10}{LeftParen (}{Text int}{Comma , }{Text int}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC41: Completion contexts:
+// CHECK-CC41-NEXT: Any type
+// CHECK-CC41-NEXT: Any value
+// CHECK-CC41-NEXT: Enum tag
+// CHECK-CC41-NEXT: Union tag
+// CHECK-CC41-NEXT: Struct tag
+// CHECK-CC41-NEXT: Class name
+// CHECK-CC41-NEXT: Nested name specifier
+// CHECK-CC41-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:81:12 %s | FileCheck -check-prefix=CHECK-CC42 %s
+// CHECK-CC42: OverloadCandidate:{ResultType void}{Text foo_11}{LeftParen (}{CurrentParameter T}{Comma , }{Text U}{RightParen )} (1)
+// CHECK-CC42: Completion contexts:
+// CHECK-CC42-NEXT: Any type
+// CHECK-CC42-NEXT: Any value
+// CHECK-CC42-NEXT: Enum tag
+// CHECK-CC42-NEXT: Union tag
+// CHECK-CC42-NEXT: Struct tag
+// CHECK-CC42-NEXT: Class name
+// CHECK-CC42-NEXT: Nested name specifier
+// CHECK-CC42-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:81:15 %s | FileCheck -check-prefix=CHECK-CC43 %s
+// CHECK-CC43: OverloadCandidate:{ResultType void}{Text foo_11}{LeftParen (}{Text int}{Comma , }{CurrentParameter U}{RightParen )} (1)
+// CHECK-CC43: Completion contexts:
+// CHECK-CC43-NEXT: Any type
+// CHECK-CC43-NEXT: Any value
+// CHECK-CC43-NEXT: Enum tag
+// CHECK-CC43-NEXT: Union tag
+// CHECK-CC43-NEXT: Struct tag
+// CHECK-CC43-NEXT: Class name
+// CHECK-CC43-NEXT: Nested name specifier
+// CHECK-CC43-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:82:17 %s | FileCheck -check-prefix=CHECK-CC44 %s
+// CHECK-CC44: OverloadCandidate:{ResultType void}{Text foo_11}{LeftParen (}{CurrentParameter int}{Comma , }{Text U}{RightParen )} (1)
+// CHECK-CC44: Completion contexts:
+// CHECK-CC44-NEXT: Any type
+// CHECK-CC44-NEXT: Any value
+// CHECK-CC44-NEXT: Enum tag
+// CHECK-CC44-NEXT: Union tag
+// CHECK-CC44-NEXT: Struct tag
+// CHECK-CC44-NEXT: Class name
+// CHECK-CC44-NEXT: Nested name specifier
+// CHECK-CC44-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:82:20 %s | FileCheck -check-prefix=CHECK-CC45 %s
+// CHECK-CC45: OverloadCandidate:{ResultType void}{Text foo_11}{LeftParen (}{Text int}{Comma , }{CurrentParameter U}{RightParen )} (1)
+// CHECK-CC45: Completion contexts:
+// CHECK-CC45-NEXT: Any type
+// CHECK-CC45-NEXT: Any value
+// CHECK-CC45-NEXT: Enum tag
+// CHECK-CC45-NEXT: Union tag
+// CHECK-CC45-NEXT: Struct tag
+// CHECK-CC45-NEXT: Class name
+// CHECK-CC45-NEXT: Nested name specifier
+// CHECK-CC45-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:83:28 %s | FileCheck -check-prefix=CHECK-CC46 %s
+// CHECK-CC46: OverloadCandidate:{ResultType void}{Text foo_11}{LeftParen (}{Text int}{Comma , }{CurrentParameter void *}{RightParen )} (1)
+// CHECK-CC46: Completion contexts:
+// CHECK-CC46-NEXT: Any type
+// CHECK-CC46-NEXT: Any value
+// CHECK-CC46-NEXT: Enum tag
+// CHECK-CC46-NEXT: Union tag
+// CHECK-CC46-NEXT: Struct tag
+// CHECK-CC46-NEXT: Class name
+// CHECK-CC46-NEXT: Nested name specifier
+// CHECK-CC46-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:84:12 %s | FileCheck -check-prefix=CHECK-CC47 %s
+// CHECK-CC47: OverloadCandidate:{ResultType void}{Text foo_12}{LeftParen (}{CurrentParameter int}{Comma , }{Text int}{RightParen )} (1)
+// CHECK-CC47: Completion contexts:
+// CHECK-CC47-NEXT: Any type
+// CHECK-CC47-NEXT: Any value
+// CHECK-CC47-NEXT: Enum tag
+// CHECK-CC47-NEXT: Union tag
+// CHECK-CC47-NEXT: Struct tag
+// CHECK-CC47-NEXT: Class name
+// CHECK-CC47-NEXT: Nested name specifier
+// CHECK-CC47-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:84:14 %s | FileCheck -check-prefix=CHECK-CC48 %s
+// CHECK-CC48: OverloadCandidate:{ResultType void}{Text foo_12}{LeftParen (}{Text void *}{Comma , }{CurrentParameter void *}{RightParen )} (1)
+// CHECK-CC48: Completion contexts:
+// CHECK-CC48-NEXT: Any type
+// CHECK-CC48-NEXT: Any value
+// CHECK-CC48-NEXT: Enum tag
+// CHECK-CC48-NEXT: Union tag
+// CHECK-CC48-NEXT: Struct tag
+// CHECK-CC48-NEXT: Class name
+// CHECK-CC48-NEXT: Nested name specifier
+// CHECK-CC48-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:85:12 %s | FileCheck -check-prefix=CHECK-CC49 %s
+// CHECK-CC49: OverloadCandidate:{ResultType void}{Text foo_13}{LeftParen (}{CurrentParameter int}{Comma , }{Text T}{Comma , }{Text T}{RightParen )} (1)
+// CHECK-CC49: Completion contexts:
+// CHECK-CC49-NEXT: Any type
+// CHECK-CC49-NEXT: Any value
+// CHECK-CC49-NEXT: Enum tag
+// CHECK-CC49-NEXT: Union tag
+// CHECK-CC49-NEXT: Struct tag
+// CHECK-CC49-NEXT: Class name
+// CHECK-CC49-NEXT: Nested name specifier
+// CHECK-CC49-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:85:15 %s | FileCheck -check-prefix=CHECK-CC50 %s
+// CHECK-CC50: OverloadCandidate:{ResultType void}{Text foo_13}{LeftParen (}{Text int}{Comma , }{CurrentParameter T}{Comma , }{Text T}{RightParen )} (1)
+// CHECK-CC50: Completion contexts:
+// CHECK-CC50-NEXT: Any type
+// CHECK-CC50-NEXT: Any value
+// CHECK-CC50-NEXT: Enum tag
+// CHECK-CC50-NEXT: Union tag
+// CHECK-CC50-NEXT: Struct tag
+// CHECK-CC50-NEXT: Class name
+// CHECK-CC50-NEXT: Nested name specifier
+// CHECK-CC50-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:85:19 %s | FileCheck -check-prefix=CHECK-CC51 %s
+// CHECK-CC51: OverloadCandidate:{ResultType void}{Text foo_13}{LeftParen (}{Text int}{Comma , }{Text int}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC51: Completion contexts:
+// CHECK-CC51-NEXT: Any type
+// CHECK-CC51-NEXT: Any value
+// CHECK-CC51-NEXT: Enum tag
+// CHECK-CC51-NEXT: Union tag
+// CHECK-CC51-NEXT: Struct tag
+// CHECK-CC51-NEXT: Class name
+// CHECK-CC51-NEXT: Nested name specifier
+// CHECK-CC51-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:87:12 %s | FileCheck -check-prefix=CHECK-CC52 %s
+// CHECK-CC52: Completion contexts:
+// CHECK-CC52-NEXT: Any type
+// CHECK-CC52-NEXT: Any value
+// CHECK-CC52-NEXT: Enum tag
+// CHECK-CC52-NEXT: Union tag
+// CHECK-CC52-NEXT: Struct tag
+// CHECK-CC52-NEXT: Class name
+// CHECK-CC52-NEXT: Nested name specifier
+// CHECK-CC52-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:88:12 %s | FileCheck -check-prefix=CHECK-CC53 %s
+// CHECK-CC53: Completion contexts:
+// CHECK-CC53-NEXT: Any type
+// CHECK-CC53-NEXT: Any value
+// CHECK-CC53-NEXT: Enum tag
+// CHECK-CC53-NEXT: Union tag
+// CHECK-CC53-NEXT: Struct tag
+// CHECK-CC53-NEXT: Class name
+// CHECK-CC53-NEXT: Nested name specifier
+// CHECK-CC53-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:89:17 %s | FileCheck -check-prefix=CHECK-CC54 %s
+// CHECK-CC54: Completion contexts:
+// CHECK-CC54-NEXT: Any type
+// CHECK-CC54-NEXT: Any value
+// CHECK-CC54-NEXT: Enum tag
+// CHECK-CC54-NEXT: Union tag
+// CHECK-CC54-NEXT: Struct tag
+// CHECK-CC54-NEXT: Class name
+// CHECK-CC54-NEXT: Nested name specifier
+// CHECK-CC54-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:90:12 %s | FileCheck -check-prefix=CHECK-CC55 %s
+// CHECK-CC55: Completion contexts:
+// CHECK-CC55-NEXT: Any type
+// CHECK-CC55-NEXT: Any value
+// CHECK-CC55-NEXT: Enum tag
+// CHECK-CC55-NEXT: Union tag
+// CHECK-CC55-NEXT: Struct tag
+// CHECK-CC55-NEXT: Class name
+// CHECK-CC55-NEXT: Nested name specifier
+// CHECK-CC55-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:91:14 %s | FileCheck -check-prefix=CHECK-CC56 %s
+// CHECK-CC56: Completion contexts:
+// CHECK-CC56-NEXT: Any type
+// CHECK-CC56-NEXT: Any value
+// CHECK-CC56-NEXT: Enum tag
+// CHECK-CC56-NEXT: Union tag
+// CHECK-CC56-NEXT: Struct tag
+// CHECK-CC56-NEXT: Class name
+// CHECK-CC56-NEXT: Nested name specifier
+// CHECK-CC56-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:92:14 %s | FileCheck -check-prefix=CHECK-CC57 %s
+// CHECK-CC57: Completion contexts:
+// CHECK-CC57-NEXT: Any type
+// CHECK-CC57-NEXT: Any value
+// CHECK-CC57-NEXT: Enum tag
+// CHECK-CC57-NEXT: Union tag
+// CHECK-CC57-NEXT: Struct tag
+// CHECK-CC57-NEXT: Class name
+// CHECK-CC57-NEXT: Nested name specifier
+// CHECK-CC57-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:93:19 %s | FileCheck -check-prefix=CHECK-CC58 %s
+// CHECK-CC58: Completion contexts:
+// CHECK-CC58-NEXT: Any type
+// CHECK-CC58-NEXT: Any value
+// CHECK-CC58-NEXT: Enum tag
+// CHECK-CC58-NEXT: Union tag
+// CHECK-CC58-NEXT: Struct tag
+// CHECK-CC58-NEXT: Class name
+// CHECK-CC58-NEXT: Nested name specifier
+// CHECK-CC58-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:94:14 %s | FileCheck -check-prefix=CHECK-CC59 %s
+// CHECK-CC59: Completion contexts:
+// CHECK-CC59-NEXT: Any type
+// CHECK-CC59-NEXT: Any value
+// CHECK-CC59-NEXT: Enum tag
+// CHECK-CC59-NEXT: Union tag
+// CHECK-CC59-NEXT: Struct tag
+// CHECK-CC59-NEXT: Class name
+// CHECK-CC59-NEXT: Nested name specifier
+// CHECK-CC59-NEXT: Objective-C interface

Added: cfe/trunk/test/Index/complete-constructor-params.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-constructor-params.cpp?rev=226670&view=auto
==============================================================================
--- cfe/trunk/test/Index/complete-constructor-params.cpp (added)
+++ cfe/trunk/test/Index/complete-constructor-params.cpp Wed Jan 21 10:24:11 2015
@@ -0,0 +1,126 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+template<class T>
+struct S {
+  template<class U>
+  S(T, U, U) {}
+};
+
+int main() {
+  S<int>(42, 42, 42);
+  S<int>(42, 42, 42);
+  S<int> s(42, 42, 42);
+
+  S<int>(42, 42, 42,);
+  S<int> z(42, 42, 42,);
+}
+
+// RUN: c-index-test -code-completion-at=%s:11:10 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: OverloadCandidate:{Text S}{LeftParen (}{CurrentParameter const S<int> &}{RightParen )} (1)
+// CHECK-CC1: OverloadCandidate:{Text S}{LeftParen (}{CurrentParameter int}{Comma , }{Text U}{Comma , }{Text U}{RightParen )} (1)
+// CHECK-CC1: Completion contexts:
+// CHECK-CC1-NEXT: Any type
+// CHECK-CC1-NEXT: Any value
+// CHECK-CC1-NEXT: Enum tag
+// CHECK-CC1-NEXT: Union tag
+// CHECK-CC1-NEXT: Struct tag
+// CHECK-CC1-NEXT: Class name
+// CHECK-CC1-NEXT: Nested name specifier
+// CHECK-CC1-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:12:10 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: OverloadCandidate:{Text S}{LeftParen (}{CurrentParameter const S<int> &}{RightParen )} (1)
+// CHECK-CC2: OverloadCandidate:{Text S}{LeftParen (}{CurrentParameter int}{Comma , }{Text U}{Comma , }{Text U}{RightParen )} (1)
+// CHECK-CC2: Completion contexts:
+// CHECK-CC2-NEXT: Any type
+// CHECK-CC2-NEXT: Any value
+// CHECK-CC2-NEXT: Enum tag
+// CHECK-CC2-NEXT: Union tag
+// CHECK-CC2-NEXT: Struct tag
+// CHECK-CC2-NEXT: Class name
+// CHECK-CC2-NEXT: Nested name specifier
+// CHECK-CC2-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:12:13 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: OverloadCandidate:{Text S}{LeftParen (}{Text int}{Comma , }{CurrentParameter U}{Comma , }{Text U}{RightParen )} (1)
+// CHECK-CC3: Completion contexts:
+// CHECK-CC3-NEXT: Any type
+// CHECK-CC3-NEXT: Any value
+// CHECK-CC3-NEXT: Enum tag
+// CHECK-CC3-NEXT: Union tag
+// CHECK-CC3-NEXT: Struct tag
+// CHECK-CC3-NEXT: Class name
+// CHECK-CC3-NEXT: Nested name specifier
+// CHECK-CC3-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:12:17 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: OverloadCandidate:{Text S}{LeftParen (}{Text int}{Comma , }{Text int}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC4: Completion contexts:
+// CHECK-CC4-NEXT: Any type
+// CHECK-CC4-NEXT: Any value
+// CHECK-CC4-NEXT: Enum tag
+// CHECK-CC4-NEXT: Union tag
+// CHECK-CC4-NEXT: Struct tag
+// CHECK-CC4-NEXT: Class name
+// CHECK-CC4-NEXT: Nested name specifier
+// CHECK-CC4-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:13:12 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: OverloadCandidate:{Text S}{LeftParen (}{CurrentParameter const S<int> &}{RightParen )} (1)
+// CHECK-CC5: OverloadCandidate:{Text S}{LeftParen (}{CurrentParameter int}{Comma , }{Text U}{Comma , }{Text U}{RightParen )} (1)
+// CHECK-CC5: Completion contexts:
+// CHECK-CC5-NEXT: Any type
+// CHECK-CC5-NEXT: Any value
+// CHECK-CC5-NEXT: Enum tag
+// CHECK-CC5-NEXT: Union tag
+// CHECK-CC5-NEXT: Struct tag
+// CHECK-CC5-NEXT: Class name
+// CHECK-CC5-NEXT: Nested name specifier
+// CHECK-CC5-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:13:15 %s | FileCheck -check-prefix=CHECK-CC6 %s
+// CHECK-CC6: OverloadCandidate:{Text S}{LeftParen (}{Text int}{Comma , }{CurrentParameter U}{Comma , }{Text U}{RightParen )} (1)
+// CHECK-CC6: Completion contexts:
+// CHECK-CC6-NEXT: Any type
+// CHECK-CC6-NEXT: Any value
+// CHECK-CC6-NEXT: Enum tag
+// CHECK-CC6-NEXT: Union tag
+// CHECK-CC6-NEXT: Struct tag
+// CHECK-CC6-NEXT: Class name
+// CHECK-CC6-NEXT: Nested name specifier
+// CHECK-CC6-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:13:19 %s | FileCheck -check-prefix=CHECK-CC7 %s
+// CHECK-CC7: OverloadCandidate:{Text S}{LeftParen (}{Text int}{Comma , }{Text int}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC7: Completion contexts:
+// CHECK-CC7-NEXT: Any type
+// CHECK-CC7-NEXT: Any value
+// CHECK-CC7-NEXT: Enum tag
+// CHECK-CC7-NEXT: Union tag
+// CHECK-CC7-NEXT: Struct tag
+// CHECK-CC7-NEXT: Class name
+// CHECK-CC7-NEXT: Nested name specifier
+// CHECK-CC7-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:15:21 %s | FileCheck -check-prefix=CHECK-CC8 %s
+// CHECK-CC8: Completion contexts:
+// CHECK-CC8-NEXT: Any type
+// CHECK-CC8-NEXT: Any value
+// CHECK-CC8-NEXT: Enum tag
+// CHECK-CC8-NEXT: Union tag
+// CHECK-CC8-NEXT: Struct tag
+// CHECK-CC8-NEXT: Class name
+// CHECK-CC8-NEXT: Nested name specifier
+// CHECK-CC8-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:16:23 %s | FileCheck -check-prefix=CHECK-CC9 %s
+// CHECK-CC9: Completion contexts:
+// CHECK-CC9-NEXT: Any type
+// CHECK-CC9-NEXT: Any value
+// CHECK-CC9-NEXT: Enum tag
+// CHECK-CC9-NEXT: Union tag
+// CHECK-CC9-NEXT: Struct tag
+// CHECK-CC9-NEXT: Class name
+// CHECK-CC9-NEXT: Nested name specifier
+// CHECK-CC9-NEXT: Objective-C interface

Added: cfe/trunk/test/Index/complete-functor-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-functor-call.cpp?rev=226670&view=auto
==============================================================================
--- cfe/trunk/test/Index/complete-functor-call.cpp (added)
+++ cfe/trunk/test/Index/complete-functor-call.cpp Wed Jan 21 10:24:11 2015
@@ -0,0 +1,175 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+template<class V>
+struct S {
+  void operator()(int) const {}
+  template<class T> void operator()(T) const {}
+  template<class T> void operator()(V, T, T) const {}
+  template<class T> const S<T> *operator()(const S<T> &s) const { return &s; }
+};
+
+int main() {
+  S<void *> s;
+  s(42);
+  s(s);
+  s(0, s, s);
+  (*S<void *>()(S<int>()))(42, 42, 42);
+
+  s(42,);
+  s(s,);
+  s(0, 42, 42,);
+}
+
+// RUN: c-index-test -code-completion-at=%s:14:5 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC1: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{CurrentParameter T}{RightParen )} (1)
+// CHECK-CC1: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{CurrentParameter void *}{Comma , }{Text T}{Comma , }{Text T}{RightParen )} (1)
+// CHECK-CC1: Completion contexts:
+// CHECK-CC1-NEXT: Any type
+// CHECK-CC1-NEXT: Any value
+// CHECK-CC1-NEXT: Enum tag
+// CHECK-CC1-NEXT: Union tag
+// CHECK-CC1-NEXT: Struct tag
+// CHECK-CC1-NEXT: Class name
+// CHECK-CC1-NEXT: Nested name specifier
+// CHECK-CC1-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:15:5 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC2: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{CurrentParameter T}{RightParen )} (1)
+// CHECK-CC2: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{CurrentParameter void *}{Comma , }{Text T}{Comma , }{Text T}{RightParen )} (1)
+// CHECK-CC2: Completion contexts:
+// CHECK-CC2-NEXT: Any type
+// CHECK-CC2-NEXT: Any value
+// CHECK-CC2-NEXT: Enum tag
+// CHECK-CC2-NEXT: Union tag
+// CHECK-CC2-NEXT: Struct tag
+// CHECK-CC2-NEXT: Class name
+// CHECK-CC2-NEXT: Nested name specifier
+// CHECK-CC2-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:16:5 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC3: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{CurrentParameter T}{RightParen )} (1)
+// CHECK-CC3: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{CurrentParameter void *}{Comma , }{Text T}{Comma , }{Text T}{RightParen )} (1)
+// CHECK-CC3: Completion contexts:
+// CHECK-CC3-NEXT: Any type
+// CHECK-CC3-NEXT: Any value
+// CHECK-CC3-NEXT: Enum tag
+// CHECK-CC3-NEXT: Union tag
+// CHECK-CC3-NEXT: Struct tag
+// CHECK-CC3-NEXT: Class name
+// CHECK-CC3-NEXT: Nested name specifier
+// CHECK-CC3-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:16:7 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{Text void *}{Comma , }{CurrentParameter T}{Comma , }{Text T}{RightParen )} (1)
+// CHECK-CC4: Completion contexts:
+// CHECK-CC4-NEXT: Any type
+// CHECK-CC4-NEXT: Any value
+// CHECK-CC4-NEXT: Enum tag
+// CHECK-CC4-NEXT: Union tag
+// CHECK-CC4-NEXT: Struct tag
+// CHECK-CC4-NEXT: Class name
+// CHECK-CC4-NEXT: Nested name specifier
+// CHECK-CC4-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:16:10 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{Text void *}{Comma , }{Text S<void *>}{Comma , }{CurrentParameter S<void *>}{RightParen )} (1)
+// CHECK-CC5: Completion contexts:
+// CHECK-CC5-NEXT: Any type
+// CHECK-CC5-NEXT: Any value
+// CHECK-CC5-NEXT: Enum tag
+// CHECK-CC5-NEXT: Union tag
+// CHECK-CC5-NEXT: Struct tag
+// CHECK-CC5-NEXT: Class name
+// CHECK-CC5-NEXT: Nested name specifier
+// CHECK-CC5-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:17:17 %s | FileCheck -check-prefix=CHECK-CC6 %s
+// CHECK-CC6: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC6: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{CurrentParameter T}{RightParen )} (1)
+// CHECK-CC6: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{CurrentParameter void *}{Comma , }{Text T}{Comma , }{Text T}{RightParen )} (1)
+// CHECK-CC6: OverloadCandidate:{ResultType const S<T> *}{Text operator()}{LeftParen (}{CurrentParameter const S<T> &s}{RightParen )} (1)
+// CHECK-CC6: Completion contexts:
+// CHECK-CC6-NEXT: Any type
+// CHECK-CC6-NEXT: Any value
+// CHECK-CC6-NEXT: Enum tag
+// CHECK-CC6-NEXT: Union tag
+// CHECK-CC6-NEXT: Struct tag
+// CHECK-CC6-NEXT: Class name
+// CHECK-CC6-NEXT: Nested name specifier
+// CHECK-CC6-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:17:28 %s | FileCheck -check-prefix=CHECK-CC7 %s
+// CHECK-CC7: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC7: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{CurrentParameter T}{RightParen )} (1)
+// CHECK-CC7: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{CurrentParameter int}{Comma , }{Text T}{Comma , }{Text T}{RightParen )} (1)
+// CHECK-CC7: OverloadCandidate:{ResultType const S<T> *}{Text operator()}{LeftParen (}{CurrentParameter const S<T> &s}{RightParen )} (1)
+// CHECK-CC7: Completion contexts:
+// CHECK-CC7-NEXT: Any type
+// CHECK-CC7-NEXT: Any value
+// CHECK-CC7-NEXT: Enum tag
+// CHECK-CC7-NEXT: Union tag
+// CHECK-CC7-NEXT: Struct tag
+// CHECK-CC7-NEXT: Class name
+// CHECK-CC7-NEXT: Nested name specifier
+// CHECK-CC7-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:17:31 %s | FileCheck -check-prefix=CHECK-CC8 %s
+// CHECK-CC8: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{Text int}{Comma , }{CurrentParameter T}{Comma , }{Text T}{RightParen )} (1)
+// CHECK-CC8: Completion contexts:
+// CHECK-CC8-NEXT: Any type
+// CHECK-CC8-NEXT: Any value
+// CHECK-CC8-NEXT: Enum tag
+// CHECK-CC8-NEXT: Union tag
+// CHECK-CC8-NEXT: Struct tag
+// CHECK-CC8-NEXT: Class name
+// CHECK-CC8-NEXT: Nested name specifier
+// CHECK-CC8-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:17:35 %s | FileCheck -check-prefix=CHECK-CC9 %s
+// CHECK-CC9: OverloadCandidate:{ResultType void}{Text operator()}{LeftParen (}{Text int}{Comma , }{Text int}{Comma , }{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC9: Completion contexts:
+// CHECK-CC9-NEXT: Any type
+// CHECK-CC9-NEXT: Any value
+// CHECK-CC9-NEXT: Enum tag
+// CHECK-CC9-NEXT: Union tag
+// CHECK-CC9-NEXT: Struct tag
+// CHECK-CC9-NEXT: Class name
+// CHECK-CC9-NEXT: Nested name specifier
+// CHECK-CC9-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:19:8 %s | FileCheck -check-prefix=CHECK-CC10 %s
+// CHECK-CC10: Completion contexts:
+// CHECK-CC10-NEXT: Any type
+// CHECK-CC10-NEXT: Any value
+// CHECK-CC10-NEXT: Enum tag
+// CHECK-CC10-NEXT: Union tag
+// CHECK-CC10-NEXT: Struct tag
+// CHECK-CC10-NEXT: Class name
+// CHECK-CC10-NEXT: Nested name specifier
+// CHECK-CC10-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:20:7 %s | FileCheck -check-prefix=CHECK-CC11 %s
+// CHECK-CC11: Completion contexts:
+// CHECK-CC11-NEXT: Any type
+// CHECK-CC11-NEXT: Any value
+// CHECK-CC11-NEXT: Enum tag
+// CHECK-CC11-NEXT: Union tag
+// CHECK-CC11-NEXT: Struct tag
+// CHECK-CC11-NEXT: Class name
+// CHECK-CC11-NEXT: Nested name specifier
+// CHECK-CC11-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:21:15 %s | FileCheck -check-prefix=CHECK-CC12 %s
+// CHECK-CC12: Completion contexts:
+// CHECK-CC12-NEXT: Any type
+// CHECK-CC12-NEXT: Any value
+// CHECK-CC12-NEXT: Enum tag
+// CHECK-CC12-NEXT: Union tag
+// CHECK-CC12-NEXT: Struct tag
+// CHECK-CC12-NEXT: Class name
+// CHECK-CC12-NEXT: Nested name specifier
+// CHECK-CC12-NEXT: Objective-C interface

Modified: cfe/trunk/test/Index/complete-type-factors.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-type-factors.m?rev=226670&r1=226669&r2=226670&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-type-factors.m (original)
+++ cfe/trunk/test/Index/complete-type-factors.m Wed Jan 21 10:24:11 2015
@@ -78,19 +78,19 @@ void test2(A *a) {
 // CHECK-CC3: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
 // CHECK-CC3: FunctionDecl:{ResultType enum Priority}{TypedText test1}{LeftParen (}{Placeholder enum Priority priority}{Comma , }{Placeholder enum Color color}{Comma , }{Placeholder int integer}{RightParen )} (12)
 // RUN: c-index-test -code-completion-at=%s:19:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC4 %s
-// CHECK-CC4: EnumConstantDecl:{ResultType enum Color}{TypedText Blue} (16)
-// CHECK-CC4: VarDecl:{ResultType enum Color}{TypedText c} (8)
-// CHECK-CC4: ParmDecl:{ResultType enum Color}{TypedText color} (8)
-// CHECK-CC4: FunctionDecl:{ResultType int}{TypedText func1}{LeftParen (}{Placeholder enum Color}{RightParen )} (25)
+// CHECK-CC4: EnumConstantDecl:{ResultType enum Color}{TypedText Blue} (65)
+// CHECK-CC4: VarDecl:{ResultType enum Color}{TypedText c} (34)
+// CHECK-CC4: ParmDecl:{ResultType enum Color}{TypedText color} (34)
+// CHECK-CC4: FunctionDecl:{ResultType int}{TypedText func1}{LeftParen (}{Placeholder enum Color}{RightParen )} (50)
 // CHECK-CC4: FunctionDecl:{ResultType enum Priority}{TypedText func2}{LeftParen (}{Placeholder int}{RightParen )} (50)
 // CHECK-CC4: FunctionDecl:{ResultType void}{TypedText func3}{LeftParen (}{Placeholder float}{RightParen )} (50)
-// CHECK-CC4: EnumConstantDecl:{ResultType enum Color}{TypedText Green} (16)
+// CHECK-CC4: EnumConstantDecl:{ResultType enum Color}{TypedText Green} (65)
 // CHECK-CC4: EnumConstantDecl:{ResultType enum Priority}{TypedText High} (65)
-// CHECK-CC4: VarDecl:{ResultType int}{TypedText i} (17)
-// CHECK-CC4: ParmDecl:{ResultType int}{TypedText integer} (17)
+// CHECK-CC4: VarDecl:{ResultType int}{TypedText i} (34)
+// CHECK-CC4: ParmDecl:{ResultType int}{TypedText integer} (34)
 // CHECK-CC4: EnumConstantDecl:{ResultType enum Priority}{TypedText Low} (65)
 // CHECK-CC4: ParmDecl:{ResultType enum Priority}{TypedText priority} (34)
-// CHECK-CC4: EnumConstantDecl:{ResultType enum Color}{TypedText Red} (16)
+// CHECK-CC4: EnumConstantDecl:{ResultType enum Color}{TypedText Red} (65)
 // CHECK-CC4: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
 // CHECK-CC4: FunctionDecl:{ResultType enum Priority}{TypedText test1}{LeftParen (}{Placeholder enum Priority priority}{Comma , }{Placeholder enum Color color}{Comma , }{Placeholder int integer}{RightParen )} (50)
 // RUN: c-index-test -code-completion-at=%s:21:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC4 %s

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=226670&r1=226669&r2=226670&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Jan 21 10:24:11 2015
@@ -4208,6 +4208,8 @@ CXString clang_getCursorKindSpelling(enu
     return cxstring::createRef("OMPTargetDirective");
   case CXCursor_OMPTeamsDirective:
     return cxstring::createRef("OMPTeamsDirective");
+  case CXCursor_OverloadCandidate:
+      return cxstring::createRef("OverloadCandidate");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");

Modified: cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp?rev=226670&r1=226669&r2=226670&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp Wed Jan 21 10:24:11 2015
@@ -622,7 +622,7 @@ namespace {
                                                 getCodeCompletionTUInfo());
         
         CXCompletionResult R;
-        R.CursorKind = CXCursor_NotImplemented;
+        R.CursorKind = CXCursor_OverloadCandidate;
         R.CompletionString = StoredCompletion;
         StoredResults.push_back(R);
       }





More information about the cfe-commits mailing list