On Tue, Jun 8, 2010 at 7:49 AM, Douglas Gregor <<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>> wrote:<br>><br>> On Jun 7, 2010, at 6:03 PM, <a href="mailto:jyasskin@gmail.com">jyasskin@gmail.com</a> wrote:<br>

><br>>> Reviewers: <a href="http://cfe-commits_cs.uiuc.edu">cfe-commits_cs.uiuc.edu</a>,<br>>><br>>> Message:<br>>> Please take a look. If you prefer reviewing diffs, they're behind the<br>
>> "Download raw patch set" link.<br>
>><br>>> Description:<br>>> When there are lots of operator<<s, clang produces significantly worse<br>>> diagnostics than gcc, simply because of the size of the output. This<br>>> patch limits clang to 4 overload candidates, with the ability to show<br>

>> the rest by passing -fshow-all-overloads, as a first cut. We'll want to<br>>> refine that later as examples of bad behavior come up.<br>><br>><br>> 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.<br>

><br><br>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.<div>

<br></div><div>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.</div>

<div><br></div><div>I'd rather not wait until the ordering is great before improving this at all.<br><br><br><font class="Apple-style-span" face="'courier new', monospace">./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')<br>

  out << '(' << p.first << ", " << p.second << ')';<br>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~<br>In file included from ...:4:<br>In file included from ...:10:<br>

In file included from ...:280:<br>In file included from ...:7:<br>In file included from ...:103:<br>In file included from ...:20:<br>In file included from ...:7:<br>In file included from ...:49:<br>In file included from ...:40:<br>

In file included from ...:6:<br>.../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<br>

      operator<<(__ostream_type& (*__pf)(__ostream_type&))<br>      ^<br>.../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<br>

      operator<<(__ios_type& (*__pf)(__ios_type&))<br>      ^<br>.../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<br>

      operator<<(ios_base& (*__pf) (ios_base&))<br>      ^<br>.../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<br>

      operator<<(long __n)<br>      ^<br>.../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<br>

      operator<<(unsigned long __n)<br>      ^<br>.../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<br>

      operator<<(bool __n)<br>      ^<br>.../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<br>

      operator<<(short __n);<br>      ^<br>.../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<br>

      operator<<(unsigned short __n)<br>      ^<br>.../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<br>

      operator<<(int __n);<br>      ^<br>.../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<br>

      operator<<(unsigned int __n)<br>      ^<br>.../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<br>

      operator<<(long long __n)<br>      ^<br>.../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<br>

      operator<<(unsigned long long __n)<br>      ^<br>.../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<br>

      operator<<(double __f)<br>      ^<br>.../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<br>

      operator<<(float __f)<br>      ^<br>.../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<br>

      operator<<(long double __f)<br>      ^<br>.../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<br>

      operator<<(const void* __p)<br>      ^<br>.../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<br>

      operator<<(__streambuf_type* __sb);<br>      ^<br>.../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<br>

    operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)<br>    ^<br>.../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<br>

    operator<<(basic_ostream<char, _Traits>& __out, char __c)<br>    ^<br>.../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<br>

    operator<<(basic_ostream<char, _Traits>& __out, signed char __c)<br>    ^<br>.../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<br>

    operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)<br>    ^<br>.../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<br>

    operator<<(basic_ostream<char, _Traits>& __out, const char* __s)<br>    ^<br>.../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<br>

    operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)<br>    ^<br>.../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<br>

    operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)<br>    ^<br>In file included from ...:4:<br>In file included from ...:10:<br>In file included from ...:280:<br>In file included from ...:7:<br>

In file included from ...:103:<br>In file included from ...:20:<br>In file included from ...:7:<br>In file included from ...:49:<br>In file included from ...:40:<br>In file included from ...:6:<br>In file included from ...:564:<br>

.../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<br>

    operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)<br>    ^<br>In file included from ...:4:<br>In file included from ...:10:<br>In file included from ...:280:<br>In file included from ...:7:<br>

In file included from ...:103:<br>./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<br>

ostream& operator<<(ostream &os, const PRIVATE_Counter&);<br>         ^<br>./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<br>

