[cfe-commits] PATCH: Generate more useful messages for out-of-line definition errors

Kaelyn Uhrain rikka at google.com
Fri Jul 22 16:19:34 PDT 2011


Here's a patch to improve the messages for out-of-line definition errors by
including the function's signature along with its name, and in the candidate
function notes including the candidates name and signature as namespace
qualifiers aren't always apparent at the line of code with the declaration.

The patch is also available for review at
http://codereview.appspot.com/4817047

For example, given a file tmp.cpp containing:

namespace N2 {
 struct S1;

  namespace N1 {
   struct S2 {
     void func(S1*);
   };

   struct S1 {};
  }
}
void N2::N1::S2::func(S1*) {}

Clang currently reports:

tmp.cpp:12:18: error: out-of-line definition of 'func' does not match any
declaration in 'N2::N1::S2'
void N2::N1::S2::func(S1*) {}
     ~~~~~~~~~~~~^

Sadly, g++ (version 4.4.3) gives better messages:

tmp.cpp:12: error: prototype for 'void N2::N1::S2::func(N2::N1::S1*)' does
not match any in class 'N2::N1::S2'
tmp.cpp:6: error: candidate is: void N2::N1::S2::func(N2::S1*)

With this patch, clang yields:

tmp.cpp:12:18: error: out-of-line definition of 'void func(N2::N1::S1 *)'
does not match any
      declaration in 'N2::N1::S2'
void N2::N1::S2::func(S1*) {}
     ~~~~~~~~~~~~^
tmp.cpp:6:11: note: member declaration 'void func(N2::S1 *)' nearly matches
     void func(S1*);
          ^

Cheers,
Kaelyn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110722/58646502/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: out-of-line-def-error.diff
Type: text/x-diff
Size: 10068 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110722/58646502/attachment.diff>


More information about the cfe-commits mailing list