@@ -809,7 +809,7 @@ StringRef LinkerDriver::findDefaultEntry() {
809809 if (findUnderscoreMangle (" wmain" )) {
810810 if (!findUnderscoreMangle (" main" ))
811811 return mangle (" wmainCRTStartup" );
812- warn ( " found both wmain and main; using latter" ) ;
812+ Warn (ctx) << " found both wmain and main; using latter" ;
813813 }
814814 return mangle (" mainCRTStartup" );
815815}
@@ -828,9 +828,9 @@ WindowsSubsystem LinkerDriver::inferSubsystem() {
828828 bool haveWWinMain = findUnderscoreMangle (" wWinMain" );
829829 if (haveMain || haveWMain) {
830830 if (haveWinMain || haveWWinMain) {
831- warn ( std::string ( " found " ) + (haveMain ? " main" : " wmain" ) + " and " +
832- (haveWinMain ? " WinMain" : " wWinMain" ) +
833- " ; defaulting to /subsystem:console" ) ;
831+ Warn (ctx) << " found " << (haveMain ? " main" : " wmain" ) << " and "
832+ << (haveWinMain ? " WinMain" : " wWinMain" )
833+ << " ; defaulting to /subsystem:console" ;
834834 }
835835 return IMAGE_SUBSYSTEM_WINDOWS_CUI;
836836 }
@@ -910,7 +910,8 @@ static std::string createResponseFile(const opt::InputArgList &args,
910910 return std::string (data);
911911}
912912
913- static unsigned parseDebugTypes (const opt::InputArgList &args) {
913+ static unsigned parseDebugTypes (COFFLinkerContext &ctx,
914+ const opt::InputArgList &args) {
914915 unsigned debugTypes = static_cast <unsigned >(DebugType::None);
915916
916917 if (auto *a = args.getLastArg (OPT_debugtype)) {
@@ -925,7 +926,7 @@ static unsigned parseDebugTypes(const opt::InputArgList &args) {
925926 .Case (" fixup" , static_cast <unsigned >(DebugType::Fixup))
926927 .Default (0 );
927928 if (v == 0 ) {
928- warn ( " /debugtype: unknown option '" + type + " '" ) ;
929+ Warn (ctx) << " /debugtype: unknown option '" << type << " '" ;
929930 continue ;
930931 }
931932 debugTypes |= v;
@@ -1162,7 +1163,8 @@ void LinkerDriver::parseOrderFile(StringRef arg) {
11621163
11631164 if (set.count (s) == 0 ) {
11641165 if (ctx.config .warnMissingOrderSymbol )
1165- warn (" /order:" + arg + " : missing symbol: " + s + " [LNK4037]" );
1166+ Warn (ctx) << " /order:" << arg << " : missing symbol: " << s
1167+ << " [LNK4037]" ;
11661168 } else
11671169 ctx.config .order [s] = INT_MIN + ctx.config .order .size ();
11681170 }
@@ -1189,7 +1191,7 @@ void LinkerDriver::parseCallGraphFile(StringRef path) {
11891191 Symbol *sym = map.lookup (name);
11901192 if (!sym) {
11911193 if (ctx.config .warnMissingOrderSymbol )
1192- warn ( path + " : no such symbol: " + name) ;
1194+ Warn (ctx) << path << " : no such symbol: " << name;
11931195 return nullptr ;
11941196 }
11951197
@@ -1332,8 +1334,8 @@ void LinkerDriver::parsePDBAltPath() {
13321334 else if (var.equals_insensitive (" %_ext%" ))
13331335 buf.append (binaryExtension);
13341336 else {
1335- warn ( " only %_PDB% and %_EXT% supported in /pdbaltpath:, keeping " + var +
1336- " as literal" ) ;
1337+ Warn (ctx) << " only %_PDB% and %_EXT% supported in /pdbaltpath:, keeping "
1338+ << var << " as literal" ;
13371339 buf.append (var);
13381340 }
13391341
@@ -1691,7 +1693,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
16911693 addLibSearchPaths ();
16921694 } else {
16931695 if (args.hasArg (OPT_vctoolsdir, OPT_winsysroot))
1694- warn ( " ignoring /vctoolsdir or /winsysroot flags in MinGW mode" ) ;
1696+ Warn (ctx) << " ignoring /vctoolsdir or /winsysroot flags in MinGW mode" ;
16951697 }
16961698 }
16971699
@@ -1752,7 +1754,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
17521754 StringRef (str).split (vec, ' ,' );
17531755 for (StringRef s : vec) {
17541756 if (s == " fastlink" ) {
1755- warn ( " /debug:fastlink unsupported; using /debug:full" ) ;
1757+ Warn (ctx) << " /debug:fastlink unsupported; using /debug:full" ;
17561758 s = " full" ;
17571759 }
17581760 if (s == " none" ) {
@@ -1795,7 +1797,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
17951797 config->demangle = args.hasFlag (OPT_demangle, OPT_demangle_no, true );
17961798
17971799 // Handle /debugtype
1798- config->debugTypes = parseDebugTypes (args);
1800+ config->debugTypes = parseDebugTypes (ctx, args);
17991801
18001802 // Handle /driver[:uponly|:wdm].
18011803 config->driverUponly = args.hasArg (OPT_driver_uponly) ||
@@ -1832,7 +1834,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
18321834
18331835 // Handle /pdbstripped
18341836 if (args.hasArg (OPT_pdbstripped))
1835- warn ( " ignoring /pdbstripped flag, it is not yet supported" ) ;
1837+ Warn (ctx) << " ignoring /pdbstripped flag, it is not yet supported" ;
18361838
18371839 // Handle /noentry
18381840 if (args.hasArg (OPT_noentry)) {
@@ -2114,7 +2116,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
21142116 if (!isPowerOf2_64 (config->align ))
21152117 error (" /align: not a power of two: " + StringRef (arg->getValue ()));
21162118 if (!args.hasArg (OPT_driver))
2117- warn ( " /align specified without /driver; image may not run" ) ;
2119+ Warn (ctx) << " /align specified without /driver; image may not run" ;
21182120 }
21192121
21202122 // Handle /aligncomm
@@ -2199,27 +2201,29 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
21992201 OPT_lld_allow_duplicate_weak_no, config->mingw );
22002202
22012203 if (args.hasFlag (OPT_inferasanlibs, OPT_inferasanlibs_no, false ))
2202- warn ( " ignoring '/inferasanlibs', this flag is not supported" ) ;
2204+ Warn (ctx) << " ignoring '/inferasanlibs', this flag is not supported" ;
22032205
22042206 if (config->incremental && args.hasArg (OPT_profile)) {
2205- warn ( " ignoring '/incremental' due to '/profile' specification" ) ;
2207+ Warn (ctx) << " ignoring '/incremental' due to '/profile' specification" ;
22062208 config->incremental = false ;
22072209 }
22082210
22092211 if (config->incremental && args.hasArg (OPT_order)) {
2210- warn ( " ignoring '/incremental' due to '/order' specification" ) ;
2212+ Warn (ctx) << " ignoring '/incremental' due to '/order' specification" ;
22112213 config->incremental = false ;
22122214 }
22132215
22142216 if (config->incremental && config->doGC ) {
2215- warn (" ignoring '/incremental' because REF is enabled; use '/opt:noref' to "
2216- " disable" );
2217+ Warn (ctx) << " ignoring '/incremental' because REF is enabled; use "
2218+ " '/opt:noref' to "
2219+ " disable" ;
22172220 config->incremental = false ;
22182221 }
22192222
22202223 if (config->incremental && config->doICF != ICFLevel::None) {
2221- warn (" ignoring '/incremental' because ICF is enabled; use '/opt:noicf' to "
2222- " disable" );
2224+ Warn (ctx) << " ignoring '/incremental' because ICF is enabled; use "
2225+ " '/opt:noicf' to "
2226+ " disable" ;
22232227 config->incremental = false ;
22242228 }
22252229
@@ -2285,7 +2289,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
22852289 // We should have inferred a machine type by now from the input files, but if
22862290 // not we assume x64.
22872291 if (config->machine == IMAGE_FILE_MACHINE_UNKNOWN) {
2288- warn ( " /machine is not specified. x64 is assumed" ) ;
2292+ Warn (ctx) << " /machine is not specified. x64 is assumed" ;
22892293 config->machine = AMD64;
22902294 addWinSysRootLibSearchPaths ();
22912295 }
@@ -2460,8 +2464,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
24602464 }
24612465
24622466 if (config->lldmapFile != " " && config->lldmapFile == config->mapFile ) {
2463- warn ( " /lldmap and /map have the same output file '" + config-> mapFile +
2464- " '.\n >>> ignoring /lldmap" ) ;
2467+ Warn (ctx) << " /lldmap and /map have the same output file '"
2468+ << config-> mapFile << " '.\n >>> ignoring /lldmap" ;
24652469 config->lldmapFile .clear ();
24662470 }
24672471
@@ -2741,7 +2745,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
27412745
27422746 Symbol *sym = ctx.symtab .find (name);
27432747 if (!sym) {
2744- warn ( " /aligncomm symbol " + name + " not found" ) ;
2748+ Warn (ctx) << " /aligncomm symbol " << name << " not found" ;
27452749 continue ;
27462750 }
27472751
0 commit comments