@@ -102,11 +102,8 @@ void SymbolTable::addFile(InputFile *file) {
102102 ctx.driver .parseDirectives (file);
103103}
104104
105- static void errorOrWarn (const Twine &s, bool forceUnresolved) {
106- if (forceUnresolved)
107- warn (s);
108- else
109- error (s);
105+ static COFFSyncStream errorOrWarn (COFFLinkerContext &ctx) {
106+ return {ctx, ctx.config .forceUnresolved ? DiagLevel::Warn : DiagLevel::Err};
110107}
111108
112109// Causes the file associated with a lazy symbol to be linked in.
@@ -273,7 +270,7 @@ struct UndefinedDiag {
273270 std::vector<File> files;
274271};
275272
276- static void reportUndefinedSymbol (const COFFLinkerContext &ctx,
273+ static void reportUndefinedSymbol (COFFLinkerContext &ctx,
277274 const UndefinedDiag &undefDiag) {
278275 std::string out;
279276 llvm::raw_string_ostream os (out);
@@ -293,7 +290,7 @@ static void reportUndefinedSymbol(const COFFLinkerContext &ctx,
293290 }
294291 if (numDisplayedRefs < numRefs)
295292 os << " \n >>> referenced " << numRefs - numDisplayedRefs << " more times" ;
296- errorOrWarn (out, ctx. config . forceUnresolved ) ;
293+ errorOrWarn (ctx) << out ;
297294}
298295
299296void SymbolTable::loadMinGWSymbols () {
@@ -425,8 +422,7 @@ static void reportProblemSymbols(
425422
426423 for (Symbol *b : ctx.config .gcroot ) {
427424 if (undefs.count (b))
428- errorOrWarn (" <root>: undefined symbol: " + toString (ctx, *b),
429- ctx.config .forceUnresolved );
425+ errorOrWarn (ctx) << " <root>: undefined symbol: " << toString (ctx, *b);
430426 if (localImports)
431427 if (Symbol *imp = localImports->lookup (b))
432428 Warn (ctx) << " <root>: locally defined symbol imported: "
0 commit comments