r83391 was completely broken since Twines keep references to their inputs, and
authorJeffrey Yasskin <jyasskin@google.com>
Tue, 6 Oct 2009 21:45:26 +0000 (21:45 +0000)
committerJeffrey Yasskin <jyasskin@google.com>
Tue, 6 Oct 2009 21:45:26 +0000 (21:45 +0000)
some of the inputs were temporaries.  Here's a real fix for the miscompilation.
Thanks to sabre for pointing out the problem.

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

lib/Support/Triple.cpp

index 804769d04e978f33f65ed5c5051c8ef6474e3907..6f805da33299778a7e4abfebcd731ed8e34b67da 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "llvm/ADT/Triple.h"
 
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/Twine.h"
 #include <cassert>
 #include <cstring>
@@ -390,10 +391,14 @@ void Triple::setOS(OSType Kind) {
 }
 
 void Triple::setArchName(const StringRef &Str) {
-  // Work around a miscompilation bug in gcc 4.0.3.
-  Twine a = getVendorName() + "-" + getOSAndEnvironmentName();
-  Twine b = Str + "-" + a;
-  setTriple(b);
+  // Work around a miscompilation bug for Twines in gcc 4.0.3.
+  SmallString<64> Triple;
+  Triple += Str;
+  Triple += "-";
+  Triple += getVendorName();
+  Triple += "-";
+  Triple += getOSAndEnvironmentName();
+  setTriple(Triple.str());
 }
 
 void Triple::setVendorName(const StringRef &Str) {