diff options
| author | Jeffrey Yasskin <jyasskin@google.com> | 2010-06-11 05:57:47 +0000 | 
|---|---|---|
| committer | Jeffrey Yasskin <jyasskin@google.com> | 2010-06-11 05:57:47 +0000 | 
| commit | 2b99c6fc4f3e0c6d5a1b4216dd86a6cfe067bffb (patch) | |
| tree | dfc3701e358e9532d6e44d2312e2dc2f69099bd6 /clang/lib/Sema/SemaOverload.cpp | |
| parent | a82475ab749eb9eefcd39df73d168c72c4dee8c1 (diff) | |
| download | bcm5719-llvm-2b99c6fc4f3e0c6d5a1b4216dd86a6cfe067bffb.tar.gz bcm5719-llvm-2b99c6fc4f3e0c6d5a1b4216dd86a6cfe067bffb.zip | |
Add an option -fshow-overloads=best|all to limit the number of overload
candidates printed.  We default to 'all'.  At the moment, 'best' prints only
the first 4 overloads, but we'll improve that over time.
llvm-svn: 105815
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 25 | 
1 files changed, 20 insertions, 5 deletions
| diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 721c68f6c1d..eda7e7ad885 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -5689,7 +5689,10 @@ Sema::PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,        Cands.push_back(Cand);      else if (OCD == OCD_AllCandidates) {        CompleteNonViableCandidate(*this, Cand, Args, NumArgs); -      Cands.push_back(Cand); +      if (Cand->Function || Cand->IsSurrogate) +        Cands.push_back(Cand); +      // Otherwise, this a non-viable builtin candidate.  We do not, in general, +      // want to list every possible builtin candidate.      }    } @@ -5699,17 +5702,26 @@ Sema::PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,    bool ReportedAmbiguousConversions = false;    llvm::SmallVectorImpl<OverloadCandidate*>::iterator I, E; +  const Diagnostic::OverloadsShown ShowOverloads = Diags.getShowOverloads(); +  unsigned CandsShown = 0;    for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {      OverloadCandidate *Cand = *I; +    // Set an arbitrary limit on the number of candidate functions we'll spam +    // the user with.  FIXME: This limit should depend on details of the +    // candidate list. +    if (CandsShown >= 4 && ShowOverloads == Diagnostic::Ovl_Best) { +      break; +    } +    ++CandsShown; +      if (Cand->Function)        NoteFunctionCandidate(*this, Cand, Args, NumArgs);      else if (Cand->IsSurrogate)        NoteSurrogateCandidate(*this, Cand); - -    // This a builtin candidate.  We do not, in general, want to list -    // every possible builtin candidate. -    else if (Cand->Viable) { +    else { +      assert(Cand->Viable && +             "Non-viable built-in candidates are not added to Cands.");        // Generally we only see ambiguities including viable builtin        // operators if overload resolution got screwed up by an        // ambiguous user-defined conversion. @@ -5725,6 +5737,9 @@ Sema::PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,        NoteBuiltinOperatorCandidate(*this, Opc, OpLoc, Cand);      }    } + +  if (I != E) +    Diag(OpLoc, diag::note_ovl_too_many_candidates) << E - I;  }  static bool CheckUnresolvedAccess(Sema &S, OverloadExpr *E, DeclAccessPair D) { | 

