// avoid intermittent crashes on Windows when exiting.
llvm_shutdown();
- lld::outs().flush();
- lld::errs().flush();
+ {
+ std::lock_guard<std::mutex> lock(mu);
+ lld::outs().flush();
+ lld::errs().flush();
+ }
_exit(val);
}
}
}
- std::lock_guard<std::mutex> lock(mu);
+ bool exit = false;
+ {
+ std::lock_guard<std::mutex> lock(mu);
+
+ if (errorLimit == 0 || errorCount < errorLimit) {
+ lld::errs() << sep << getLocation(msg) << ": " << Colors::RED
+ << "error: " << Colors::RESET << msg << "\n";
+ } else if (errorCount == errorLimit) {
+ lld::errs() << sep << getLocation(msg) << ": " << Colors::RED
+ << "error: " << Colors::RESET << errorLimitExceededMsg
+ << "\n";
+ exit = exitEarly;
+ }
- if (errorLimit == 0 || errorCount < errorLimit) {
- lld::errs() << sep << getLocation(msg) << ": " << Colors::RED
- << "error: " << Colors::RESET << msg << "\n";
- } else if (errorCount == errorLimit) {
- lld::errs() << sep << getLocation(msg) << ": " << Colors::RED
- << "error: " << Colors::RESET << errorLimitExceededMsg << "\n";
- if (exitEarly)
- exitLld(1);
+ sep = getSeparator(msg);
+ ++errorCount;
}
- sep = getSeparator(msg);
- ++errorCount;
+ if (exit)
+ exitLld(1);
}
void ErrorHandler::fatal(const Twine &msg) {