[llvm-commits] CVS: llvm/lib/Support/FileUtilities.cpp

Reid Spencer reid at x10sys.com
Tue Aug 22 09:06:44 PDT 2006



Changes in directory llvm/lib/Support:

FileUtilities.cpp updated: 1.48 -> 1.49
---
Log message:

For PR797: http://llvm.org/PR797 :
Adjust users of MappedFile to its new non-throwing interface.  Note that in 
most cases the lazy step of just throwing after a call to MappedFile was 
installed. This was done in the name of incremental changes. Getting rid of 
the new throw statements will take adjustment of interfaces and propagation 
of errors to higher levels.  Those changes will come in subsequent patches.


---
Diffs of the changes:  (+14 -6)

 FileUtilities.cpp |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)


Index: llvm/lib/Support/FileUtilities.cpp
diff -u llvm/lib/Support/FileUtilities.cpp:1.48 llvm/lib/Support/FileUtilities.cpp:1.49
--- llvm/lib/Support/FileUtilities.cpp:1.48	Fri Jul 28 17:03:44 2006
+++ llvm/lib/Support/FileUtilities.cpp	Tue Aug 22 11:06:27 2006
@@ -147,9 +147,11 @@
                                  double AbsTol, double RelTol,
                                  std::string *Error) {
   sys::FileStatus FileAStat, FileBStat;
-  if (FileA.getFileStatus(FileAStat, Error) ||
-      FileB.getFileStatus(FileBStat, Error))
+  if (FileA.getFileStatus(FileAStat, Error))
     return 2;
+  if (FileB.getFileStatus(FileBStat, Error))
+    return 2;
+
   // Check for zero length files because some systems croak when you try to
   // mmap an empty file.
   size_t A_size = FileAStat.getSize();
@@ -165,10 +167,16 @@
   try {
     // Now its safe to mmap the files into memory becasue both files
     // have a non-zero size.
-    sys::MappedFile F1(FileA);
-    sys::MappedFile F2(FileB);
-    F1.map();
-    F2.map();
+    sys::MappedFile F1;
+    if (F1.open(FileA, sys::MappedFile::READ_ACCESS, Error))
+      return 2;
+    sys::MappedFile F2;
+    if (F2.open(FileB, sys::MappedFile::READ_ACCESS, Error))
+      return 2;
+    if (!F1.map(Error))
+      return 2;
+    if (!F2.map(Error))
+      return 2;
 
     // Okay, now that we opened the files, scan them for the first difference.
     char *File1Start = F1.charBase();






More information about the llvm-commits mailing list