summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-02-24 18:20:12 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-02-24 18:20:12 +0000
commit90c7f1cc161769853db72e30e76c34b0e4ddf3da (patch)
tree3d67820a8a7b4be67a275680897f77df8f188040 /llvm/lib
parent6ccda923e594bff47aade5a2342f01e5d2dbc661 (diff)
downloadbcm5719-llvm-90c7f1cc161769853db72e30e76c34b0e4ddf3da.tar.gz
bcm5719-llvm-90c7f1cc161769853db72e30e76c34b0e4ddf3da.zip
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 :-) llvm-svn: 202052
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/CFGPrinter.cpp4
-rw-r--r--llvm/lib/Bitcode/Writer/BitWriter.cpp2
-rw-r--r--llvm/lib/CodeGen/MachineVerifier.cpp3
-rw-r--r--llvm/lib/CodeGen/RegAllocPBQP.cpp2
-rw-r--r--llvm/lib/IR/Core.cpp2
-rw-r--r--llvm/lib/IR/GCOV.cpp2
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp2
-rw-r--r--llvm/lib/MC/MCParser/DarwinAsmParser.cpp3
-rw-r--r--llvm/lib/Support/Path.cpp6
-rw-r--r--llvm/lib/Support/Timer.cpp4
-rw-r--r--llvm/lib/Support/Windows/Path.inc2
-rw-r--r--llvm/lib/Support/raw_ostream.cpp2
-rw-r--r--llvm/lib/TableGen/Main.cpp4
-rw-r--r--llvm/lib/Target/TargetMachineC.cpp2
-rw-r--r--llvm/lib/Transforms/Instrumentation/DebugIR.cpp2
-rw-r--r--llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp2
16 files changed, 23 insertions, 21 deletions
diff --git a/llvm/lib/Analysis/CFGPrinter.cpp b/llvm/lib/Analysis/CFGPrinter.cpp
index 3c67618450c..3f768ce7806 100644
--- a/llvm/lib/Analysis/CFGPrinter.cpp
+++ b/llvm/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/llvm/lib/Bitcode/Writer/BitWriter.cpp b/llvm/lib/Bitcode/Writer/BitWriter.cpp
index cd1ada22cfd..0275f96fc9b 100644
--- a/llvm/lib/Bitcode/Writer/BitWriter.cpp
+++ b/llvm/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/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index d61470c173b..aa89b83e727 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/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/llvm/lib/CodeGen/RegAllocPBQP.cpp b/llvm/lib/CodeGen/RegAllocPBQP.cpp
index 56fdb45f4e0..347329591b5 100644
--- a/llvm/lib/CodeGen/RegAllocPBQP.cpp
+++ b/llvm/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/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index dbaf02edf6c..68bc5c5810e 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/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/llvm/lib/IR/GCOV.cpp b/llvm/lib/IR/GCOV.cpp
index 3311d2ef42e..a0591fffb9a 100644
--- a/llvm/lib/IR/GCOV.cpp
+++ b/llvm/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/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 2b37802efc4..fb272ad5134 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/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/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
index 6d66e308e8c..39399c08656 100644
--- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
+++ b/llvm/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/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index 5b8be18db3f..1bd94a76faf 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/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/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp
index 100b21e1221..0456f5d6383 100644
--- a/llvm/lib/Support/Timer.cpp
+++ b/llvm/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/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index a72d0bf0b1b..98b2767c011 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/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/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 2d825e15091..3c45743666d 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/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/llvm/lib/TableGen/Main.cpp b/llvm/lib/TableGen/Main.cpp
index cf0d88b513e..6532268263c 100644
--- a/llvm/lib/TableGen/Main.cpp
+++ b/llvm/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/llvm/lib/Target/TargetMachineC.cpp b/llvm/lib/Target/TargetMachineC.cpp
index f0644ea3cc2..0175ab99170 100644
--- a/llvm/lib/Target/TargetMachineC.cpp
+++ b/llvm/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/llvm/lib/Transforms/Instrumentation/DebugIR.cpp b/llvm/lib/Transforms/Instrumentation/DebugIR.cpp
index 1100689fb7e..f552bbffc0f 100644
--- a/llvm/lib/Transforms/Instrumentation/DebugIR.cpp
+++ b/llvm/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/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index 0929142108a..8a3d5ea2db9 100644
--- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/llvm/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();
OpenPOWER on IntegriCloud