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

Benjamin Kramer benny.kra at googlemail.com
Mon Nov 7 08:02:25 PST 2011


Author: d0k
Date: Mon Nov  7 10:02:25 2011
New Revision: 143962

URL: http://llvm.org/viewvc/llvm-project?rev=143962&view=rev
Log:
Fix an unsafe use of Twine.

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=143962&r1=143961&r2=143962&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Nov  7 10:02:25 2011
@@ -157,15 +157,14 @@
   // the link line. We cannot do the same thing because unlike gcov there is a
   // libprofile_rt.so. We used to use the -l:libprofile_rt.a syntax, but that is
   // not supported by old linkers.
-  Twine ProfileRT =
-    Twine(TC.getDriver().Dir) + "/../lib/" + "libprofile_rt.a";
+  std::string ProfileRT =
+    std::string(TC.getDriver().Dir) + "/../lib/libprofile_rt.a";
 
   if (Triple.isOSDarwin()) {
     // On Darwin, if the static library doesn't exist try the dylib.
     bool Exists;
-    if (llvm::sys::fs::exists(ProfileRT.str(), Exists) || !Exists)
-      ProfileRT =
-        Twine(TC.getDriver().Dir) + "/../lib/" + "libprofile_rt.dylib";
+    if (llvm::sys::fs::exists(ProfileRT, Exists) || !Exists)
+      ProfileRT.replace(ProfileRT.size() - 1, 1, "dylib");
   }
 
   CmdArgs.push_back(Args.MakeArgString(ProfileRT));





More information about the cfe-commits mailing list