[cfe-commits] [PATCH] Limit the number of overload candidates printed (issue1591041)

Jeffrey Yasskin jyasskin at google.com
Tue Jun 8 13:06:27 PDT 2010


On Tue, Jun 8, 2010 at 7:49 AM, Douglas Gregor <dgregor at apple.com> wrote:
>
> On Jun 7, 2010, at 6:03 PM, jyasskin at gmail.com wrote:
>
>> Reviewers: cfe-commits_cs.uiuc.edu,
>>
>> Message:
>> Please take a look. If you prefer reviewing diffs, they're behind the
>> "Download raw patch set" link.
>>
>> Description:
>> When there are lots of operator<<s, clang produces significantly worse
>> diagnostics than gcc, simply because of the size of the output. This
>> patch limits clang to 4 overload candidates, with the ability to show
>> the rest by passing -fshow-all-overloads, as a first cut. We'll want to
>> refine that later as examples of bad behavior come up.
>
>
> Unless we can be fairly sure that the "right" operator<< is in those first
4 overload candidates, I don't think this is a good idea. Unlike with
suppressing inner template/macro instantiation histories, this change is
likely to suppress important information.
>

I agree that it will sometimes suppress important information. That's why I
added the -fshow-all-overloads flag so the user can get it back if they need
it. But in cases like the one below, there are too many overloads printed to
find the "right" one, even if it were present, and they just discourage
users from reading any of them. 4 is clearly not the right cut-off in all
cases, and cutting off after a drop in quality is likely to be better in
many cases, but it fixes some of the most egregious behavior pretty easily.
We can fix places where it omits useful overloads as they come up.

If you prefer, I can look for a quality drop based
on CompareOverloadCandidatesForDisplay instead of the fixed cutoff. I'll
want a hard cutoff around 6-10 anyway, since at that point I think most
users give up on our errors and just stare at the source instead.

I'd rather not wait until the ordering is great before improving this at
all.


./util/gtl/stl_logging-inl.h:42:33: error: invalid operands to binary
expression ('basic_ostream<char, std::char_traits<char> >' and
'std::vector<int, std::allocator<int> > const')
 out << '(' << p.first << ", " << p.second << ')';
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~
In file included from ...:4:
In file included from ...:10:
In file included from ...:280:
In file included from ...:7:
In file included from ...:103:
In file included from ...:20:
In file included from ...:7:
In file included from ...:49:
In file included from ...:40:
In file included from ...:6:
.../include/c++/4.4.0/ostream:107:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'__ostream_type &(*)(__ostream_type &)' for 1st argument
     operator<<(__ostream_type& (*__pf)(__ostream_type&))
     ^
.../include/c++/4.4.0/ostream:116:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'__ios_type &(*)(__ios_type &)' for 1st argument
     operator<<(__ios_type& (*__pf)(__ios_type&))
     ^
.../include/c++/4.4.0/ostream:126:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'std::ios_base &(*)(std::ios_base &)' for 1st argument
     operator<<(ios_base& (*__pf) (ios_base&))
     ^
.../include/c++/4.4.0/ostream:164:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'long' for 1st argument
     operator<<(long __n)
     ^
.../include/c++/4.4.0/ostream:168:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'unsigned long' for 1st argument
     operator<<(unsigned long __n)
     ^
.../include/c++/4.4.0/ostream:172:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'bool' for 1st argument
     operator<<(bool __n)
     ^
.../include/c++/4.4.0/ostream:176:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'short' for 1st argument
     operator<<(short __n);
     ^
.../include/c++/4.4.0/ostream:179:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'unsigned short' for 1st argument
     operator<<(unsigned short __n)
     ^
.../include/c++/4.4.0/ostream:187:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'int' for 1st argument
     operator<<(int __n);
     ^
.../include/c++/4.4.0/ostream:190:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'unsigned int' for 1st argument
     operator<<(unsigned int __n)
     ^
.../include/c++/4.4.0/ostream:199:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'long long' for 1st argument
     operator<<(long long __n)
     ^
.../include/c++/4.4.0/ostream:203:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'unsigned long long' for 1st argument
     operator<<(unsigned long long __n)
     ^
.../include/c++/4.4.0/ostream:208:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'double' for 1st argument
     operator<<(double __f)
     ^
.../include/c++/4.4.0/ostream:212:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'float' for 1st argument
     operator<<(float __f)
     ^
.../include/c++/4.4.0/ostream:220:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'long double' for 1st argument
     operator<<(long double __f)
     ^
.../include/c++/4.4.0/ostream:224:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'void const *' for 1st argument
     operator<<(const void* __p)
     ^
