[NFC] Use llvm::raw_string_ostream instead of std::stringstream
authorserge-sans-paille <sguelton@redhat.com>
Fri, 12 Mar 2021 17:42:17 +0000 (18:42 +0100)
committerserge-sans-paille <sguelton@redhat.com>
Fri, 12 Mar 2021 17:43:59 +0000 (18:43 +0100)
That's more efficient and we don't loose any valuable feature when doing so.

llvm/lib/Analysis/InlineAdvisor.cpp

index 9a2276a..469ec4c 100644 (file)
@@ -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)