[llvm] 2f1c212 - PR45561: Return a literal string rather than an error string to avoid returning reference to local

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 14:28:03 PDT 2020


Author: David Blaikie
Date: 2020-04-15T14:27:29-07:00
New Revision: 2f1c212e8837a9602f6bc6a96ca32bddafd3a4ec

URL: https://github.com/llvm/llvm-project/commit/2f1c212e8837a9602f6bc6a96ca32bddafd3a4ec
DIFF: https://github.com/llvm/llvm-project/commit/2f1c212e8837a9602f6bc6a96ca32bddafd3a4ec.diff

LOG: 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.

Added: 
    

Modified: 
    llvm/lib/TextAPI/MachO/TextStub.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/TextAPI/MachO/TextStub.cpp b/llvm/lib/TextAPI/MachO/TextStub.cpp
index 57e3318f99d8..db6762f9554d 100644
--- a/llvm/lib/TextAPI/MachO/TextStub.cpp
+++ b/llvm/lib/TextAPI/MachO/TextStub.cpp
@@ -412,8 +412,10 @@ template <> struct ScalarTraits<Target> {
 
   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)


        


More information about the llvm-commits mailing list