Skip to content

Commit dc6229b

Browse files
committed
[lld] Use context-aware outs() and errs()
1 parent 73bb022 commit dc6229b

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

lld/Common/ErrorHandler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,15 @@ void ErrorHandler::reportDiagnostic(StringRef location, Colors c,
215215
raw_svector_ostream os(buf);
216216
os << sep << location << ": ";
217217
if (!diagKind.empty()) {
218-
if (lld::errs().colors_enabled()) {
218+
if (errs().colors_enabled()) {
219219
os.enable_colors(true);
220220
os << c << diagKind << ": " << Colors::RESET;
221221
} else {
222222
os << diagKind << ": ";
223223
}
224224
}
225225
os << msg << '\n';
226-
lld::errs() << buf;
226+
errs() << buf;
227227
}
228228

229229
void ErrorHandler::log(const Twine &msg) {

lld/ELF/DriverUtils.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ static void handleColorDiagnostics(Ctx &ctx, opt::InputArgList &args) {
5858
return;
5959
StringRef s = arg->getValue();
6060
if (s == "always")
61-
lld::errs().enable_colors(true);
61+
ctx.errHandler->errs().enable_colors(true);
6262
else if (s == "never")
63-
lld::errs().enable_colors(false);
63+
ctx.errHandler->errs().enable_colors(false);
6464
else if (s != "auto")
6565
ErrAlways(ctx) << "unknown option: --color-diagnostics=" << s;
6666
}
@@ -139,16 +139,17 @@ opt::InputArgList ELFOptTable::parse(Ctx &ctx, ArrayRef<const char *> argv) {
139139
}
140140

141141
void elf::printHelp(Ctx &ctx) {
142+
auto &outs = ctx.errHandler->outs();
142143
ELFOptTable().printHelp(
143-
lld::outs(), (ctx.arg.progName + " [options] file...").str().c_str(),
144-
"lld", false /*ShowHidden*/, true /*ShowAllAliases*/);
145-
lld::outs() << "\n";
144+
outs, (ctx.arg.progName + " [options] file...").str().c_str(), "lld",
145+
false /*ShowHidden*/, true /*ShowAllAliases*/);
146+
outs << "\n";
146147

147148
// Scripts generated by Libtool versions up to 2021-10 expect /: supported
148149
// targets:.* elf/ in a message for the --help option. If it doesn't match,
149150
// the scripts assume that the linker doesn't support very basic features
150151
// such as shared libraries. Therefore, we need to print out at least "elf".
151-
lld::outs() << ctx.arg.progName << ": supported targets: elf\n";
152+
outs << ctx.arg.progName << ": supported targets: elf\n";
152153
}
153154

154155
static std::string rewritePath(StringRef s) {

lld/ELF/Writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ template <class ELFT> void Writer<ELFT>::run() {
342342

343343
// Handle --print-memory-usage option.
344344
if (ctx.arg.printMemoryUsage)
345-
ctx.script->printMemoryUsage(lld::outs());
345+
ctx.script->printMemoryUsage(ctx.errHandler->outs());
346346

347347
if (ctx.arg.checkSections)
348348
checkSections();

0 commit comments

Comments
 (0)