[PATCH] D67039: [ELF] Add a spell corrector for "undefined symbol" diagnostics

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 2 18:50:30 PDT 2019


MaskRay added a comment.

In D67039#1655055 <https://reviews.llvm.org/D67039#1655055>, @thakis wrote:

> This is a cool idea, but I'm struggling to come up with a scenario where it's actually useful :)
>
> For this to fire and be a true positive, you'd have to have an incorrect declaration but a correct definition of a function. I can't remember ever running into this – and the compiler seems to be in a better place to print a diagnostic for this case in almost all cases (except for if the TU with the correct definition doesn't happen to see the incorrect declaration).


The file that provides the definition may have a mismatch of the declaration and the definition, e.g.

  // a.h
  void foo(int &a);
  
  // a.cc
  #include "a.h"
  void foo(int a) {}
  
  // b.cc
  #include "a.h"
  void bar(int a) { foo(a); }
  
  % ld.lld a.o b.o            
  ld.lld: error: undefined symbol: foo(int&)
  >>> referenced by b.cc
  >>>               b.o:(bar(int))
  >>> did you mean: foo(int)
  >>> defined in: a.o


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D67039





More information about the llvm-commits mailing list