Skip to content

Commit 24c7d97

Browse files
committed
[ELF] Replace context-less errorHandler() and error() with ctx.errHandler
1 parent 3f6a1d1 commit 24c7d97

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

lld/ELF/Driver.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ void LinkerDriver::addLibrary(StringRef name) {
388388
if (std::optional<std::string> path = searchLibrary(ctx, name))
389389
addFile(saver().save(*path), /*withLOption=*/true);
390390
else
391-
error("unable to find library -l" + name, ErrorTag::LibNotFound, {name});
391+
ctx.errHandler->error("unable to find library -l" + name,
392+
ErrorTag::LibNotFound, {name});
392393
}
393394

394395
// This function is called on startup. We need this for LTO since
@@ -642,11 +643,11 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
642643
opt::InputArgList args = parser.parse(ctx, argsArr.slice(1));
643644

644645
// Interpret these flags early because Err/Warn depend on them.
645-
errorHandler().errorLimit = args::getInteger(args, OPT_error_limit, 20);
646-
errorHandler().fatalWarnings =
646+
ctx.errHandler->errorLimit = args::getInteger(args, OPT_error_limit, 20);
647+
ctx.errHandler->fatalWarnings =
647648
args.hasFlag(OPT_fatal_warnings, OPT_no_fatal_warnings, false) &&
648649
!args.hasArg(OPT_no_warnings);
649-
errorHandler().suppressWarnings = args.hasArg(OPT_no_warnings);
650+
ctx.errHandler->suppressWarnings = args.hasArg(OPT_no_warnings);
650651

651652
// Handle -help
652653
if (args.hasArg(OPT_help)) {
@@ -1278,8 +1279,8 @@ static bool remapInputs(Ctx &ctx, StringRef line, const Twine &location) {
12781279

12791280
// Initializes Config members by the command line options.
12801281
static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
1281-
errorHandler().verbose = args.hasArg(OPT_verbose);
1282-
errorHandler().vsDiagnostics =
1282+
ctx.errHandler->verbose = args.hasArg(OPT_verbose);
1283+
ctx.errHandler->vsDiagnostics =
12831284
args.hasArg(OPT_visual_studio_diagnostics_format, false);
12841285

12851286
ctx.arg.allowMultipleDefinition =
@@ -1337,7 +1338,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
13371338
args.hasArg(OPT_enable_non_contiguous_regions);
13381339
ctx.arg.entry = args.getLastArgValue(OPT_entry);
13391340

1340-
errorHandler().errorHandlingScript =
1341+
ctx.errHandler->errorHandlingScript =
13411342
args.getLastArgValue(OPT_error_handling_script);
13421343

13431344
ctx.arg.executeOnly =

lld/ELF/Relocations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ static void reportUndefinedSymbol(Ctx &ctx, const UndefinedDiag &undef,
798798
if (undef.isWarning)
799799
Warn(ctx) << msg;
800800
else
801-
error(msg, ErrorTag::SymbolNotFound, {sym.getName()});
801+
ctx.errHandler->error(msg, ErrorTag::SymbolNotFound, {sym.getName()});
802802
}
803803

804804
void elf::reportUndefinedSymbols(Ctx &ctx) {

lld/ELF/Writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ template <class ELFT> class Writer {
4949
public:
5050
LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
5151

52-
Writer(Ctx &ctx) : ctx(ctx), buffer(errorHandler().outputBuffer) {}
52+
Writer(Ctx &ctx) : ctx(ctx), buffer(ctx.errHandler->outputBuffer) {}
5353

5454
void run();
5555

0 commit comments

Comments
 (0)