summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorMatt Beaumont-Gay <matthewbg@google.com>2012-11-08 20:50:02 +0000
committerMatt Beaumont-Gay <matthewbg@google.com>2012-11-08 20:50:02 +0000
commit641bd89d6b5e7378fdcc989e09ee1fcf6edf9f70 (patch)
treec2bfa34ec8a9e88b152bad60924a9f57304b1bde /clang/lib/Sema/SemaOverload.cpp
parent43ab4ef9bae9a99a1e64c20eabcae7e850c2e6b3 (diff)
downloadbcm5719-llvm-641bd89d6b5e7378fdcc989e09ee1fcf6edf9f70.tar.gz
bcm5719-llvm-641bd89d6b5e7378fdcc989e09ee1fcf6edf9f70.zip
Fix a bug I found while preparing my devmtg talk: When passing NULL to a
function that takes a const Foo&, where Foo is convertible from a large number of pointer types, we print ALL the overloads, no matter the setting of -fshow-overloads. There is potential follow-on work in unifying the "print candidates, but not too many" logic between OverloadCandidateSet::NoteCandidates and ImplicitConversionSequence::DiagnoseAmbiguousConversion. llvm-svn: 167596
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 8e8580d7019..bf2b89741ab 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -7992,10 +7992,20 @@ void ImplicitConversionSequence::DiagnoseAmbiguousConversion(
const PartialDiagnostic &PDiag) const {
S.Diag(CaretLoc, PDiag)
<< Ambiguous.getFromType() << Ambiguous.getToType();
- for (AmbiguousConversionSequence::const_iterator
- I = Ambiguous.begin(), E = Ambiguous.end(); I != E; ++I) {
+ // FIXME: The note limiting machinery is borrowed from
+ // OverloadCandidateSet::NoteCandidates; there's an opportunity for
+ // refactoring here.
+ const OverloadsShown ShowOverloads = S.Diags.getShowOverloads();
+ unsigned CandsShown = 0;
+ AmbiguousConversionSequence::const_iterator I, E;
+ for (I = Ambiguous.begin(), E = Ambiguous.end(); I != E; ++I) {
+ if (CandsShown >= 4 && ShowOverloads == Ovl_Best)
+ break;
+ ++CandsShown;
S.NoteOverloadCandidate(*I);
}
+ if (I != E)
+ S.Diag(SourceLocation(), diag::note_ovl_too_many_candidates) << int(E - I);
}
namespace {
OpenPOWER on IntegriCloud