inline ostream& operator<<(ostream& o, const DocId& d) {<br>                ^<br>./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<br>

inline ostream& operator<<(ostream& o, const DocId32Bit& d) {<br>                ^<br>./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<br>

inline NullStream& operator<<(NullStream &str, const T &value) { return str; }<br>                   ^<br>In file included from ...:4:<br>In file included from ...:11:<br>In file included from ...:21:<br>

In file included from ...:11:<br>In file included from ...:20:<br>In file included from ...:30:<br>In file included from ...:27:<br>In file included from ...:60:<br>./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<br>

extern ostream& operator<<(ostream& o, const uint128& b);<br>                ^<br>In file included from ...:4:<br>In file included from ...:11:<br>In file included from ...:21:<br>In file included from ...:11:<br>

In file included from ...:20:<br>In file included from ...:30:<br>./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<br>

extern ostream& operator<<(ostream& o, const StringPiece& piece);<br>                ^<br>In file included from ...:4:<br>In file included from ...:11:<br>In file included from ...:21:<br>In file included from ...:15:<br>

In file included from ...:49:<br>In file included from ...:17:<br>In file included from ...:16:<br>In file included from ...:27:<br>./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<br>

extern ostream& operator<<(ostream& out, const Cord& cord);<br>                ^<br>In file included from ...:17:<br>In file included from ...:14:<br>In file included from ...:13:<br>In file included from ...:111:<br>

In file included from ...:125:<br>In file included from ...:6:<br>.../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<br>

    operator<<(basic_ostream<_CharT, _Traits>& __os, _Resetiosflags __f)<br>    ^<br>.../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<br>

    operator<<(basic_ostream<_CharT, _Traits>& __os, _Setiosflags __f)<br>    ^<br>.../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<br>

    operator<<(basic_ostream<_CharT, _Traits>& __os, _Setbase __f)<br>    ^<br>.../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<br>

    operator<<(basic_ostream<_CharT, _Traits>& __os, _Setprecision __f)<br>    ^<br>.../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<br>

    operator<<(basic_ostream<_CharT, _Traits>& __os, _Setw __f)<br>    ^<br>In file included from ...:4:<br>In file included from ...:6:<br>In file included from ...:6:<br>In file included from ...:52:<br>

.../include/c++/4.4.0/bits/basic_string.h:2500:5: note: candidate template ignored: failed template argument deduction<br>    operator<<(basic_ostream<_CharT, _Traits>& __os,<br>    ^<br>In file included from ...:4:<br>

In file included from ...:6:<br>In file included from ...:48:<br>.../include/c++/4.4.0/ext/vstring.h:2407:5: note: candidate template ignored: failed template argument deduction<br>    operator<<(basic_ostream<_CharT, _Traits>& __os,<br>

    ^<br>In file included from ...:4:<br>In file included from ...:6:<br>third_party/stl/gcc3/string:550:3: note: candidate template ignored: failed template argument deduction<br>  operator<<(std::basic_ostream<_CharT, _Traits>& __os,<br>

  ^<br>In file included from ...:4:<br>In file included from ...:10:<br>In file included from ...:280:<br>In file included from ...:7:<br>In file included from ...:103:<br>In file included from ...:20:<br>In file included from ...:7:<br>

In file included from ...:49:<br>In file included from ...:40:<br>In file included from ...:6:<br>.../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> >')<br>

    operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)<br>    ^<br>.../include/c++/4.4.0/ostream:487:5: note: candidate template ignored: failed template argument deduction<br>    operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)<br>

    ^<br>In file included from ...:17:<br>In file included from ...:14:<br>In file included from ...:13:<br>In file included from ...:111:<br>In file included from ...:125:<br>In file included from ...:6:<br>.../include/c++/4.4.0/iomanip:186:5: note: candidate template ignored: failed template argument deduction<br>

    operator<<(basic_ostream<_CharT, _Traits>& __os, _Setfill<_CharT> __f)<br>    ^<br>In file included from ...:25:<br>./util/gtl/stl_logging-inl.h:41:17: note: candidate template ignored: failed template argument deduction<br>

inline ostream& operator<<(ostream& out, const pair<First, Second>& p) {<br>                ^<br>1 error generated.</font></div><div><br></div><div><br></div><div>NewCallback() (similar to tr1::bind) provides another wealth of spammy overloads, with a mix of bad-arity and bad-conversion.</div>