[lld] ae5fdae - [ELF] Simplify printLocation
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 7 20:31:55 PST 2024
Author: Fangrui Song
Date: 2024-12-07T20:31:50-08:00
New Revision: ae5fdaea43cbe7dd722f4fef84be005b2a41711d
URL: https://github.com/llvm/llvm-project/commit/ae5fdaea43cbe7dd722f4fef84be005b2a41711d
DIFF: https://github.com/llvm/llvm-project/commit/ae5fdaea43cbe7dd722f4fef84be005b2a41711d.diff
LOG: [ELF] Simplify printLocation
sym.file is always non-null (since around #78944).
Added:
Modified:
lld/ELF/Relocations.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 2268121827f649..4de24a21f6f43d 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -65,21 +65,8 @@ using namespace llvm::support::endian;
using namespace lld;
using namespace lld::elf;
-static std::optional<std::string> getLinkerScriptLocation(Ctx &ctx,
- const Symbol &sym) {
- for (SectionCommand *cmd : ctx.script->sectionCommands)
- if (auto *assign = dyn_cast<SymbolAssignment>(cmd))
- if (assign->sym == &sym)
- return assign->location;
- return std::nullopt;
-}
-
static void printDefinedLocation(ELFSyncStream &s, const Symbol &sym) {
- s << "\n>>> defined in ";
- if (sym.file)
- return void(s << sym.file);
- if (std::optional<std::string> loc = getLinkerScriptLocation(s.ctx, sym))
- return void(s << *loc);
+ s << "\n>>> defined in " << sym.file;
}
// Construct a message in the following format.
More information about the llvm-commits
mailing list