[PATCH] D69650: [ELF] Suggest an arbitrary C++ overload as an alternative spelling

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 31 01:44:12 PDT 2019


ruiu added inline comments.


================
Comment at: lld/test/ELF/undef-suggest-extern-cxx.s:15
+# CHECK-NEXT: >>> referenced by {{.*}}
+# CHECK-NEXT: >>> did you mean: one of the C++ overloads such as foo(int)
+
----------------
dblaikie wrote:
> This situation might be worth a few more words for the user.
> 
> This current phrasing makes it sounds like the person who wrote the call to foo, might've intended to call foo(int) - when they might've actually called foo(int), but with C mangling & there's a good chance the /call/ is correct (it'd be rare that someone wrote a header file intending to only use it for C++ and manage to just by accident write perfectly valid C in that header file without the intent that that file ever be included from C code) - and that it's the definition in C++ that needs to be fixed.
> 
> "did you mean to define foo(int) (or some other overload) as extern "C"?"
> 
> might be the phrasing to go for?
I like that error message style. But if the user's intention was to link `foo` as a C function, showing that function as `foo(int)` is a bit confusing? How about something like this?

   we found a C++ symbol that has a similar name -- did you forget to surround a declaration with 'extern "C"'?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69650/new/

https://reviews.llvm.org/D69650





More information about the llvm-commits mailing list