@@ -809,7 +809,7 @@ StringRef LinkerDriver::findDefaultEntry() {
809
809
if (findUnderscoreMangle (" wmain" )) {
810
810
if (!findUnderscoreMangle (" main" ))
811
811
return mangle (" wmainCRTStartup" );
812
- warn ( " found both wmain and main; using latter" ) ;
812
+ Warn (ctx) << " found both wmain and main; using latter" ;
813
813
}
814
814
return mangle (" mainCRTStartup" );
815
815
}
@@ -828,9 +828,9 @@ WindowsSubsystem LinkerDriver::inferSubsystem() {
828
828
bool haveWWinMain = findUnderscoreMangle (" wWinMain" );
829
829
if (haveMain || haveWMain) {
830
830
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" ;
834
834
}
835
835
return IMAGE_SUBSYSTEM_WINDOWS_CUI;
836
836
}
@@ -910,7 +910,8 @@ static std::string createResponseFile(const opt::InputArgList &args,
910
910
return std::string (data);
911
911
}
912
912
913
- static unsigned parseDebugTypes (const opt::InputArgList &args) {
913
+ static unsigned parseDebugTypes (COFFLinkerContext &ctx,
914
+ const opt::InputArgList &args) {
914
915
unsigned debugTypes = static_cast <unsigned >(DebugType::None);
915
916
916
917
if (auto *a = args.getLastArg (OPT_debugtype)) {
@@ -925,7 +926,7 @@ static unsigned parseDebugTypes(const opt::InputArgList &args) {
925
926
.Case (" fixup" , static_cast <unsigned >(DebugType::Fixup))
926
927
.Default (0 );
927
928
if (v == 0 ) {
928
- warn ( " /debugtype: unknown option '" + type + " '" ) ;
929
+ Warn (ctx) << " /debugtype: unknown option '" << type << " '" ;
929
930
continue ;
930
931
}
931
932
debugTypes |= v;
@@ -1162,7 +1163,8 @@ void LinkerDriver::parseOrderFile(StringRef arg) {
1162
1163
1163
1164
if (set.count (s) == 0 ) {
1164
1165
if (ctx.config .warnMissingOrderSymbol )
1165
- warn (" /order:" + arg + " : missing symbol: " + s + " [LNK4037]" );
1166
+ Warn (ctx) << " /order:" << arg << " : missing symbol: " << s
1167
+ << " [LNK4037]" ;
1166
1168
} else
1167
1169
ctx.config .order [s] = INT_MIN + ctx.config .order .size ();
1168
1170
}
@@ -1189,7 +1191,7 @@ void LinkerDriver::parseCallGraphFile(StringRef path) {
1189
1191
Symbol *sym = map.lookup (name);
1190
1192
if (!sym) {
1191
1193
if (ctx.config .warnMissingOrderSymbol )
1192
- warn ( path + " : no such symbol: " + name) ;
1194
+ Warn (ctx) << path << " : no such symbol: " << name;
1193
1195
return nullptr ;
1194
1196
}
1195
1197
@@ -1332,8 +1334,8 @@ void LinkerDriver::parsePDBAltPath() {
1332
1334
else if (var.equals_insensitive (" %_ext%" ))
1333
1335
buf.append (binaryExtension);
1334
1336
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" ;
1337
1339
buf.append (var);
1338
1340
}
1339
1341
@@ -1691,7 +1693,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
1691
1693
addLibSearchPaths ();
1692
1694
} else {
1693
1695
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" ;
1695
1697
}
1696
1698
}
1697
1699
@@ -1752,7 +1754,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
1752
1754
StringRef (str).split (vec, ' ,' );
1753
1755
for (StringRef s : vec) {
1754
1756
if (s == " fastlink" ) {
1755
- warn ( " /debug:fastlink unsupported; using /debug:full" ) ;
1757
+ Warn (ctx) << " /debug:fastlink unsupported; using /debug:full" ;
1756
1758
s = " full" ;
1757
1759
}
1758
1760
if (s == " none" ) {
@@ -1795,7 +1797,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
1795
1797
config->demangle = args.hasFlag (OPT_demangle, OPT_demangle_no, true );
1796
1798
1797
1799
// Handle /debugtype
1798
- config->debugTypes = parseDebugTypes (args);
1800
+ config->debugTypes = parseDebugTypes (ctx, args);
1799
1801
1800
1802
// Handle /driver[:uponly|:wdm].
1801
1803
config->driverUponly = args.hasArg (OPT_driver_uponly) ||
@@ -1832,7 +1834,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
1832
1834
1833
1835
// Handle /pdbstripped
1834
1836
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" ;
1836
1838
1837
1839
// Handle /noentry
1838
1840
if (args.hasArg (OPT_noentry)) {
@@ -2114,7 +2116,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
2114
2116
if (!isPowerOf2_64 (config->align ))
2115
2117
error (" /align: not a power of two: " + StringRef (arg->getValue ()));
2116
2118
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" ;
2118
2120
}
2119
2121
2120
2122
// Handle /aligncomm
@@ -2199,27 +2201,29 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
2199
2201
OPT_lld_allow_duplicate_weak_no, config->mingw );
2200
2202
2201
2203
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" ;
2203
2205
2204
2206
if (config->incremental && args.hasArg (OPT_profile)) {
2205
- warn ( " ignoring '/incremental' due to '/profile' specification" ) ;
2207
+ Warn (ctx) << " ignoring '/incremental' due to '/profile' specification" ;
2206
2208
config->incremental = false ;
2207
2209
}
2208
2210
2209
2211
if (config->incremental && args.hasArg (OPT_order)) {
2210
- warn ( " ignoring '/incremental' due to '/order' specification" ) ;
2212
+ Warn (ctx) << " ignoring '/incremental' due to '/order' specification" ;
2211
2213
config->incremental = false ;
2212
2214
}
2213
2215
2214
2216
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" ;
2217
2220
config->incremental = false ;
2218
2221
}
2219
2222
2220
2223
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" ;
2223
2227
config->incremental = false ;
2224
2228
}
2225
2229
@@ -2285,7 +2289,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
2285
2289
// We should have inferred a machine type by now from the input files, but if
2286
2290
// not we assume x64.
2287
2291
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" ;
2289
2293
config->machine = AMD64;
2290
2294
addWinSysRootLibSearchPaths ();
2291
2295
}
@@ -2460,8 +2464,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
2460
2464
}
2461
2465
2462
2466
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" ;
2465
2469
config->lldmapFile .clear ();
2466
2470
}
2467
2471
@@ -2741,7 +2745,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
2741
2745
2742
2746
Symbol *sym = ctx.symtab .find (name);
2743
2747
if (!sym) {
2744
- warn ( " /aligncomm symbol " + name + " not found" ) ;
2748
+ Warn (ctx) << " /aligncomm symbol " << name << " not found" ;
2745
2749
continue ;
2746
2750
}
2747
2751
0 commit comments