[ELF] Add a spell corrector for "undefined symbol" diagnostics
authorFangrui Song <maskray@google.com>
Wed, 4 Sep 2019 09:04:26 +0000 (09:04 +0000)
committerFangrui Song <maskray@google.com>
Wed, 4 Sep 2019 09:04:26 +0000 (09:04 +0000)
commitb4745fad24663ae50a592b57c6e1bf1c7e4d1527
treeb4d77144c745aed21d92fcdb0b83e97370b11c82
parentb8b4fa47971491db63620d75b97d5ea00cd0b0cc
[ELF] Add a spell corrector for "undefined symbol" diagnostics

Non-undefined symbols with Levenshtein distance 1 or a transposition are
suggestion candidates. This is probably good enough and it can suggest
some missing/superfluous qualifiers: const, restrict, volatile, & and &&
ref-qualifier, e.g.

   error: undefined symbol: foo(int*)
   >>> referenced by b.o:(.text+0x1)
  +>>> did you mean: foo(int const*)
  +>>> defined in: a.o

   error: undefined symbol: foo(int*&)
   >>> referenced by b.o:(.text+0x1)
  +>>> did you mean: foo(int*)
  +>>> defined in: b.o

Reviewed By: ruiu

Differential Revision: https://reviews.llvm.org/D67039

llvm-svn: 370853
lld/ELF/Relocations.cpp
lld/test/ELF/undef-spell-corrector.s [new file with mode: 0644]