summaryrefslogtreecommitdiff
path: root/lib/Support/SourceMgr.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
commit3ff9563c3e391954b2e224afcf8b2b0fcc3888aa (patch)
treecccde9111a73ba5895f6cefbfb280290fa6c469d /lib/Support/SourceMgr.cpp
parentb29b20e7deb7297f6a10b2d6922feeca8c6df055 (diff)
downloadllvm-3ff9563c3e391954b2e224afcf8b2b0fcc3888aa.tar.gz
llvm-3ff9563c3e391954b2e224afcf8b2b0fcc3888aa.tar.bz2
llvm-3ff9563c3e391954b2e224afcf8b2b0fcc3888aa.tar.xz
MemoryBuffer now return an error_code and returns a OwningPtr<MemoryBuffer> via an out parm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121958 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/SourceMgr.cpp')
-rw-r--r--lib/Support/SourceMgr.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Support/SourceMgr.cpp b/lib/Support/SourceMgr.cpp
index 1f62068376..ef099163c2 100644
--- a/lib/Support/SourceMgr.cpp
+++ b/lib/Support/SourceMgr.cpp
@@ -16,6 +16,7 @@
#include "llvm/ADT/Twine.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/ADT/OwningPtr.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/system_error.h"
using namespace llvm;
@@ -49,18 +50,18 @@ SourceMgr::~SourceMgr() {
/// ~0, otherwise it returns the buffer ID of the stacked file.
unsigned SourceMgr::AddIncludeFile(const std::string &Filename,
SMLoc IncludeLoc) {
- error_code ec;
- MemoryBuffer *NewBuf = MemoryBuffer::getFile(Filename.c_str(), ec);
+ OwningPtr<MemoryBuffer> NewBuf;
+ MemoryBuffer::getFile(Filename.c_str(), NewBuf);
// If the file didn't exist directly, see if it's in an include path.
for (unsigned i = 0, e = IncludeDirectories.size(); i != e && !NewBuf; ++i) {
std::string IncFile = IncludeDirectories[i] + "/" + Filename;
- NewBuf = MemoryBuffer::getFile(IncFile.c_str(), ec);
+ MemoryBuffer::getFile(IncFile.c_str(), NewBuf);
}
if (NewBuf == 0) return ~0U;
- return AddNewSourceBuffer(NewBuf, IncludeLoc);
+ return AddNewSourceBuffer(NewBuf.take(), IncludeLoc);
}