Cleaner, more general exponent output.
[oota-llvm.git] / lib / Support / FileUtilities.cpp
index ea7822a2c4b466aa4ed802c8fd4b84b3625f4e58..1736b0d5c31e2b0d99f23bb7158d624a990ab9b9 100644 (file)
@@ -106,8 +106,9 @@ static bool CompareNumbers(char *&F1P, char *&F2P, char *F1End, char *F2End,
       Diff = 0;  // Both zero.
     if (Diff > RelTolerance) {
       if (ErrorMsg) {
-        *ErrorMsg = "Compared: " + ftostr(V1) + " and " + ftostr(V2) +
-                    ": diff = " + ftostr(Diff) + "\n";
+        *ErrorMsg = "Compared: " + ftostr(V1) + " and " + ftostr(V2) + "\n";
+        *ErrorMsg += "abs. diff = " + ftostr(std::abs(V1-V2)) + 
+                     " rel.diff = " + ftostr(Diff) + "\n";
         *ErrorMsg += "Out of tolerance: rel/abs: " + ftostr(RelTolerance) +
                      "/" + ftostr(AbsTolerance);
       }
@@ -147,20 +148,21 @@ static void PadFileIfNeeded(char *&FileStart, char *&FileEnd, char *&FP) {
 /// error occurs, allowing the caller to distinguish between a failed diff and a
 /// file system error.
 ///
-int llvm::DiffFilesWithTolerance(const sys::Path &FileA,
-                                 const sys::Path &FileB,
+int llvm::DiffFilesWithTolerance(const sys::PathWithStatus &FileA,
+                                 const sys::PathWithStatus &FileB,
                                  double AbsTol, double RelTol,
                                  std::string *Error) {
-  sys::FileStatus FileAStat, FileBStat;
-  if (FileA.getFileStatus(FileAStat, Error))
+  const sys::FileStatus *FileAStat = FileA.getFileStatus(false, Error);
+  if (!FileAStat)
     return 2;
-  if (FileB.getFileStatus(FileBStat, Error))
+  const sys::FileStatus *FileBStat = FileB.getFileStatus(false, Error);
+  if (!FileBStat)
     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();
-  size_t B_size = FileBStat.getSize();
+  size_t A_size = FileAStat->getSize();
+  size_t B_size = FileBStat->getSize();
 
   // If they are both zero sized then they're the same
   if (A_size == 0 && B_size == 0)