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"; }
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);
return buffer.str();
}
static llvm::raw_ostream &getOutput() {
- return defaultOutput_ ? *defaultOutput_.value() : llvm::outs();
+ return defaultOutput_ ? *defaultOutput_ : llvm::outs();
}
unsigned count_{0u};
bool isEntry_{false};
bool isExit_{false};
std::map<BasicBlock *, unsigned> blockIds_;
- static std::optional<llvm::raw_ostream *> defaultOutput_;
+ static llvm::raw_ostream * defaultOutput_;
};
}