[PATCH] D53044: [ELF] Don't warn on undefined symbols if UnresolvedPolicy::Ignore is used
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 10 15:23:58 PDT 2018
MaskRay added inline comments.
================
Comment at: ELF/Symbols.cpp:280-288
Warn(": unable to order shared symbol: ");
- else if (D && !D->Section)
- Warn(": unable to order absolute symbol: ");
- else if (D && isa<OutputSection>(D->Section))
- Warn(": unable to order synthetic symbol: ");
- else if (D && !D->Section->Repl->Live)
- Warn(": unable to order discarded symbol: ");
+ } else if (D) {
+ if (!D->Section)
+ Warn(": unable to order absolute symbol: ");
+ else if (isa<OutputSection>(D->Section))
+ Warn(": unable to order synthetic symbol: ");
+ else if (!D->Section->Repl->Live)
----------------
ruiu wrote:
> MaskRay wrote:
> > ruiu wrote:
> > > Please do not change this -- this code was written in the way it is to reduce indentation depth.
> > Should I use `if (Sym->isUndefined() && Config->UnresolvedSymbols != UnresolvedPolicy::Ignore)` then?
> >
> > I actually find dispatching by `SymbolKind` first makes the code a bit easier to understand:
> >
> > * Undefined
> > * Shared
> > * Others (Defined)
> >
> > For the `Defined` case, fine-grained conditions are checked for absolute/syunthetic/discarded.
> >
> > I lean to this style but if you have strong opinion on this, I can change it.
> Yeah, maybe you should write that `if` at the beginning of this function to exit early.
But that way:
```
if (Sym->isUndefined() && Config->UnresolvedSymbols != UnresolvedPolicy::Ignore)
Warn(": unable to order undefined symbol: ");
else if (Sym->isShared())
Warn(": unable to order undefined symbol: ");
else if (Sym->isShared())
Warn(": unable to order shared symbol: ");
////// Sym->isUndefined() is possible here
else if (D && !D->Section)
Warn(": unable to order absolute symbol: ");
else if (D && isa<OutputSection>(D->Section))
Warn(": unable to order synthetic symbol: ");
else if (D && !D->Section->Repl->Live)
Warn(": unable to order discarded symbol: ");
```
Will that cause a problem?
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D53044
More information about the llvm-commits
mailing list