[lld] 467e1b3 - [ELF] reportDuplicate: change Symbol * to const Symbol &. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 15 11:18:38 PST 2022
Author: Fangrui Song
Date: 2022-02-15T11:18:31-08:00
New Revision: 467e1b3aaa47643ace2011de38fe549a1b357464
URL: https://github.com/llvm/llvm-project/commit/467e1b3aaa47643ace2011de38fe549a1b357464
DIFF: https://github.com/llvm/llvm-project/commit/467e1b3aaa47643ace2011de38fe549a1b357464.diff
LOG: [ELF] reportDuplicate: change Symbol * to const Symbol &. NFC
Added:
Modified:
lld/ELF/Symbols.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index e604d350574b..972c70d53af8 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<Defined>(sym);
+ const Defined *d = cast<Defined>(&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<InputSectionBase>(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<InputSectionBase>(other.section),
other.value);
}
More information about the llvm-commits
mailing list