Don't return a pointer to a temporary std::string's c_str.
llvm-svn: 197157
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 74cd393..99f62fa 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -4532,8 +4532,9 @@
: "arm7tdmi";
}
+/// FIXME: this should return a stringref once getHostCPUName return one.
/// getARMTargetCPU - Get the (LLVM) name of the ARM cpu we are targeting.
-const char *arm::getARMTargetCPU(const ArgList &Args,
+std::string arm::getARMTargetCPU(const ArgList &Args,
const llvm::Triple &Triple) {
// FIXME: Warn on inconsistent use of -mcpu and -march.
// If we have -mcpu=, use that.
@@ -4541,9 +4542,9 @@
StringRef MCPU = A->getValue();
// Handle -mcpu=native.
if (MCPU == "native")
- return llvm::sys::getHostCPUName().c_str();
+ return llvm::sys::getHostCPUName();
else
- return MCPU.str().c_str();
+ return MCPU.str();
}
return getARMCPUForMArch(Args, Triple);