use an auto_ptr to avoid an explicit delete

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36850 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2007-05-06 05:47:36 +00:00
parent 03b6963762
commit db9cbeb240

View File

@ -184,14 +184,12 @@ int main(int argc, char **argv) {
std::auto_ptr<Module> M;
if (Bitcode) {
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&InputFilename[0],
InputFilename.size());
if (Buffer == 0)
ErrorMessage = "Error reading file '" + InputFilename + "'";
std::auto_ptr<MemoryBuffer> Buffer(
MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()));
if (Buffer.get())
M.reset(ParseBitcodeFile(Buffer.get(), &ErrorMessage));
else
M.reset(ParseBitcodeFile(Buffer, &ErrorMessage));
delete Buffer;
ErrorMessage = "Error reading file '" + InputFilename + "'";
} else {
M.reset(ParseBytecodeFile(InputFilename,
Compressor::decompressToNewBuffer,