From 3fd1e9933f4bb621ab6706b598830ff125fefe50 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 25 Aug 2014 18:16:47 +0000 Subject: Modernize raw_fd_ostream's constructor a bit. Take a StringRef instead of a "const char *". Take a "std::error_code &" instead of a "std::string &" for error. A create static method would be even better, but this patch is already a bit too big. llvm-svn: 216393 --- llvm/lib/Analysis/CFGPrinter.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'llvm/lib/Analysis/CFGPrinter.cpp') diff --git a/llvm/lib/Analysis/CFGPrinter.cpp b/llvm/lib/Analysis/CFGPrinter.cpp index c2c19d6a69e..89787f826be 100644 --- a/llvm/lib/Analysis/CFGPrinter.cpp +++ b/llvm/lib/Analysis/CFGPrinter.cpp @@ -79,11 +79,11 @@ namespace { bool runOnFunction(Function &F) override { std::string Filename = "cfg." + F.getName().str() + ".dot"; errs() << "Writing '" << Filename << "'..."; - - std::string ErrorInfo; - raw_fd_ostream File(Filename.c_str(), ErrorInfo, sys::fs::F_Text); - if (ErrorInfo.empty()) + std::error_code EC; + raw_fd_ostream File(Filename, EC, sys::fs::F_Text); + + if (!EC) WriteGraph(File, (const Function*)&F); else errs() << " error opening file for writing!"; @@ -114,10 +114,10 @@ namespace { std::string Filename = "cfg." + F.getName().str() + ".dot"; errs() << "Writing '" << Filename << "'..."; - std::string ErrorInfo; - raw_fd_ostream File(Filename.c_str(), ErrorInfo, sys::fs::F_Text); - - if (ErrorInfo.empty()) + std::error_code EC; + raw_fd_ostream File(Filename, EC, sys::fs::F_Text); + + if (!EC) WriteGraph(File, (const Function*)&F, true); else errs() << " error opening file for writing!"; -- cgit v1.2.3