[cfe-commits] r72241 - /cfe/trunk/lib/Driver/Tools.cpp

Daniel Dunbar daniel at zuster.org
Thu May 21 19:21:06 PDT 2009


Author: ddunbar
Date: Thu May 21 21:21:04 2009
New Revision: 72241

URL: http://llvm.org/viewvc/llvm-project?rev=72241&view=rev
Log:
Don't rely on getArchName() to return a constant string reference.

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

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=72241&r1=72240&r2=72241&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu May 21 21:21:04 2009
@@ -642,24 +642,27 @@
   RenderExtraToolArgs(CmdArgs);
 
   // If using a driver driver, force the arch.
+  const std::string &Arch = getToolChain().getArchName();
   if (getToolChain().getHost().useDriverDriver()) {
     CmdArgs.push_back("-arch");
 
     // FIXME: Remove these special cases.
-    const char *Str = getToolChain().getArchName().c_str();
-    if (strcmp(Str, "powerpc") == 0)
-      Str = "ppc";
-    else if (strcmp(Str, "powerpc64") == 0)
-      Str = "ppc64";
-    CmdArgs.push_back(Str);
+    if (Arch == "powerpc")
+      CmdArgs.push_back("ppc");
+    else if (Arch == "powerpc64")
+      CmdArgs.push_back("ppc64");
+    else
+      CmdArgs.push_back(Args.MakeArgString(Arch.c_str()));
   }
 
   // Try to force gcc to match the tool chain we want, if we recognize
   // the arch.
-  const char *Str = getToolChain().getArchName().c_str();
-  if (strcmp(Str, "i386") == 0 || strcmp(Str, "powerpc") == 0)
+  //
+  // FIXME: The triple class should directly provide the information we want
+  // here.
+  if (Arch == "i386" || Arch == "powerpc")
     CmdArgs.push_back("-m32");
-  else if (strcmp(Str, "x86_64") == 0 || strcmp(Str, "powerpc64") == 0)
+  else if (Arch == "x86_64" || Arch == "powerpc64")
     CmdArgs.push_back("-m64");
 
   if (Output.isPipe()) {
@@ -1199,7 +1202,7 @@
 
   // Derived from asm spec.
   CmdArgs.push_back("-arch");
-  CmdArgs.push_back(getToolChain().getArchName().c_str());
+  CmdArgs.push_back(Args.MakeArgString(getToolChain().getArchName().c_str()));
 
   CmdArgs.push_back("-force_cpusubtype_ALL");
   if ((Args.hasArg(options::OPT_mkernel) ||
@@ -1276,7 +1279,7 @@
                                  ArgStringList &CmdArgs) const {
   // Derived from darwin_arch spec.
   CmdArgs.push_back("-arch");
-  CmdArgs.push_back(getToolChain().getArchName().c_str());
+  CmdArgs.push_back(Args.MakeArgString(getToolChain().getArchName().c_str()));
 }
 
 void darwin::Link::AddDarwinSubArch(const ArgList &Args,





More information about the cfe-commits mailing list