Skip to content

Commit d82422f

Browse files
committed
[ELF] Remove errorOrWarn
1 parent 032014e commit d82422f

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

lld/ELF/Config.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,7 @@ static inline ArrayRef<VersionDefinition> namedVersionDefs(Ctx &ctx) {
676676

677677
void errorOrWarn(const Twine &msg);
678678

679-
static inline void internalLinkerError(StringRef loc, const Twine &msg) {
680-
errorOrWarn(loc + "internal linker error: " + msg + "\n" +
681-
llvm::getBugReportMsg());
682-
}
679+
void internalLinkerError(StringRef loc, const Twine &msg);
683680

684681
struct ELFSyncStream : SyncStream {
685682
Ctx &ctx;

lld/ELF/Driver.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,6 @@ Ctx elf::ctx;
8484
static void setConfigs(Ctx &ctx, opt::InputArgList &args);
8585
static void readConfigs(Ctx &ctx, opt::InputArgList &args);
8686

87-
void elf::errorOrWarn(const Twine &msg) {
88-
if (ctx.arg.noinhibitExec)
89-
Warn(ctx) << msg;
90-
else
91-
ErrAlways(ctx) << msg;
92-
}
93-
9487
ELFSyncStream elf::Log(Ctx &ctx) { return {ctx, DiagLevel::Log}; }
9588
ELFSyncStream elf::Warn(Ctx &ctx) { return {ctx, DiagLevel::Warn}; }
9689
ELFSyncStream elf::Err(Ctx &ctx) {
@@ -100,6 +93,11 @@ ELFSyncStream elf::ErrAlways(Ctx &ctx) { return {ctx, DiagLevel::Err}; }
10093
ELFSyncStream elf::Fatal(Ctx &ctx) { return {ctx, DiagLevel::Fatal}; }
10194
uint64_t elf::errCount(Ctx &ctx) { return ctx.errHandler->errorCount; }
10295

96+
void elf::internalLinkerError(StringRef loc, const Twine &msg) {
97+
ELFSyncStream(ctx, DiagLevel::Err) << "internal linker error: " << msg << '\n'
98+
<< llvm::getBugReportMsg();
99+
}
100+
103101
Ctx::Ctx() : driver(*this) {}
104102

105103
void Ctx::reset() {

lld/ELF/Writer.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,10 +1822,11 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
18221822
ctx.in.iplt->addSymbols();
18231823

18241824
if (ctx.arg.unresolvedSymbolsInShlib != UnresolvedPolicy::Ignore) {
1825-
auto diagnose =
1826-
ctx.arg.unresolvedSymbolsInShlib == UnresolvedPolicy::ReportError
1827-
? errorOrWarn
1828-
: warn;
1825+
auto diag =
1826+
ctx.arg.unresolvedSymbolsInShlib == UnresolvedPolicy::ReportError &&
1827+
!ctx.arg.noinhibitExec
1828+
? DiagLevel::Err
1829+
: DiagLevel::Warn;
18291830
// Error on undefined symbols in a shared object, if all of its DT_NEEDED
18301831
// entries are seen. These cases would otherwise lead to runtime errors
18311832
// reported by the dynamic linker.
@@ -1850,14 +1851,14 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
18501851
if (sym->dsoDefined)
18511852
continue;
18521853
if (sym->isUndefined() && !sym->isWeak()) {
1853-
diagnose("undefined reference: " + toString(*sym) +
1854-
"\n>>> referenced by " + toString(file) +
1855-
" (disallowed by --no-allow-shlib-undefined)");
1854+
ELFSyncStream(ctx, diag)
1855+
<< "undefined reference: " << sym << "\n>>> referenced by "
1856+
<< file << " (disallowed by --no-allow-shlib-undefined)";
18561857
} else if (sym->isDefined() &&
18571858
sym->computeBinding(ctx) == STB_LOCAL) {
1858-
diagnose("non-exported symbol '" + toString(*sym) + "' in '" +
1859-
toString(sym->file) + "' is referenced by DSO '" +
1860-
toString(file) + "'");
1859+
ELFSyncStream(ctx, diag)
1860+
<< "non-exported symbol '" << sym << "' in '" << sym->file
1861+
<< "' is referenced by DSO '" << file << "'";
18611862
}
18621863
}
18631864
}

0 commit comments

Comments
 (0)