[flang] Fix build breakage
authorEric Schweitz <eschweitz@nvidia.com>
Mon, 11 Mar 2019 16:16:01 +0000 (09:16 -0700)
committerEric Schweitz <eschweitz@nvidia.com>
Mon, 11 Mar 2019 16:16:01 +0000 (09:16 -0700)
Original-commit: flang-compiler/f18@72d003f89d523f84cfab6ed048897be6bcb7ed92
Reviewed-on: https://github.com/flang-compiler/f18/pull/323

flang/lib/FIR/graph-writer.cc
flang/lib/FIR/graph-writer.h
flang/tools/f18/CMakeLists.txt

index 013eb58..d96f11b 100644 (file)
 
 namespace Fortran::FIR {
 
-std::optional<llvm::raw_ostream *> GraphWriter::defaultOutput_{std::nullopt};
+llvm::raw_ostream *GraphWriter::defaultOutput_;
+
+GraphWriter::~GraphWriter() {
+  if (defaultOutput_) {
+    defaultOutput_->flush();
+  }
+}
 
 void GraphWriter::dumpHeader() { output_ << "digraph G {\n"; }
 void GraphWriter::dumpFooter() { output_ << "}\n"; }
index 14bea2a..812fb46 100644 (file)
@@ -49,12 +49,8 @@ public:
 
 private:
   GraphWriter(llvm::raw_ostream &output) : output_{output} {}
-  ~GraphWriter() {
-    if (defaultOutput_) {
-      delete *defaultOutput_;
-      defaultOutput_ = std::nullopt;
-    }
-  }
+  ~GraphWriter();
+
   void dump(Program &program);
   void dump(Procedure &procedure, bool box = false);
   void dump(Region &region, bool box = false);
@@ -77,7 +73,7 @@ private:
     return buffer.str();
   }
   static llvm::raw_ostream &getOutput() {
-    return defaultOutput_ ? *defaultOutput_.value() : llvm::outs();
+    return defaultOutput_ ? *defaultOutput_ : llvm::outs();
   }
 
   unsigned count_{0u};
@@ -86,7 +82,7 @@ private:
   bool isEntry_{false};
   bool isExit_{false};
   std::map<BasicBlock *, unsigned> blockIds_;
-  static std::optional<llvm::raw_ostream *> defaultOutput_;
+  static llvm::raw_ostream * defaultOutput_;
 };
 }
 
index 343f3bc..e894bb2 100644 (file)
@@ -21,5 +21,6 @@ target_link_libraries(f18
   FortranParser
   FortranEvaluate
   FortranSemantics
+  FortranFIR
   ${LLVM_COMMON_LIBS}
 )