]> granicus.if.org Git - clang/commitdiff
Use StringRef instead of returning a temporary std::string.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 30 Jan 2010 15:01:47 +0000 (15:01 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 30 Jan 2010 15:01:47 +0000 (15:01 +0000)
This fixes a really nasty bug in Darwin::getDarwinArchName where we were going
StringRef -> temporary std::string -> StringRef (and return the dead StringRef).
The StringRefs from Triple live as long as the Triple itself, that should be
long enough.

Hopefully 2 of 4 MSVC buildbot failures are gone now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94892 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/ToolChain.h
lib/Driver/Tools.cpp

index cc8d438db3e9657ab32ec35464d68a20308496b5..501e833202b15fe6b67a7168e043eb7adbf66f7d 100644 (file)
@@ -53,9 +53,9 @@ public:
   const Driver &getDriver() const;
   const llvm::Triple &getTriple() const { return Triple; }
 
-  std::string getArchName() const { return Triple.getArchName(); }
-  std::string getPlatform() const { return Triple.getVendorName(); }
-  std::string getOS() const { return Triple.getOSName(); }
+  llvm::StringRef getArchName() const { return Triple.getArchName(); }
+  llvm::StringRef getPlatform() const { return Triple.getVendorName(); }
+  llvm::StringRef getOS() const { return Triple.getOSName(); }
 
   std::string getTripleString() const {
     return Triple.getTriple();
index 2e7435fa32a5e581515852abe2c58e5cf0768359..2354bd494e6649237757b8a576c7e9e7a1099c42 100644 (file)
@@ -512,7 +512,7 @@ void Clang::AddX86TargetArgs(const ArgList &Args,
   // Select the default CPU if none was given (or detection failed).
   if (!CPUName) {
     // FIXME: Need target hooks.
-    if (memcmp(getToolChain().getOS().c_str(), "darwin", 6) == 0) {
+    if (getToolChain().getOS().startswith("darwin")) {
       if (getToolChain().getArchName() == "x86_64")
         CPUName = "core2";
       else if (getToolChain().getArchName() == "i386")