[lld] [LLD][COFF] Introduce Symbol::getDefined helper. (NFC) (PR #151253)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 30 04:22:14 PDT 2025
================
@@ -91,6 +91,14 @@ bool Symbol::isLive() const {
return true;
}
+Defined *Symbol::getDefined() {
+ if (auto d = dyn_cast<Defined>(this))
+ return d;
+ if (auto u = dyn_cast<Undefined>(this))
----------------
mstorsjo wrote:
This (very) vaguely changes the logic from before - previously we tested `dyn_cast<Undefined>` before, while we now test them in different order. (In theory this could have a performance aspect, but that's not relevant.) What I wanted to say here, is that as long as only one of `dyn_cast<Defined>` and `dyn_cast<Undefined>` can succeed, i.e. they are mutually exclusive, then this should be fine - and this mildly rewritten form looks ok.
https://github.com/llvm/llvm-project/pull/151253
More information about the llvm-commits
mailing list