diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-02-24 18:20:12 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-02-24 18:20:12 +0000 |
commit | ac69459e0fe3df04788f5adcb94b1bec8b8cf8ad (patch) | |
tree | 6260ace05d8d32042f39b42aead973d7c3ebaf9a /lib | |
parent | 137342f198093f68e112cd979782fae27bbb22ab (diff) | |
download | llvm-ac69459e0fe3df04788f5adcb94b1bec8b8cf8ad.tar.gz llvm-ac69459e0fe3df04788f5adcb94b1bec8b8cf8ad.tar.bz2 llvm-ac69459e0fe3df04788f5adcb94b1bec8b8cf8ad.tar.xz |
Replace the F_Binary flag with a F_Text one.
After this I will set the default back to F_None. The advantage is that
before this patch forgetting to set F_Binary would corrupt a file on windows.
Forgetting to set F_Text produces one that cannot be read in notepad, which
is a better failure mode :-)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202052 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/CFGPrinter.cpp | 4 | ||||
-rw-r--r-- | lib/Bitcode/Writer/BitWriter.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/MachineVerifier.cpp | 3 | ||||
-rw-r--r-- | lib/CodeGen/RegAllocPBQP.cpp | 2 | ||||
-rw-r--r-- | lib/IR/Core.cpp | 2 | ||||
-rw-r--r-- | lib/IR/GCOV.cpp | 2 | ||||
-rw-r--r-- | lib/LTO/LTOCodeGenerator.cpp | 2 | ||||
-rw-r--r-- | lib/MC/MCParser/DarwinAsmParser.cpp | 3 | ||||
-rw-r--r-- | lib/Support/Path.cpp | 6 | ||||
-rw-r--r-- | lib/Support/Timer.cpp | 4 | ||||
-rw-r--r-- | lib/Support/Windows/Path.inc | 2 | ||||
-rw-r--r-- | lib/Support/raw_ostream.cpp | 2 | ||||
-rw-r--r-- | lib/TableGen/Main.cpp | 4 | ||||
-rw-r--r-- | lib/Target/TargetMachineC.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Instrumentation/DebugIR.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Instrumentation/GCOVProfiling.cpp | 2 |
16 files changed, 23 insertions, 21 deletions
diff --git a/lib/Analysis/CFGPrinter.cpp b/lib/Analysis/CFGPrinter.cpp index 3c67618450..3f768ce780 100644 --- a/lib/Analysis/CFGPrinter.cpp +++ b/lib/Analysis/CFGPrinter.cpp @@ -80,7 +80,7 @@ namespace { errs() << "Writing '" << Filename << "'..."; std::string ErrorInfo; - raw_fd_ostream File(Filename.c_str(), ErrorInfo, sys::fs::F_None); + raw_fd_ostream File(Filename.c_str(), ErrorInfo, sys::fs::F_Text); if (ErrorInfo.empty()) WriteGraph(File, (const Function*)&F); @@ -114,7 +114,7 @@ namespace { errs() << "Writing '" << Filename << "'..."; std::string ErrorInfo; - raw_fd_ostream File(Filename.c_str(), ErrorInfo, sys::fs::F_None); + raw_fd_ostream File(Filename.c_str(), ErrorInfo, sys::fs::F_Text); if (ErrorInfo.empty()) WriteGraph(File, (const Function*)&F, true); diff --git a/lib/Bitcode/Writer/BitWriter.cpp b/lib/Bitcode/Writer/BitWriter.cpp index cd1ada22cf..0275f96fc9 100644 --- a/lib/Bitcode/Writer/BitWriter.cpp +++ b/lib/Bitcode/Writer/BitWriter.cpp @@ -18,7 +18,7 @@ using namespace llvm; int LLVMWriteBitcodeToFile(LLVMModuleRef M, const char *Path) { std::string ErrorInfo; - raw_fd_ostream OS(Path, ErrorInfo, sys::fs::F_Binary); + raw_fd_ostream OS(Path, ErrorInfo, sys::fs::F_None); if (!ErrorInfo.empty()) return -1; diff --git a/lib/CodeGen/MachineVerifier.cpp b/lib/CodeGen/MachineVerifier.cpp index d61470c173..aa89b83e72 100644 --- a/lib/CodeGen/MachineVerifier.cpp +++ b/lib/CodeGen/MachineVerifier.cpp @@ -276,7 +276,8 @@ bool MachineVerifier::runOnMachineFunction(MachineFunction &MF) { raw_ostream *OutFile = 0; if (OutFileName) { std::string ErrorInfo; - OutFile = new raw_fd_ostream(OutFileName, ErrorInfo, sys::fs::F_Append); + OutFile = new raw_fd_ostream(OutFileName, ErrorInfo, + sys::fs::F_Append | sys::fs::F_Text); if (!ErrorInfo.empty()) { errs() << "Error opening '" << OutFileName << "': " << ErrorInfo << '\n'; exit(1); diff --git a/lib/CodeGen/RegAllocPBQP.cpp b/lib/CodeGen/RegAllocPBQP.cpp index 56fdb45f4e..347329591b 100644 --- a/lib/CodeGen/RegAllocPBQP.cpp +++ b/lib/CodeGen/RegAllocPBQP.cpp @@ -595,7 +595,7 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) { rs << round; std::string graphFileName(fqn + "." + rs.str() + ".pbqpgraph"); std::string tmp; - raw_fd_ostream os(graphFileName.c_str(), tmp, sys::fs::F_None); + raw_fd_ostream os(graphFileName.c_str(), tmp, sys::fs::F_Text); DEBUG(dbgs() << "Dumping graph for round " << round << " to \"" << graphFileName << "\"\n"); problem->getGraph().dump(os); diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index dbaf02edf6..68bc5c5810 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -130,7 +130,7 @@ void LLVMDumpModule(LLVMModuleRef M) { LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, char **ErrorMessage) { std::string error; - raw_fd_ostream dest(Filename, error, sys::fs::F_None); + raw_fd_ostream dest(Filename, error, sys::fs::F_Text); if (!error.empty()) { *ErrorMessage = strdup(error.c_str()); return true; diff --git a/lib/IR/GCOV.cpp b/lib/IR/GCOV.cpp index 3311d2ef42..a0591fffb9 100644 --- a/lib/IR/GCOV.cpp +++ b/lib/IR/GCOV.cpp @@ -482,7 +482,7 @@ void FileInfo::print(StringRef GCNOFile, StringRef GCDAFile) { std::string CoveragePath = mangleCoveragePath(Filename, Options.PreservePaths); std::string ErrorInfo; - raw_fd_ostream OS(CoveragePath.c_str(), ErrorInfo, sys::fs::F_None); + raw_fd_ostream OS(CoveragePath.c_str(), ErrorInfo, sys::fs::F_Text); if (!ErrorInfo.empty()) errs() << ErrorInfo << "\n"; diff --git a/lib/LTO/LTOCodeGenerator.cpp b/lib/LTO/LTOCodeGenerator.cpp index 2b37802efc..fb272ad513 100644 --- a/lib/LTO/LTOCodeGenerator.cpp +++ b/lib/LTO/LTOCodeGenerator.cpp @@ -191,7 +191,7 @@ bool LTOCodeGenerator::writeMergedModules(const char *path, // create output file std::string ErrInfo; - tool_output_file Out(path, ErrInfo, sys::fs::F_Binary); + tool_output_file Out(path, ErrInfo, sys::fs::F_None); if (!ErrInfo.empty()) { errMsg = "could not open bitcode file for writing: "; errMsg += path; diff --git a/lib/MC/MCParser/DarwinAsmParser.cpp b/lib/MC/MCParser/DarwinAsmParser.cpp index 6d66e308e8..39399c0865 100644 --- a/lib/MC/MCParser/DarwinAsmParser.cpp +++ b/lib/MC/MCParser/DarwinAsmParser.cpp @@ -634,7 +634,8 @@ bool DarwinAsmParser::ParseDirectiveSecureLogUnique(StringRef, SMLoc IDLoc) { raw_ostream *OS = getContext().getSecureLog(); if (OS == NULL) { std::string Err; - OS = new raw_fd_ostream(SecureLogFile, Err, sys::fs::F_Append); + OS = new raw_fd_ostream(SecureLogFile, Err, + sys::fs::F_Append | sys::fs::F_Text); if (!Err.empty()) { delete OS; return Error(IDLoc, Twine("can't open secure log file: ") + diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp index 5b8be18db3..1bd94a76fa 100644 --- a/lib/Support/Path.cpp +++ b/lib/Support/Path.cpp @@ -201,9 +201,9 @@ retry_random_path: // Try to open + create the file. switch (Type) { case FS_File: { - if (error_code EC = sys::fs::openFileForWrite( - Twine(ResultPath.begin()), ResultFD, - sys::fs::F_RW | sys::fs::F_Excl | sys::fs::F_Binary, Mode)) { + if (error_code EC = + sys::fs::openFileForWrite(Twine(ResultPath.begin()), ResultFD, + sys::fs::F_RW | sys::fs::F_Excl, Mode)) { if (EC == errc::file_exists) goto retry_random_path; return EC; diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index 100b21e122..0456f5d638 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -66,8 +66,8 @@ raw_ostream *llvm::CreateInfoOutputFile() { // compensate for this, the test-suite Makefiles have code to delete the // info output file before running commands which write to it. std::string Error; - raw_ostream *Result = - new raw_fd_ostream(OutputFilename.c_str(), Error, sys::fs::F_Append); + raw_ostream *Result = new raw_fd_ostream( + OutputFilename.c_str(), Error, sys::fs::F_Append | sys::fs::F_Text); if (Error.empty()) return Result; diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc index a72d0bf0b1..98b2767c01 100644 --- a/lib/Support/Windows/Path.inc +++ b/lib/Support/Windows/Path.inc @@ -876,7 +876,7 @@ error_code openFileForWrite(const Twine &Name, int &ResultFD, if (Flags & F_Append) OpenFlags |= _O_APPEND; - if (!(Flags & F_Binary)) + if (Flags & F_Text) OpenFlags |= _O_TEXT; int FD = ::_open_osfhandle(intptr_t(H), OpenFlags); diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index 2d825e1509..3c45743666 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -443,7 +443,7 @@ raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo, FD = STDOUT_FILENO; // If user requested binary then put stdout into binary mode if // possible. - if (Flags & sys::fs::F_Binary) + if (!(Flags & sys::fs::F_Text)) sys::ChangeStdoutToBinary(); // Close stdout when we're done, to detect any output errors. ShouldClose = true; diff --git a/lib/TableGen/Main.cpp b/lib/TableGen/Main.cpp index cf0d88b513..6532268263 100644 --- a/lib/TableGen/Main.cpp +++ b/lib/TableGen/Main.cpp @@ -57,7 +57,7 @@ static int createDependencyFile(const TGParser &Parser, const char *argv0) { return 1; } std::string Error; - tool_output_file DepOut(DependFilename.c_str(), Error, sys::fs::F_None); + tool_output_file DepOut(DependFilename.c_str(), Error, sys::fs::F_Text); if (!Error.empty()) { errs() << argv0 << ": error opening " << DependFilename << ":" << Error << "\n"; @@ -103,7 +103,7 @@ int TableGenMain(char *argv0, TableGenMainFn *MainFn) { return 1; std::string Error; - tool_output_file Out(OutputFilename.c_str(), Error, sys::fs::F_None); + tool_output_file Out(OutputFilename.c_str(), Error, sys::fs::F_Text); if (!Error.empty()) { errs() << argv0 << ": error opening " << OutputFilename << ":" << Error << "\n"; diff --git a/lib/Target/TargetMachineC.cpp b/lib/Target/TargetMachineC.cpp index f0644ea3cc..0175ab9917 100644 --- a/lib/Target/TargetMachineC.cpp +++ b/lib/Target/TargetMachineC.cpp @@ -238,7 +238,7 @@ static LLVMBool LLVMTargetMachineEmit(LLVMTargetMachineRef T, LLVMModuleRef M, LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M, char* Filename, LLVMCodeGenFileType codegen, char** ErrorMessage) { std::string error; - raw_fd_ostream dest(Filename, error, sys::fs::F_Binary); + raw_fd_ostream dest(Filename, error, sys::fs::F_None); if (!error.empty()) { *ErrorMessage = strdup(error.c_str()); return true; diff --git a/lib/Transforms/Instrumentation/DebugIR.cpp b/lib/Transforms/Instrumentation/DebugIR.cpp index 1100689fb7..f552bbffc0 100644 --- a/lib/Transforms/Instrumentation/DebugIR.cpp +++ b/lib/Transforms/Instrumentation/DebugIR.cpp @@ -528,7 +528,7 @@ void DebugIR::writeDebugBitcode(const Module *M, int *fd) { if (!fd) { std::string Path = getPath(); - Out.reset(new raw_fd_ostream(Path.c_str(), error, sys::fs::F_None)); + Out.reset(new raw_fd_ostream(Path.c_str(), error, sys::fs::F_Text)); DEBUG(dbgs() << "WRITING debug bitcode from Module " << M << " to file " << Path << "\n"); } else { diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 0929142108..8a3d5ea2db 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -466,7 +466,7 @@ void GCOVProfiler::emitProfileNotes() { DICompileUnit CU(CU_Nodes->getOperand(i)); std::string ErrorInfo; raw_fd_ostream out(mangleName(CU, "gcno").c_str(), ErrorInfo, - sys::fs::F_Binary); + sys::fs::F_None); std::string EdgeDestinations; DIArray SPs = CU.getSubprograms(); |