r213265 - Using a std::string instead of a StringRef because the Default case synthesizes a temporary std::string from a Twine. Assigning that into a StringRef causes the StringRef to refer to a temporary, and bad things happen.

Aaron Ballman aaron at aaronballman.com
Thu Jul 17 06:28:50 PDT 2014


Author: aaronballman
Date: Thu Jul 17 08:28:50 2014
New Revision: 213265

URL: http://llvm.org/viewvc/llvm-project?rev=213265&view=rev
Log:
Using a std::string instead of a StringRef because the Default case synthesizes a temporary std::string from a Twine. Assigning that into a StringRef causes the StringRef to refer to a temporary, and bad things happen.

This fixes a failing test case on Windows.

Modified:
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=213265&r1=213264&r2=213265&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Jul 17 08:28:50 2014
@@ -1037,12 +1037,12 @@ static void getMIPSTargetFeatures(const
   ABIName = getGnuCompatibleMipsABIName(ABIName);
 
   // Always override the backend's default ABI.
-  StringRef ABIFeature = llvm::StringSwitch<StringRef>(ABIName)
-                              .Case("32", "+o32")
-                              .Case("n32", "+n32")
-                              .Case("64", "+n64")
-                              .Case("eabi", "+eabi")
-                              .Default(("+" + ABIName).str());
+  std::string ABIFeature = llvm::StringSwitch<StringRef>(ABIName)
+                               .Case("32", "+o32")
+                               .Case("n32", "+n32")
+                               .Case("64", "+n64")
+                               .Case("eabi", "+eabi")
+                               .Default(("+" + ABIName).str());
   Features.push_back("-o32");
   Features.push_back("-n64");
   Features.push_back(Args.MakeArgString(ABIFeature));





More information about the cfe-commits mailing list