[cfe-commits] r94892 - in /cfe/trunk: include/clang/Driver/ToolChain.h lib/Driver/Tools.cpp
Benjamin Kramer
benny.kra at googlemail.com
Sat Jan 30 07:01:47 PST 2010
Author: d0k
Date: Sat Jan 30 09:01:47 2010
New Revision: 94892
URL: http://llvm.org/viewvc/llvm-project?rev=94892&view=rev
Log:
Use StringRef instead of returning a temporary std::string.
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.
Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=94892&r1=94891&r2=94892&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Sat Jan 30 09:01:47 2010
@@ -53,9 +53,9 @@
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();
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=94892&r1=94891&r2=94892&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sat Jan 30 09:01:47 2010
@@ -512,7 +512,7 @@
// 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")
More information about the cfe-commits
mailing list