summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-08-22 16:06:27 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-08-22 16:06:27 +0000
commitefdc3a13cdccf11fe33773e724ff40ffa8c733b0 (patch)
tree2e94623b087fe17a9033023f1d28ea56eab50c61
parentdf1297dd3a4b3163c0a2a27a2d0048a584ea0fda (diff)
downloadbcm5719-llvm-efdc3a13cdccf11fe33773e724ff40ffa8c733b0.tar.gz
bcm5719-llvm-efdc3a13cdccf11fe33773e724ff40ffa8c733b0.zip
For 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. llvm-svn: 29817
-rw-r--r--llvm/include/llvm/Debugger/SourceFile.h5
-rw-r--r--llvm/lib/Debugger/SourceFile.cpp4
-rw-r--r--llvm/lib/Support/FileUtilities.cpp20
3 files changed, 21 insertions, 8 deletions
diff --git a/llvm/include/llvm/Debugger/SourceFile.h b/llvm/include/llvm/Debugger/SourceFile.h
index 6d49fbe5d22..e54660cb7a9 100644
--- a/llvm/include/llvm/Debugger/SourceFile.h
+++ b/llvm/include/llvm/Debugger/SourceFile.h
@@ -50,7 +50,10 @@ namespace llvm {
/// reading it, or if the user cancels the operation. Instead, it will just
/// be an empty source file.
SourceFile(const std::string &fn, const GlobalVariable *Desc)
- : Filename(fn), Descriptor(Desc), File(Filename) {
+ : Filename(fn), Descriptor(Desc), File() {
+ std::string ErrMsg;
+ if (File.open(Filename, sys::MappedFile::READ_ACCESS, &ErrMsg))
+ throw ErrMsg;
readFile();
}
~SourceFile() {
diff --git a/llvm/lib/Debugger/SourceFile.cpp b/llvm/lib/Debugger/SourceFile.cpp
index 222cdfa26aa..799231fc8dd 100644
--- a/llvm/lib/Debugger/SourceFile.cpp
+++ b/llvm/lib/Debugger/SourceFile.cpp
@@ -19,7 +19,9 @@ using namespace llvm;
/// readFile - Load Filename
///
void SourceFile::readFile() {
- File.map();
+ std::string ErrMsg;
+ if (File.map(&ErrMsg))
+ throw ErrMsg;
}
/// calculateLineOffsets - Compute the LineOffset vector for the current file.
diff --git a/llvm/lib/Support/FileUtilities.cpp b/llvm/lib/Support/FileUtilities.cpp
index d4608ccb65b..313598942a7 100644
--- a/llvm/lib/Support/FileUtilities.cpp
+++ b/llvm/lib/Support/FileUtilities.cpp
@@ -147,9 +147,11 @@ int llvm::DiffFilesWithTolerance(const sys::Path &FileA,
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 @@ int llvm::DiffFilesWithTolerance(const sys::Path &FileA,
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();
OpenPOWER on IntegriCloud