@@ -219,7 +219,7 @@ void LinkerDriver::addBuffer(std::unique_ptr<MemoryBuffer> mb,
219219 make<std::unique_ptr<Archive>>(std::move (file)); // take ownership
220220
221221 int memberIndex = 0 ;
222- for (MemoryBufferRef m : getArchiveMembers (archive))
222+ for (MemoryBufferRef m : getArchiveMembers (ctx, archive))
223223 addArchiveBuffer (m, " <whole-archive>" , filename, memberIndex++);
224224 return ;
225225 }
@@ -1033,8 +1033,8 @@ void LinkerDriver::createImportLibrary(bool asLib) {
10331033 SmallString<128 > tmpName;
10341034 if (std::error_code ec =
10351035 sys::fs::createUniqueFile (path + " .tmp-%%%%%%%%.lib" , tmpName))
1036- fatal ( " cannot create temporary file for import library " + path + " : " +
1037- ec.message () );
1036+ Fatal (ctx) << " cannot create temporary file for import library " << path
1037+ << " : " << ec.message ();
10381038
10391039 if (Error e = writeImportLibrary (libName, tmpName, exports,
10401040 ctx.config .machine , ctx.config .mingw )) {
@@ -1233,11 +1233,11 @@ static void readCallGraphsFromObjectFiles(COFFLinkerContext &ctx) {
12331233 uint32_t fromIndex, toIndex;
12341234 uint64_t count;
12351235 if (Error err = reader.readInteger (fromIndex))
1236- fatal ( toString (obj) + " : Expected 32-bit integer" ) ;
1236+ Fatal (ctx) << toString (obj) << " : Expected 32-bit integer" ;
12371237 if (Error err = reader.readInteger (toIndex))
1238- fatal ( toString (obj) + " : Expected 32-bit integer" ) ;
1238+ Fatal (ctx) << toString (obj) << " : Expected 32-bit integer" ;
12391239 if (Error err = reader.readInteger (count))
1240- fatal ( toString (obj) + " : Expected 64-bit integer" ) ;
1240+ Fatal (ctx) << toString (obj) << " : Expected 64-bit integer" ;
12411241 auto *fromSym = dyn_cast_or_null<Defined>(obj->getSymbol (fromIndex));
12421242 auto *toSym = dyn_cast_or_null<Defined>(obj->getSymbol (toIndex));
12431243 if (!fromSym || !toSym)
@@ -1279,9 +1279,11 @@ static void findKeepUniqueSections(COFFLinkerContext &ctx) {
12791279 const char *err = nullptr ;
12801280 uint64_t symIndex = decodeULEB128 (cur, &size, contents.end (), &err);
12811281 if (err)
1282- fatal (toString (obj) + " : could not decode addrsig section: " + err);
1282+ Fatal (ctx) << toString (obj)
1283+ << " : could not decode addrsig section: " << err;
12831284 if (symIndex >= syms.size ())
1284- fatal (toString (obj) + " : invalid symbol index in addrsig section" );
1285+ Fatal (ctx) << toString (obj)
1286+ << " : invalid symbol index in addrsig section" ;
12851287 markAddrsig (syms[symIndex]);
12861288 cur += size;
12871289 }
@@ -1574,7 +1576,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
15741576 (StringRef (argsArr[1 ]).equals_insensitive (" /lib" ) ||
15751577 StringRef (argsArr[1 ]).equals_insensitive (" -lib" ))) {
15761578 if (llvm::libDriverMain (argsArr.slice (1 )) != 0 )
1577- fatal ( " lib failed" ) ;
1579+ Fatal (ctx) << " lib failed" ;
15781580 return ;
15791581 }
15801582
@@ -1676,7 +1678,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
16761678 if (args.hasArg (OPT_deffile))
16771679 config->noEntry = true ;
16781680 else
1679- fatal ( " no input files" ) ;
1681+ Fatal (ctx) << " no input files" ;
16801682 }
16811683
16821684 // Construct search path list.
@@ -1887,7 +1889,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
18871889 if (auto *arg = args.getLastArg (OPT_machine)) {
18881890 config->machine = getMachineType (arg->getValue ());
18891891 if (config->machine == IMAGE_FILE_MACHINE_UNKNOWN)
1890- fatal ( Twine ( " unknown /machine argument: " ) + arg->getValue () );
1892+ Fatal (ctx) << " unknown /machine argument: " << arg->getValue ();
18911893 addWinSysRootLibSearchPaths ();
18921894 }
18931895 }
@@ -1955,17 +1957,17 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
19551957 config->repro = false ;
19561958 StringRef value (arg->getValue ());
19571959 if (value.getAsInteger (0 , config->timestamp ))
1958- fatal ( Twine ( " invalid timestamp: " ) + value +
1959- " . Expected 32-bit integer" ) ;
1960+ Fatal (ctx) << " invalid timestamp: " << value
1961+ << " . Expected 32-bit integer" ;
19601962 }
19611963 } else {
19621964 config->repro = false ;
19631965 if (std::optional<std::string> epoch =
19641966 Process::GetEnv (" SOURCE_DATE_EPOCH" )) {
19651967 StringRef value (*epoch);
19661968 if (value.getAsInteger (0 , config->timestamp ))
1967- fatal ( Twine ( " invalid SOURCE_DATE_EPOCH timestamp: " ) + value +
1968- " . Expected 32-bit integer" ) ;
1969+ Fatal (ctx) << " invalid SOURCE_DATE_EPOCH timestamp: " << value
1970+ << " . Expected 32-bit integer" ;
19691971 } else {
19701972 config->timestamp = time (nullptr );
19711973 }
@@ -2155,7 +2157,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
21552157
21562158 if (!config->manifestInput .empty () &&
21572159 config->manifest != Configuration::Embed) {
2158- fatal ( " /manifestinput: requires /manifest:embed" ) ;
2160+ Fatal (ctx) << " /manifestinput: requires /manifest:embed" ;
21592161 }
21602162
21612163 // Handle /dwodir
@@ -2400,15 +2402,15 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
24002402 llvm::TimeTraceScope timeScope (" Infer subsystem" );
24012403 config->subsystem = inferSubsystem ();
24022404 if (config->subsystem == IMAGE_SUBSYSTEM_UNKNOWN)
2403- fatal ( " subsystem must be defined" ) ;
2405+ Fatal (ctx) << " subsystem must be defined" ;
24042406 }
24052407
24062408 // Handle /entry and /dll
24072409 {
24082410 llvm::TimeTraceScope timeScope (" Entry point" );
24092411 if (auto *arg = args.getLastArg (OPT_entry)) {
24102412 if (!arg->getValue ()[0 ])
2411- fatal ( " missing entry point symbol name" ) ;
2413+ Fatal (ctx) << " missing entry point symbol name" ;
24122414 config->entry = addUndefined (mangle (arg->getValue ()), true );
24132415 } else if (!config->entry && !config->noEntry ) {
24142416 if (args.hasArg (OPT_dll)) {
@@ -2423,7 +2425,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
24232425 // infer that from user-defined entry name.
24242426 StringRef s = findDefaultEntry ();
24252427 if (s.empty ())
2426- fatal ( " entry point must be defined" ) ;
2428+ Fatal (ctx) << " entry point must be defined" ;
24272429 config->entry = addUndefined (s, true );
24282430 Log (ctx) << " Entry name inferred: " << s;
24292431 }
0 commit comments