]> granicus.if.org Git - clang/commitdiff
Don't return a pointer to a temporary std::string's c_str.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 12 Dec 2013 15:39:05 +0000 (15:39 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 12 Dec 2013 15:39:05 +0000 (15:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197157 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
lib/Driver/Tools.h

index 74cd393775207af5c6ba1254ed6d28a8b61695f6..99f62fa3c0be82c420d897c3d9cfae11e57d2227 100644 (file)
@@ -4532,8 +4532,9 @@ const char *arm::getARMCPUForMArch(const ArgList &Args,
       : "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 @@ const char *arm::getARMTargetCPU(const ArgList &Args,
     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);
index 562352f035c46e3814a1608c1e8de40f83e6e653..c6da145ce3750e7f4b3b5f7154e4f3a49b651b93 100644 (file)
@@ -202,7 +202,7 @@ namespace hexagon {
 } // end namespace hexagon.
 
 namespace arm {
-  const char* getARMTargetCPU(const llvm::opt::ArgList &Args,
+  std::string getARMTargetCPU(const llvm::opt::ArgList &Args,
                               const llvm::Triple &Triple);
   const char* getARMCPUForMArch(const llvm::opt::ArgList &Args,
                                 const llvm::Triple &Triple);