[PATCH] D69592: [ELF] Suggest the extern "C" name as an alternative spelling

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 30 17:04:43 PDT 2019


MaskRay marked an inline comment as done.
MaskRay added a comment.

In D69592#1726758 <https://reviews.llvm.org/D69592#1726758>, @peter.smith wrote:

> If there were many references in an overload set abcde(int); abcde(float); etc. then we'd get multiple references matched against the suggestion abcde. I don't think this isn't the end of the world, as a user can make sense of it, even if it might look obviously wrong to some.
>
> Thinking about the reverse problem, I think we could identify top level non-nested mangled function names by looking for a prefix of _Z(number), nested names would start with _ZN(number). We could catch these, extract the (number) of characters for the C name, and end up with something like a mapping from C name -> mangled name. If an undefined "C" name matches in the table we can demangle the mangled name. Given that there can be multiple C++ names that match the C name it might be better doing in a separate function with a custom diagnostic to handle multiple matches. Something like:
>
>    error: undefined symbol: abcde
>   >>> referenced by {{.*}}
>   >>> did you mean one of the C++ overloads such as abcde(int) 
>   
>
> In summary I think this is a reasonable low cost addition, so I'm happy to add it. Might not be too much effort to do a separate function that could give a more specific diagnostic though.


Thanks for the suggestion! I am motivated to do the other direction now... D69650 <https://reviews.llvm.org/D69650> implements the other direction (definition is mangled; reference is not).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69592





More information about the llvm-commits mailing list