r241299 - [CodeGen] Use llvm::join to simplify string joining.

Benjamin Kramer benny.kra at googlemail.com
Thu Jul 2 14:02:39 PDT 2015


Author: d0k
Date: Thu Jul  2 16:02:39 2015
New Revision: 241299

URL: http://llvm.org/viewvc/llvm-project?rev=241299&view=rev
Log:
[CodeGen] Use llvm::join to simplify string joining.

While there replace stable_sort of std::string with just sort, stability
is not necessary for "simple" value types. No functional change intended.

Modified:
    cfe/trunk/lib/CodeGen/CGCall.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=241299&r1=241298&r2=241299&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Jul  2 16:02:39 2015
@@ -32,7 +32,6 @@
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/Transforms/Utils/Local.h"
-#include <sstream>
 using namespace clang;
 using namespace CodeGen;
 
@@ -1544,14 +1543,9 @@ void CodeGenModule::ConstructAttributeLi
     if (TargetCPU != "")
       FuncAttrs.addAttribute("target-cpu", TargetCPU);
     if (!Features.empty()) {
-      std::stable_sort(Features.begin(), Features.end());
-      std::stringstream TargetFeatures;
-      std::copy(Features.begin(), Features.end(),
-                std::ostream_iterator<std::string>(TargetFeatures, ","));
-
-      // The drop_back gets rid of the trailing space.
+      std::sort(Features.begin(), Features.end());
       FuncAttrs.addAttribute("target-features",
-                             StringRef(TargetFeatures.str()).drop_back(1));
+                             llvm::join(Features.begin(), Features.end(), ","));
     }
   }
 





More information about the cfe-commits mailing list