[lld] Use context-aware outs() and errs()
This commit is contained in:
parent
73bb022b46
commit
dc6229bd66
@ -215,7 +215,7 @@ void ErrorHandler::reportDiagnostic(StringRef location, Colors c,
|
||||
raw_svector_ostream os(buf);
|
||||
os << sep << location << ": ";
|
||||
if (!diagKind.empty()) {
|
||||
if (lld::errs().colors_enabled()) {
|
||||
if (errs().colors_enabled()) {
|
||||
os.enable_colors(true);
|
||||
os << c << diagKind << ": " << Colors::RESET;
|
||||
} else {
|
||||
@ -223,7 +223,7 @@ void ErrorHandler::reportDiagnostic(StringRef location, Colors c,
|
||||
}
|
||||
}
|
||||
os << msg << '\n';
|
||||
lld::errs() << buf;
|
||||
errs() << buf;
|
||||
}
|
||||
|
||||
void ErrorHandler::log(const Twine &msg) {
|
||||
|
@ -58,9 +58,9 @@ static void handleColorDiagnostics(Ctx &ctx, opt::InputArgList &args) {
|
||||
return;
|
||||
StringRef s = arg->getValue();
|
||||
if (s == "always")
|
||||
lld::errs().enable_colors(true);
|
||||
ctx.errHandler->errs().enable_colors(true);
|
||||
else if (s == "never")
|
||||
lld::errs().enable_colors(false);
|
||||
ctx.errHandler->errs().enable_colors(false);
|
||||
else if (s != "auto")
|
||||
ErrAlways(ctx) << "unknown option: --color-diagnostics=" << s;
|
||||
}
|
||||
@ -139,16 +139,17 @@ opt::InputArgList ELFOptTable::parse(Ctx &ctx, ArrayRef<const char *> argv) {
|
||||
}
|
||||
|
||||
void elf::printHelp(Ctx &ctx) {
|
||||
auto &outs = ctx.errHandler->outs();
|
||||
ELFOptTable().printHelp(
|
||||
lld::outs(), (ctx.arg.progName + " [options] file...").str().c_str(),
|
||||
"lld", false /*ShowHidden*/, true /*ShowAllAliases*/);
|
||||
lld::outs() << "\n";
|
||||
outs, (ctx.arg.progName + " [options] file...").str().c_str(), "lld",
|
||||
false /*ShowHidden*/, true /*ShowAllAliases*/);
|
||||
outs << "\n";
|
||||
|
||||
// Scripts generated by Libtool versions up to 2021-10 expect /: supported
|
||||
// targets:.* elf/ in a message for the --help option. If it doesn't match,
|
||||
// the scripts assume that the linker doesn't support very basic features
|
||||
// such as shared libraries. Therefore, we need to print out at least "elf".
|
||||
lld::outs() << ctx.arg.progName << ": supported targets: elf\n";
|
||||
outs << ctx.arg.progName << ": supported targets: elf\n";
|
||||
}
|
||||
|
||||
static std::string rewritePath(StringRef s) {
|
||||
|
@ -342,7 +342,7 @@ template <class ELFT> void Writer<ELFT>::run() {
|
||||
|
||||
// Handle --print-memory-usage option.
|
||||
if (ctx.arg.printMemoryUsage)
|
||||
ctx.script->printMemoryUsage(lld::outs());
|
||||
ctx.script->printMemoryUsage(ctx.errHandler->outs());
|
||||
|
||||
if (ctx.arg.checkSections)
|
||||
checkSections();
|
||||
|
Loading…
x
Reference in New Issue
Block a user