summaryrefslogtreecommitdiff
path: root/llvm/tools/yaml2obj/yaml2obj.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/yaml2obj/yaml2obj.cpp')
-rw-r--r--llvm/tools/yaml2obj/yaml2obj.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/tools/yaml2obj/yaml2obj.cpp b/llvm/tools/yaml2obj/yaml2obj.cpp
index 45aa3828311f..dcd6dfcd3de2 100644
--- a/llvm/tools/yaml2obj/yaml2obj.cpp
+++ b/llvm/tools/yaml2obj/yaml2obj.cpp
@@ -117,8 +117,9 @@ int main(int argc, char **argv) {
argc, argv, "Create an object file from a YAML description", nullptr,
nullptr, /*LongOptionsUseDoubleDash=*/true);
- auto ErrHandler = [](const Twine &Msg) {
- WithColor::error(errs(), "yaml2obj") << Msg << "\n";
+ constexpr StringRef ProgName = "yaml2obj";
+ auto ErrHandler = [&](const Twine &Msg) {
+ WithColor::error(errs(), ProgName) << Msg << "\n";
};
std::error_code EC;
@@ -131,8 +132,10 @@ int main(int argc, char **argv) {
ErrorOr<std::unique_ptr<MemoryBuffer>> Buf =
MemoryBuffer::getFileOrSTDIN(Input, /*IsText=*/true);
- if (!Buf)
+ if (std::error_code EC = Buf.getError()) {
+ WithColor::error(errs(), ProgName) << Input << ": " << EC.message() << '\n';
return 1;
+ }
std::optional<std::string> Buffer =
preprocess(Buf.get()->getBuffer(), ErrHandler);