.../include/c++/4.4.0/ostream:249:7: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'__streambuf_type *' (aka 'basic_streambuf<char, std::char_traits<char> >
*') for 1st argument
     operator<<(__streambuf_type* __sb);
     ^
.../include/c++/4.4.0/ostream:450:5: note: candidate function [with _CharT =
char, _Traits = std::char_traits<char>] not viable: no known conversion from
'std::vector<int, std::allocator<int> > const' to 'char' for 2nd argument
   operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
   ^
.../include/c++/4.4.0/ostream:456:5: note: candidate function [with _Traits
= std::char_traits<char>] not viable: no known conversion from
'std::vector<int, std::allocator<int> > const' to 'char' for 2nd argument
   operator<<(basic_ostream<char, _Traits>& __out, char __c)
   ^
.../include/c++/4.4.0/ostream:462:5: note: candidate function [with _Traits
= std::char_traits<char>] not viable: no known conversion from
'std::vector<int, std::allocator<int> > const' to 'signed char' for 2nd
argument
   operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
   ^
.../include/c++/4.4.0/ostream:467:5: note: candidate function [with _Traits
= std::char_traits<char>] not viable: no known conversion from
'std::vector<int, std::allocator<int> > const' to 'unsigned char' for 2nd
argument
   operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
   ^
.../include/c++/4.4.0/ostream:504:5: note: candidate function [with _Traits
= std::char_traits<char>] not viable: no known conversion from
'std::vector<int, std::allocator<int> > const' to 'char const *' for 2nd
argument
   operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
   ^
.../include/c++/4.4.0/ostream:517:5: note: candidate function [with _Traits
= std::char_traits<char>] not viable: no known conversion from
'std::vector<int, std::allocator<int> > const' to 'signed char const *' for
2nd argument
   operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
   ^
.../include/c++/4.4.0/ostream:522:5: note: candidate function [with _Traits
= std::char_traits<char>] not viable: no known conversion from
'std::vector<int, std::allocator<int> > const' to 'unsigned char const *'
for 2nd argument
   operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
   ^
In file included from ...:4:
In file included from ...:10:
In file included from ...:280:
In file included from ...:7:
In file included from ...:103:
In file included from ...:20:
In file included from ...:7:
In file included from ...:49:
In file included from ...:40:
In file included from ...:6:
In file included from ...:564:
.../include/c++/4.4.0/bits/ostream.tcc:320:5: note: candidate function [with
_CharT = char, _Traits = std::char_traits<char>] not viable: no known
conversion from 'std::vector<int, std::allocator<int> > const' to 'char
const *' for 2nd argument
   operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
   ^
In file included from ...:4:
In file included from ...:10:
In file included from ...:280:
In file included from ...:7:
In file included from ...:103:
./base/logging.h:1205:10: note: candidate function not viable: no known
conversion from 'std::vector<int, std::allocator<int> > const' to
'PRIVATE_Counter const' for 2nd argument
ostream& operator<<(ostream &os, const PRIVATE_Counter&);
        ^
./base/logging.h:1212:17: note: candidate function not viable: no known
conversion from 'std::vector<int, std::allocator<int> > const' to 'DocId
const' for 2nd argument
inline ostream& operator<<(ostream& o, const DocId& d) {
               ^
./base/logging.h:1216:17: note: candidate function not viable: no known
conversion from 'std::vector<int, std::allocator<int> > const' to
'DocId32Bit const' for 2nd argument
inline ostream& operator<<(ostream& o, const DocId32Bit& d) {
               ^
./base/logging.h:1520:20: note: candidate function [with T =
std::vector<int, std::allocator<int> >] not viable: no known conversion from
'basic_ostream<char, std::char_traits<char> >' to 'NullStream &' for 1st
argument
inline NullStream& operator<<(NullStream &str, const T &value) { return str;
}
                  ^
In file included from ...:4:
In file included from ...:11:
In file included from ...:21:
In file included from ...:11:
In file included from ...:20:
In file included from ...:30:
In file included from ...:27:
In file included from ...:60:
./base/int128.h:70:17: note: candidate function not viable: no known
conversion from 'std::vector<int, std::allocator<int> > const' to 'uint128
const' for 2nd argument
extern ostream& operator<<(ostream& o, const uint128& b);
               ^
In file included from ...:4:
In file included from ...:11:
In file included from ...:21:
In file included from ...:11:
In file included from ...:20:
In file included from ...:30:
./strings/stringpiece.h:226:17: note: candidate function not viable: no
known conversion from 'std::vector<int, std::allocator<int> > const' to
'StringPiece const' for 2nd argument
extern ostream& operator<<(ostream& o, const StringPiece& piece);
               ^
In file included from ...:4:
In file included from ...:11:
In file included from ...:21:
In file included from ...:15:
In file included from ...:49:
In file included from ...:17:
In file included from ...:16:
In file included from ...:27:
./strings/cord.h:561:17: note: candidate function not viable: no known
conversion from 'std::vector<int, std::allocator<int> > const' to 'Cord
const' for 2nd argument
extern ostream& operator<<(ostream& out, const Cord& cord);
               ^
In file included from ...:17:
In file included from ...:14:
In file included from ...:13:
In file included from ...:111:
In file included from ...:125:
In file included from ...:6:
.../include/c++/4.4.0/iomanip:75:5: note: candidate function [with _CharT =
char, _Traits = std::char_traits<char>] not viable: no known conversion from
'std::vector<int, std::allocator<int> > const' to 'std::_Resetiosflags' for
2nd argument
   operator<<(basic_ostream<_CharT, _Traits>& __os, _Resetiosflags __f)
   ^
.../include/c++/4.4.0/iomanip:109:5: note: candidate function [with _CharT =
char, _Traits = std::char_traits<char>] not viable: no known conversion from
'std::vector<int, std::allocator<int> > const' to 'std::_Setiosflags' for
2nd argument
   operator<<(basic_ostream<_CharT, _Traits>& __os, _Setiosflags __f)
   ^
.../include/c++/4.4.0/iomanip:147:5: note: candidate function [with _CharT =
char, _Traits = std::char_traits<char>] not viable: no known conversion from
'std::vector<int, std::allocator<int> > const' to 'std::_Setbase' for 2nd
argument
   operator<<(basic_ostream<_CharT, _Traits>& __os, _Setbase __f)
   ^
.../include/c++/4.4.0/iomanip:220:5: note: candidate function [with _CharT =
char, _Traits = std::char_traits<char>] not viable: no known conversion from
'std::vector<int, std::allocator<int> > const' to 'std::_Setprecision' for
2nd argument
   operator<<(basic_ostream<_CharT, _Traits>& __os, _Setprecision __f)
   ^
.../include/c++/4.4.0/iomanip:254:5: note: candidate function [with _CharT =
char, _Traits = std::char_traits<char>] not viable: no known conversion from
'std::vector<int, std::allocator<int> > const' to 'std::_Setw' for 2nd
argument
   operator<<(basic_ostream<_CharT, _Traits>& __os, _Setw __f)
   ^
In file included from ...:4:
In file included from ...:6:
In file included from ...:6:
In file included from ...:52:
.../include/c++/4.4.0/bits/basic_string.h:2500:5: note: candidate template
ignored: failed template argument deduction
   operator<<(basic_ostream<_CharT, _Traits>& __os,
   ^
In file included from ...:4:
In file included from ...:6:
In file included from ...:48:
.../include/c++/4.4.0/ext/vstring.h:2407:5: note: candidate template
ignored: failed template argument deduction
   operator<<(basic_ostream<_CharT, _Traits>& __os,
   ^
In file included from ...:4:
In file included from ...:6:
third_party/stl/gcc3/string:550:3: note: candidate template ignored: failed
template argument deduction
 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 ^
In file included from ...:4:
In file included from ...:10:
In file included from ...:280:
In file included from ...:7:
In file included from ...:103:
In file included from ...:20:
In file included from ...:7:
In file included from ...:49:
In file included from ...:40:
In file included from ...:6:
.../include/c++/4.4.0/ostream:445:5: note: candidate template ignored:
deduced conflicting types for parameter '_CharT' ('char' vs.
'std::vector<int, std::allocator<int> >')
   operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
   ^
.../include/c++/4.4.0/ostream:487:5: note: candidate template ignored:
failed template argument deduction
   operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
   ^
In file included from ...:17:
In file included from ...:14:
In file included from ...:13:
In file included from ...:111:
In file included from ...:125:
In file included from ...:6:
.../include/c++/4.4.0/iomanip:186:5: note: candidate template ignored:
failed template argument deduction
   operator<<(basic_ostream<_CharT, _Traits>& __os, _Setfill<_CharT> __f)
   ^
In file included from ...:25:
./util/gtl/stl_logging-inl.h:41:17: note: candidate template ignored: failed
template argument deduction
inline ostream& operator<<(ostream& out, const pair<First, Second>& p) {
               ^
1 error generated.


NewCallback() (similar to tr1::bind) provides another wealth of spammy
overloads, with a mix of bad-arity and bad-conversion.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100608/a07dd638/attachment.html>


More information about the cfe-commits mailing list