summaryrefslogtreecommitdiffstats
path: root/llvm/utils/FileUpdate/FileUpdate.cpp
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-12-16 03:29:14 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-12-16 03:29:14 +0000
commit39a0ffc3949a746d0a09c9a3e01c183c9216da04 (patch)
treed045dd753f87830314c4fede77145544f5650b6a /llvm/utils/FileUpdate/FileUpdate.cpp
parent716d01a612022608467fb7071ef4669dd326e007 (diff)
downloadbcm5719-llvm-39a0ffc3949a746d0a09c9a3e01c183c9216da04.tar.gz
bcm5719-llvm-39a0ffc3949a746d0a09c9a3e01c183c9216da04.zip
MemoryBuffer now return an error_code and returns a OwningPtr<MemoryBuffer> via an out parm.
llvm-svn: 121958
Diffstat (limited to 'llvm/utils/FileUpdate/FileUpdate.cpp')
-rw-r--r--llvm/utils/FileUpdate/FileUpdate.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/utils/FileUpdate/FileUpdate.cpp b/llvm/utils/FileUpdate/FileUpdate.cpp
index 3514d0f2157..3ea1e4f306e 100644
--- a/llvm/utils/FileUpdate/FileUpdate.cpp
+++ b/llvm/utils/FileUpdate/FileUpdate.cpp
@@ -15,6 +15,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/ADT/OwningPtr.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/Signals.h"
@@ -43,17 +44,16 @@ int main(int argc, char **argv) {
}
// Get the input data.
- error_code ec;
- MemoryBuffer *In =
- MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), ec);
- if (In == 0) {
+ OwningPtr<MemoryBuffer> In;
+ if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), In)) {
errs() << argv[0] << ": error: Unable to get input '"
<< InputFilename << "': " << ec.message() << '\n';
return 1;
}
// Get the output data.
- MemoryBuffer *Out = MemoryBuffer::getFile(OutputFilename.c_str(), ec);
+ OwningPtr<MemoryBuffer> Out;
+ MemoryBuffer::getFile(OutputFilename.c_str(), Out);
// If the output exists and the contents match, we are done.
if (Out && In->getBufferSize() == Out->getBufferSize() &&
@@ -65,8 +65,6 @@ int main(int argc, char **argv) {
return 0;
}
- delete Out;
-
// Otherwise, overwrite the output.
if (!Quiet)
errs() << argv[0] << ": Updating '" << OutputFilename
OpenPOWER on IntegriCloud