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

Rafael Espindola rafael.espindola at gmail.com
Thu Dec 12 07:39:06 PST 2013


Author: rafael
Date: Thu Dec 12 09:39:05 2013
New Revision: 197157

URL: http://llvm.org/viewvc/llvm-project?rev=197157&view=rev
Log:
Don't return a pointer to a temporary std::string's c_str.

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

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=197157&r1=197156&r2=197157&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Dec 12 09:39:05 2013
@@ -4532,8 +4532,9 @@ const char *arm::getARMCPUForMArch(const
       : "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 A
     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);

Modified: cfe/trunk/lib/Driver/Tools.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=197157&r1=197156&r2=197157&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Thu Dec 12 09:39:05 2013
@@ -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);





More information about the cfe-commits mailing list