From 467e1b3aaa47643ace2011de38fe549a1b357464 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 15 Feb 2022 11:18:31 -0800 Subject: [PATCH] [ELF] reportDuplicate: change Symbol * to const Symbol &. NFC --- lld/ELF/Symbols.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index e604d35..972c70d 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -585,15 +585,14 @@ int Symbol::compare(const Symbol *other) const { return 0; } -static void reportDuplicate(Symbol *sym, InputFile *newFile, +static void reportDuplicate(const Symbol &sym, InputFile *newFile, InputSectionBase *errSec, uint64_t errOffset) { if (config->allowMultipleDefinition) return; - - Defined *d = cast(sym); + const Defined *d = cast(&sym); if (!d->section || !errSec) { - error("duplicate symbol: " + toString(*sym) + "\n>>> defined in " + - toString(sym->file) + "\n>>> defined in " + toString(newFile)); + error("duplicate symbol: " + toString(sym) + "\n>>> defined in " + + toString(sym.file) + "\n>>> defined in " + toString(newFile)); return; } @@ -605,12 +604,12 @@ static void reportDuplicate(Symbol *sym, InputFile *newFile, // >>> defined at baz.c:563 // >>> baz.o in archive libbaz.a auto *sec1 = cast(d->section); - std::string src1 = sec1->getSrcMsg(*sym, d->value); + std::string src1 = sec1->getSrcMsg(sym, d->value); std::string obj1 = sec1->getObjMsg(d->value); - std::string src2 = errSec->getSrcMsg(*sym, errOffset); + std::string src2 = errSec->getSrcMsg(sym, errOffset); std::string obj2 = errSec->getObjMsg(errOffset); - std::string msg = "duplicate symbol: " + toString(*sym) + "\n>>> defined at "; + std::string msg = "duplicate symbol: " + toString(sym) + "\n>>> defined at "; if (!src1.empty()) msg += src1 + "\n>>> "; msg += obj1 + "\n>>> defined at "; @@ -655,7 +654,7 @@ void Symbol::resolveDefined(const Defined &other) { if (cmp > 0) replace(other); else if (cmp == 0) - reportDuplicate(this, other.file, + reportDuplicate(*this, other.file, dyn_cast_or_null(other.section), other.value); } -- 2.7.4