[LoopAccesses] Make raw_string_ostream local in VectorizationReport
authorAdam Nemet <anemet@apple.com>
Wed, 18 Feb 2015 03:42:15 +0000 (03:42 +0000)
committerAdam Nemet <anemet@apple.com>
Wed, 18 Feb 2015 03:42:15 +0000 (03:42 +0000)
Since VectorizationReport will be part of the result of the analysis it
will be stored in a container.  However, one of its members is a
raw_string_ostream which cannot be copy-constructed.

This makes the raw_string_ostream local to the << operator.

This is part of the patchset that converts LoopAccessAnalysis into an
actual analysis pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229620 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/LoopAccessAnalysis.h

index 909c47bd4c80332010cba8380c5264bb0e9cd360..f02b4fc37324dae665fd864e06d847ece60c74b7 100644 (file)
@@ -36,23 +36,22 @@ class SCEV;
 /// the user why vectorization did not occur.
 class VectorizationReport {
   std::string Message;
 /// the user why vectorization did not occur.
 class VectorizationReport {
   std::string Message;
-  raw_string_ostream Out;
   Instruction *Instr;
 
 public:
   Instruction *Instr;
 
 public:
-  VectorizationReport(Instruction *I = nullptr) : Out(Message), Instr(I) {
-    Out << "loop not vectorized: ";
-  }
+  VectorizationReport(Instruction *I = nullptr)
+      : Message("loop not vectorized: "), Instr(I) {}
 
   template <typename A> VectorizationReport &operator<<(const A &Value) {
 
   template <typename A> VectorizationReport &operator<<(const A &Value) {
+    raw_string_ostream Out(Message);
     Out << Value;
     return *this;
   }
 
   Instruction *getInstr() { return Instr; }
 
     Out << Value;
     return *this;
   }
 
   Instruction *getInstr() { return Instr; }
 
-  std::string &str() { return Out.str(); }
-  operator Twine() { return Out.str(); }
+  std::string &str() { return Message; }
+  operator Twine() { return Message; }
 
   /// \brief Emit an analysis note with the debug location from the instruction
   /// in \p Message if available.  Otherwise use the location of \p TheLoop.
 
   /// \brief Emit an analysis note with the debug location from the instruction
   /// in \p Message if available.  Otherwise use the location of \p TheLoop.