Don't return a pointer to a temporary std::string's c_str.

llvm-svn: 197157
This commit is contained in:
Rafael Espindola 2013-12-12 15:39:05 +00:00
parent 86d8fb5ba1
commit 9c5ef12d66
2 changed files with 5 additions and 4 deletions

View File

@ -4532,8 +4532,9 @@ const char *arm::getARMCPUForMArch(const ArgList &Args,
: "arm7tdmi"; : "arm7tdmi";
} }
/// FIXME: this should return a stringref once getHostCPUName return one.
/// getARMTargetCPU - Get the (LLVM) name of the ARM cpu we are targeting. /// 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) { const llvm::Triple &Triple) {
// FIXME: Warn on inconsistent use of -mcpu and -march. // FIXME: Warn on inconsistent use of -mcpu and -march.
// If we have -mcpu=, use that. // If we have -mcpu=, use that.
@ -4541,9 +4542,9 @@ const char *arm::getARMTargetCPU(const ArgList &Args,
StringRef MCPU = A->getValue(); StringRef MCPU = A->getValue();
// Handle -mcpu=native. // Handle -mcpu=native.
if (MCPU == "native") if (MCPU == "native")
return llvm::sys::getHostCPUName().c_str(); return llvm::sys::getHostCPUName();
else else
return MCPU.str().c_str(); return MCPU.str();
} }
return getARMCPUForMArch(Args, Triple); return getARMCPUForMArch(Args, Triple);

View File

@ -202,7 +202,7 @@ namespace hexagon {
} // end namespace hexagon. } // end namespace hexagon.
namespace arm { namespace arm {
const char* getARMTargetCPU(const llvm::opt::ArgList &Args, std::string getARMTargetCPU(const llvm::opt::ArgList &Args,
const llvm::Triple &Triple); const llvm::Triple &Triple);
const char* getARMCPUForMArch(const llvm::opt::ArgList &Args, const char* getARMCPUForMArch(const llvm::opt::ArgList &Args,
const llvm::Triple &Triple); const llvm::Triple &Triple);