[llvm] 1ce2b58 - [NFC] Use llvm::raw_string_ostream instead of std::stringstream

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 12 09:44:12 PST 2021


Author: serge-sans-paille
Date: 2021-03-12T18:43:59+01:00
New Revision: 1ce2b584543a6ae350d976ec3db667e7265ee3fe

URL: https://github.com/llvm/llvm-project/commit/1ce2b584543a6ae350d976ec3db667e7265ee3fe
DIFF: https://github.com/llvm/llvm-project/commit/1ce2b584543a6ae350d976ec3db667e7265ee3fe.diff

LOG: [NFC] Use llvm::raw_string_ostream instead of std::stringstream

That's more efficient and we don't loose any valuable feature when doing so.

Added: 
    

Modified: 
    llvm/lib/Analysis/InlineAdvisor.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InlineAdvisor.cpp b/llvm/lib/Analysis/InlineAdvisor.cpp
index 9a2276a16132..469ec4c1d57c 100644
--- a/llvm/lib/Analysis/InlineAdvisor.cpp
+++ b/llvm/lib/Analysis/InlineAdvisor.cpp
@@ -24,8 +24,6 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/raw_ostream.h"
 
-#include <sstream>
-
 using namespace llvm;
 #define DEBUG_TYPE "inline"
 
@@ -279,8 +277,7 @@ shouldBeDeferred(Function *Caller, InlineCost IC, int &TotalSecondaryCost,
 }
 
 namespace llvm {
-static std::basic_ostream<char> &operator<<(std::basic_ostream<char> &R,
-                                            const ore::NV &Arg) {
+static raw_ostream &operator<<(raw_ostream &R, const ore::NV &Arg) {
   return R << Arg.Val;
 }
 
@@ -302,7 +299,8 @@ RemarkT &operator<<(RemarkT &&R, const InlineCost &IC) {
 } // namespace llvm
 
 std::string llvm::inlineCostStr(const InlineCost &IC) {
-  std::stringstream Remark;
+  std::string Buffer;
+  raw_string_ostream Remark(Buffer);
   Remark << IC;
   return Remark.str();
 }
@@ -383,7 +381,8 @@ llvm::shouldInline(CallBase &CB,
 }
 
 std::string llvm::getCallSiteLocation(DebugLoc DLoc) {
-  std::ostringstream CallSiteLoc;
+  std::string Buffer;
+  raw_string_ostream CallSiteLoc(Buffer);
   bool First = true;
   for (DILocation *DIL = DLoc.get(); DIL; DIL = DIL->getInlinedAt()) {
     if (!First)


        


More information about the llvm-commits mailing list