@@ -90,7 +90,7 @@ ELFSyncStream elf::Err(Ctx &ctx) {
9090}
9191ELFSyncStream elf::ErrAlways (Ctx &ctx) { return {ctx, DiagLevel::Err}; }
9292ELFSyncStream elf::Fatal (Ctx &ctx) { return {ctx, DiagLevel::Fatal}; }
93- uint64_t elf::errCount (Ctx &ctx) { return ctx.errHandler -> errorCount ; }
93+ uint64_t elf::errCount (Ctx &ctx) { return ctx.e . errorCount ; }
9494
9595ELFSyncStream elf::InternalErr (Ctx &ctx, const uint8_t *buf) {
9696 ELFSyncStream s (ctx, DiagLevel::Err);
@@ -112,9 +112,9 @@ namespace lld {
112112namespace elf {
113113bool link (ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
114114 llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput) {
115- Ctx ctx;
116115 // This driver-specific context will be freed later by unsafeLldMain().
117- auto *context = new CommonLinkerContext;
116+ auto *context = new Ctx;
117+ Ctx &ctx = *context;
118118
119119 context->e .initialize (stdoutOS, stderrOS, exitEarly, disableOutput);
120120 context->e .logName = args::getFilenameWithoutExe (args[0 ]);
@@ -124,8 +124,6 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
124124
125125 LinkerScript script (ctx);
126126 ctx.script = &script;
127- ctx.commonCtx = context;
128- ctx.errHandler = &context->e ;
129127 ctx.symAux .emplace_back ();
130128 ctx.symtab = std::make_unique<SymbolTable>(ctx);
131129
@@ -334,8 +332,8 @@ void LinkerDriver::addLibrary(StringRef name) {
334332 if (std::optional<std::string> path = searchLibrary (ctx, name))
335333 addFile (saver (ctx).save (*path), /* withLOption=*/ true );
336334 else
337- ctx.errHandler -> error (" unable to find library -l" + name,
338- ErrorTag::LibNotFound, {name});
335+ ctx.e . error (" unable to find library -l" + name, ErrorTag::LibNotFound ,
336+ {name});
339337}
340338
341339// This function is called on startup. We need this for LTO since
@@ -589,11 +587,11 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
589587 opt::InputArgList args = parser.parse (ctx, argsArr.slice (1 ));
590588
591589 // Interpret these flags early because Err/Warn depend on them.
592- ctx.errHandler -> errorLimit = args::getInteger (args, OPT_error_limit, 20 );
593- ctx.errHandler -> fatalWarnings =
590+ ctx.e . errorLimit = args::getInteger (args, OPT_error_limit, 20 );
591+ ctx.e . fatalWarnings =
594592 args.hasFlag (OPT_fatal_warnings, OPT_no_fatal_warnings, false ) &&
595593 !args.hasArg (OPT_no_warnings);
596- ctx.errHandler -> suppressWarnings = args.hasArg (OPT_no_warnings);
594+ ctx.e . suppressWarnings = args.hasArg (OPT_no_warnings);
597595
598596 // Handle -help
599597 if (args.hasArg (OPT_help)) {
@@ -667,10 +665,9 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
667665 }
668666
669667 if (ctx.arg .timeTraceEnabled ) {
670- checkError (
671- *ctx.errHandler ,
672- timeTraceProfilerWrite (args.getLastArgValue (OPT_time_trace_eq).str (),
673- ctx.arg .outputFile ));
668+ checkError (ctx.e , timeTraceProfilerWrite (
669+ args.getLastArgValue (OPT_time_trace_eq).str (),
670+ ctx.arg .outputFile ));
674671 timeTraceProfilerCleanup ();
675672 }
676673}
@@ -1227,8 +1224,8 @@ static bool remapInputs(Ctx &ctx, StringRef line, const Twine &location) {
12271224
12281225// Initializes Config members by the command line options.
12291226static void readConfigs (Ctx &ctx, opt::InputArgList &args) {
1230- ctx.errHandler -> verbose = args.hasArg (OPT_verbose);
1231- ctx.errHandler -> vsDiagnostics =
1227+ ctx.e . verbose = args.hasArg (OPT_verbose);
1228+ ctx.e . vsDiagnostics =
12321229 args.hasArg (OPT_visual_studio_diagnostics_format, false );
12331230
12341231 ctx.arg .allowMultipleDefinition =
@@ -1286,8 +1283,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
12861283 args.hasArg (OPT_enable_non_contiguous_regions);
12871284 ctx.arg .entry = args.getLastArgValue (OPT_entry);
12881285
1289- ctx.errHandler ->errorHandlingScript =
1290- args.getLastArgValue (OPT_error_handling_script);
1286+ ctx.e .errorHandlingScript = args.getLastArgValue (OPT_error_handling_script);
12911287
12921288 ctx.arg .executeOnly =
12931289 args.hasFlag (OPT_execute_only, OPT_no_execute_only, false );
0 commit comments