From cf18b7a6bd01bb10921250c2c0b0be91c4b12b26 Mon Sep 17 00:00:00 2001 From: Eric Schweitz Date: Mon, 11 Mar 2019 09:16:01 -0700 Subject: [PATCH] [flang] Fix build breakage Original-commit: flang-compiler/f18@72d003f89d523f84cfab6ed048897be6bcb7ed92 Reviewed-on: https://github.com/flang-compiler/f18/pull/323 --- flang/lib/FIR/graph-writer.cc | 8 +++++++- flang/lib/FIR/graph-writer.h | 12 ++++-------- flang/tools/f18/CMakeLists.txt | 1 + 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/flang/lib/FIR/graph-writer.cc b/flang/lib/FIR/graph-writer.cc index 013eb58..d96f11b7 100644 --- a/flang/lib/FIR/graph-writer.cc +++ b/flang/lib/FIR/graph-writer.cc @@ -16,7 +16,13 @@ namespace Fortran::FIR { -std::optional 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"; } diff --git a/flang/lib/FIR/graph-writer.h b/flang/lib/FIR/graph-writer.h index 14bea2a..812fb46 100644 --- a/flang/lib/FIR/graph-writer.h +++ b/flang/lib/FIR/graph-writer.h @@ -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 ®ion, 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 blockIds_; - static std::optional defaultOutput_; + static llvm::raw_ostream * defaultOutput_; }; } diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt index 343f3bc..e894bb2 100644 --- a/flang/tools/f18/CMakeLists.txt +++ b/flang/tools/f18/CMakeLists.txt @@ -21,5 +21,6 @@ target_link_libraries(f18 FortranParser FortranEvaluate FortranSemantics + FortranFIR ${LLVM_COMMON_LIBS} ) -- 2.7.4