From 2f1c212e8837a9602f6bc6a96ca32bddafd3a4ec Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 15 Apr 2020 14:26:31 -0700 Subject: [PATCH] PR45561: Return a literal string rather than an error string to avoid returning reference to local Changing the underlying YAML support to allow returning a literal string, rather than a StringRef, would probably be a bigger refactor so I didn't do that. --- llvm/lib/TextAPI/MachO/TextStub.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llvm/lib/TextAPI/MachO/TextStub.cpp b/llvm/lib/TextAPI/MachO/TextStub.cpp index 57e3318..db6762f 100644 --- a/llvm/lib/TextAPI/MachO/TextStub.cpp +++ b/llvm/lib/TextAPI/MachO/TextStub.cpp @@ -412,8 +412,10 @@ template <> struct ScalarTraits { static StringRef input(StringRef Scalar, void *, Target &Value) { auto Result = Target::create(Scalar); - if (!Result) - return toString(Result.takeError()); + if (!Result) { + consumeError(Result.takeError()); + return "unparsable target"; + } Value = *Result; if (Value.Arch == AK_unknown) -- 2.7.4