Fix bugs in class invariant
authorReid Spencer <rspencer@reidspencer.com>
Sun, 14 Nov 2004 22:07:50 +0000 (22:07 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Sun, 14 Nov 2004 22:07:50 +0000 (22:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17779 91177308-0d34-0410-b5e6-96231b3b80d8

lib/System/Unix/MappedFile.cpp
lib/System/Unix/MappedFile.inc

index 7e03cd15a819a9a6e46d8fad34dd4cdac80b8235..0e03a04c6fe871997fa8acac68821da420ca78b5 100644 (file)
@@ -53,6 +53,8 @@ void MappedFile::initialize() {
       info_ = 0;
       ThrowErrno(std::string("Can't stat file: ") + path_.get());
     }
+  } else {
+    throw std::string("Can't open file: ") + path_.get();
   }
 }
 
@@ -74,6 +76,7 @@ void MappedFile::unmap() {
 }
 
 void* MappedFile::map() {
+  assert(info_ && "MappedFile not initialized");
   if (!isMapped()) {
     int prot = PROT_NONE;
     int flags = 0;
index 7e03cd15a819a9a6e46d8fad34dd4cdac80b8235..0e03a04c6fe871997fa8acac68821da420ca78b5 100644 (file)
@@ -53,6 +53,8 @@ void MappedFile::initialize() {
       info_ = 0;
       ThrowErrno(std::string("Can't stat file: ") + path_.get());
     }
+  } else {
+    throw std::string("Can't open file: ") + path_.get();
   }
 }
 
@@ -74,6 +76,7 @@ void MappedFile::unmap() {
 }
 
 void* MappedFile::map() {
+  assert(info_ && "MappedFile not initialized");
   if (!isMapped()) {
     int prot = PROT_NONE;
     int flags = 0;