summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/DataStream.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2012-02-09 00:29:19 +0000
committerDavid Blaikie <dblaikie@gmail.com>2012-02-09 00:29:19 +0000
commite7d7a5dfaa546a772ef9a9b9d7f7e04da6e2a21c (patch)
treea1c68ffbdf9f8639121d6a00985794295a278c85 /llvm/lib/Support/DataStream.cpp
parent7cc99dc40f51863207fbf11d1b7243da2e8e6a0d (diff)
downloadbcm5719-llvm-e7d7a5dfaa546a772ef9a9b9d7f7e04da6e2a21c.tar.gz
bcm5719-llvm-e7d7a5dfaa546a772ef9a9b9d7f7e04da6e2a21c.zip
Remove static initializer from DataStream.cpp
If someone would prefer a clear name for the 'success' error_value we could come up with one - potentially just a 'named constructor' style 'error_value::success()' to make this expression more self-documenting. If I see this come up in other cases I'll certainly consider it. One step along the way to resolving PR11944. llvm-svn: 150120
Diffstat (limited to 'llvm/lib/Support/DataStream.cpp')
-rw-r--r--llvm/lib/Support/DataStream.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/llvm/lib/Support/DataStream.cpp b/llvm/lib/Support/DataStream.cpp
index b2dd979e7f1..0e8a717b515 100644
--- a/llvm/lib/Support/DataStream.cpp
+++ b/llvm/lib/Support/DataStream.cpp
@@ -49,8 +49,6 @@ DataStreamer::~DataStreamer() {}
namespace {
-const static error_code success;
-
// Very simple stream backed by a file. Mostly useful for stdin and debugging;
// actual file access is probably still best done with mmap.
class DataFileStreamer : public DataStreamer {
@@ -66,18 +64,20 @@ public:
}
error_code OpenFile(const std::string &Filename) {
- int OpenFlags = O_RDONLY;
-#ifdef O_BINARY
- OpenFlags |= O_BINARY; // Open input file in binary mode on win32.
-#endif
if (Filename == "-") {
Fd = 0;
sys::Program::ChangeStdinToBinary();
+ return error_code();
}
- else
- Fd = ::open(Filename.c_str(), OpenFlags);
- if (Fd == -1) return error_code(errno, posix_category());
- return success;
+
+ int OpenFlags = O_RDONLY;
+#ifdef O_BINARY
+ OpenFlags |= O_BINARY; // Open input file in binary mode on win32.
+#endif
+ Fd = ::open(Filename.c_str(), OpenFlags);
+ if (Fd == -1)
+ return error_code(errno, posix_category());
+ return error_code();
}
};
@@ -87,8 +87,7 @@ namespace llvm {
DataStreamer *getDataFileStreamer(const std::string &Filename,
std::string *StrError) {
DataFileStreamer *s = new DataFileStreamer();
- error_code e = s->OpenFile(Filename);
- if (e != success) {
+ if (error_code e = s->OpenFile(Filename)) {
*StrError = std::string("Could not open ") + Filename + ": " +
e.message() + "\n";
return NULL;
OpenPOWER on IntegriCloud