[lld] [lld][ELF] Use the containing symbol, not the referenced symbol, for undefined symbol errors. (PR #70800)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 31 13:01:29 PDT 2023


MaskRay wrote:

The `sym` parameter of `getSrcMsg` provides a fallback when line table information is unavailable.
The line table information covers cases when the undefined symbol is from a function.

> `int * p[] = { &ex };`

This is about a case when the undefined symbol is from a variable with no line table information.
I am nervous if we need to spend these lines of code to give a diagnostic for this case and I'd probably choose not.

Fortunately, I think we can refactor the existing code (`getEnclosingFunction`) to give this diagnostic improvement with nearly no additional complexity: 
https://github.com/MaskRay/llvm-project/tree/lld-enclosing-function I haven't added a test yet.

https://github.com/llvm/llvm-project/pull/70800


More information about the llvm-commits mailing list