/// \brief Open the specified file as a MemoryBuffer, returning a new
/// MemoryBuffer if successful, otherwise returning null.
- std::unique_ptr<llvm::MemoryBuffer>
- getBufferForFile(const FileEntry *Entry, std::string *ErrorStr = nullptr,
- bool isVolatile = false, bool ShouldCloseOpenFile = true);
- std::unique_ptr<llvm::MemoryBuffer>
- getBufferForFile(StringRef Filename, std::string *ErrorStr = nullptr);
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+ getBufferForFile(const FileEntry *Entry, bool isVolatile = false,
+ bool ShouldCloseOpenFile = true);
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+ getBufferForFile(StringRef Filename);
/// \brief Get the 'stat' information for the given \p Path.
///
/// \brief Get the status of the file.
virtual llvm::ErrorOr<Status> status() = 0;
/// \brief Get the contents of the file as a \p MemoryBuffer.
- virtual std::error_code getBuffer(const Twine &Name,
- std::unique_ptr<llvm::MemoryBuffer> &Result,
- int64_t FileSize = -1,
- bool RequiresNullTerminator = true,
- bool IsVolatile = false) = 0;
+ virtual llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+ getBuffer(const Twine &Name, int64_t FileSize = -1,
+ bool RequiresNullTerminator = true, bool IsVolatile = false) = 0;
/// \brief Closes the file.
virtual std::error_code close() = 0;
/// \brief Sets the name to use for this file.
/// \brief Get the status of the entry at \p Path, if one exists.
virtual llvm::ErrorOr<Status> status(const Twine &Path) = 0;
/// \brief Get a \p File object for the file at \p Path, if one exists.
- virtual std::error_code openFileForRead(const Twine &Path,
- std::unique_ptr<File> &Result) = 0;
+ virtual llvm::ErrorOr<std::unique_ptr<File>>
+ openFileForRead(const Twine &Path) = 0;
/// This is a convenience method that opens a file, gets its content and then
/// closes the file.
- std::error_code getBufferForFile(const Twine &Name,
- std::unique_ptr<llvm::MemoryBuffer> &Result,
- int64_t FileSize = -1,
- bool RequiresNullTerminator = true,
- bool IsVolatile = false);
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+ getBufferForFile(const Twine &Name, int64_t FileSize = -1,
+ bool RequiresNullTerminator = true, bool IsVolatile = false);
/// \brief Get a directory_iterator for \p Dir.
/// \note The 'end' iterator is directory_iterator().
void pushOverlay(IntrusiveRefCntPtr<FileSystem> FS);
llvm::ErrorOr<Status> status(const Twine &Path) override;
- std::error_code openFileForRead(const Twine &Path,
- std::unique_ptr<File> &Result) override;
+ llvm::ErrorOr<std::unique_ptr<File>>
+ openFileForRead(const Twine &Path) override;
directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
typedef FileSystemList::reverse_iterator iterator;
path = NewPath;
}
-std::unique_ptr<llvm::MemoryBuffer>
-FileManager::getBufferForFile(const FileEntry *Entry, std::string *ErrorStr,
- bool isVolatile, bool ShouldCloseOpenFile) {
- std::unique_ptr<llvm::MemoryBuffer> Result;
- std::error_code ec;
-
+llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+FileManager::getBufferForFile(const FileEntry *Entry, bool isVolatile,
+ bool ShouldCloseOpenFile) {
uint64_t FileSize = Entry->getSize();
// If there's a high enough chance that the file have changed since we
// got its size, force a stat before opening it.
const char *Filename = Entry->getName();
// If the file is already open, use the open file descriptor.
if (Entry->File) {
- ec = Entry->File->getBuffer(Filename, Result, FileSize,
- /*RequiresNullTerminator=*/true, isVolatile);
- if (ErrorStr)
- *ErrorStr = ec.message();
+ auto Result =
+ Entry->File->getBuffer(Filename, FileSize,
+ /*RequiresNullTerminator=*/true, isVolatile);
// FIXME: we need a set of APIs that can make guarantees about whether a
// FileEntry is open or not.
if (ShouldCloseOpenFile)
// Otherwise, open the file.
- if (FileSystemOpts.WorkingDir.empty()) {
- ec = FS->getBufferForFile(Filename, Result, FileSize,
- /*RequiresNullTerminator=*/true, isVolatile);
- if (ec && ErrorStr)
- *ErrorStr = ec.message();
- return Result;
- }
+ if (FileSystemOpts.WorkingDir.empty())
+ return FS->getBufferForFile(Filename, FileSize,
+ /*RequiresNullTerminator=*/true, isVolatile);
SmallString<128> FilePath(Entry->getName());
FixupRelativePath(FilePath);
- ec = FS->getBufferForFile(FilePath.str(), Result, FileSize,
- /*RequiresNullTerminator=*/true, isVolatile);
- if (ec && ErrorStr)
- *ErrorStr = ec.message();
- return Result;
+ return FS->getBufferForFile(FilePath.str(), FileSize,
+ /*RequiresNullTerminator=*/true, isVolatile);
}
-std::unique_ptr<llvm::MemoryBuffer>
-FileManager::getBufferForFile(StringRef Filename, std::string *ErrorStr) {
- std::unique_ptr<llvm::MemoryBuffer> Result;
- std::error_code ec;
- if (FileSystemOpts.WorkingDir.empty()) {
- ec = FS->getBufferForFile(Filename, Result);
- if (ec && ErrorStr)
- *ErrorStr = ec.message();
- return Result;
- }
+llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+FileManager::getBufferForFile(StringRef Filename) {
+ if (FileSystemOpts.WorkingDir.empty())
+ return FS->getBufferForFile(Filename);
SmallString<128> FilePath(Filename);
FixupRelativePath(FilePath);
- ec = FS->getBufferForFile(FilePath.c_str(), Result);
- if (ec && ErrorStr)
- *ErrorStr = ec.message();
- return Result;
+ return FS->getBufferForFile(FilePath.c_str());
}
/// getStatValue - Get the 'stat' information for the specified path,
//
// Because of this, check to see if the file exists with 'open'. If the
// open succeeds, use fstat to get the stat info.
- std::unique_ptr<vfs::File> OwnedFile;
- std::error_code EC = FS.openFileForRead(Path, OwnedFile);
+ auto OwnedFile = FS.openFileForRead(Path);
- if (EC) {
+ if (!OwnedFile) {
// If the open fails, our "stat" fails.
R = CacheMissing;
} else {
// Otherwise, the open succeeded. Do an fstat to get the information
// about the file. We'll end up returning the open file descriptor to the
// client to do what they please with it.
- llvm::ErrorOr<vfs::Status> Status = OwnedFile->status();
+ llvm::ErrorOr<vfs::Status> Status = (*OwnedFile)->status();
if (Status) {
R = CacheExists;
copyStatusToFileData(*Status, Data);
- *F = std::move(OwnedFile);
+ *F = std::move(*OwnedFile);
} else {
// fstat rarely fails. If it does, claim the initial open didn't
// succeed.
return Buffer.getPointer();
}
- std::string ErrorStr;
bool isVolatile = SM.userFilesAreVolatile() && !IsSystemFile;
- Buffer.setPointer(SM.getFileManager()
- .getBufferForFile(ContentsEntry, &ErrorStr, isVolatile)
- .release());
+ auto BufferOrError =
+ SM.getFileManager().getBufferForFile(ContentsEntry, isVolatile);
// If we were unable to open the file, then we are in an inconsistent
// situation where the content cache referenced a file which no longer
// currently handle returning a null entry here. Ideally we should detect
// that we are in an inconsistent situation and error out as quickly as
// possible.
- if (!Buffer.getPointer()) {
+ if (!BufferOrError) {
StringRef FillStr("<<<MISSING SOURCE FILE>>>\n");
Buffer.setPointer(MemoryBuffer::getNewMemBuffer(ContentsEntry->getSize(),
"<invalid>").release());
Ptr[i] = FillStr[i % FillStr.size()];
if (Diag.isDiagnosticInFlight())
- Diag.SetDelayedDiagnostic(diag::err_cannot_open_file,
- ContentsEntry->getName(), ErrorStr);
- else
+ Diag.SetDelayedDiagnostic(diag::err_cannot_open_file,
+ ContentsEntry->getName(),
+ BufferOrError.getError().message());
+ else
Diag.Report(Loc, diag::err_cannot_open_file)
- << ContentsEntry->getName() << ErrorStr;
+ << ContentsEntry->getName() << BufferOrError.getError().message();
Buffer.setInt(Buffer.getInt() | InvalidFlag);
if (Invalid) *Invalid = true;
return Buffer.getPointer();
}
-
+
+ Buffer.setPointer(BufferOrError->release());
+
// Check that the file's size is the same as in the file entry (which may
// have come from a stat cache).
if (getRawBuffer()->getBufferSize() != (size_t)ContentsEntry->getSize()) {
FileSystem::~FileSystem() {}
-std::error_code FileSystem::getBufferForFile(
- const llvm::Twine &Name, std::unique_ptr<MemoryBuffer> &Result,
- int64_t FileSize, bool RequiresNullTerminator, bool IsVolatile) {
- std::unique_ptr<File> F;
- if (std::error_code EC = openFileForRead(Name, F))
- return EC;
-
- std::error_code EC =
- F->getBuffer(Name, Result, FileSize, RequiresNullTerminator, IsVolatile);
- return EC;
+ErrorOr<std::unique_ptr<MemoryBuffer>>
+FileSystem::getBufferForFile(const llvm::Twine &Name, int64_t FileSize,
+ bool RequiresNullTerminator, bool IsVolatile) {
+ auto F = openFileForRead(Name);
+ if (!F)
+ return F.getError();
+
+ return (*F)->getBuffer(Name, FileSize, RequiresNullTerminator, IsVolatile);
}
//===-----------------------------------------------------------------------===/
public:
~RealFile();
ErrorOr<Status> status() override;
- std::error_code getBuffer(const Twine &Name,
- std::unique_ptr<MemoryBuffer> &Result,
- int64_t FileSize = -1,
- bool RequiresNullTerminator = true,
- bool IsVolatile = false) override;
+ ErrorOr<std::unique_ptr<MemoryBuffer>>
+ getBuffer(const Twine &Name, int64_t FileSize = -1,
+ bool RequiresNullTerminator = true,
+ bool IsVolatile = false) override;
std::error_code close() override;
void setName(StringRef Name) override;
};
return S;
}
-std::error_code RealFile::getBuffer(const Twine &Name,
- std::unique_ptr<MemoryBuffer> &Result,
- int64_t FileSize,
- bool RequiresNullTerminator,
- bool IsVolatile) {
+ErrorOr<std::unique_ptr<MemoryBuffer>>
+RealFile::getBuffer(const Twine &Name, int64_t FileSize,
+ bool RequiresNullTerminator, bool IsVolatile) {
assert(FD != -1 && "cannot get buffer for closed file");
- ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
- MemoryBuffer::getOpenFile(FD, Name.str().c_str(), FileSize,
- RequiresNullTerminator, IsVolatile);
- if (std::error_code EC = BufferOrErr.getError())
- return EC;
- Result = std::move(BufferOrErr.get());
- return std::error_code();
+ return MemoryBuffer::getOpenFile(FD, Name, FileSize, RequiresNullTerminator,
+ IsVolatile);
}
// FIXME: This is terrible, we need this for ::close.
class RealFileSystem : public FileSystem {
public:
ErrorOr<Status> status(const Twine &Path) override;
- std::error_code openFileForRead(const Twine &Path,
- std::unique_ptr<File> &Result) override;
+ ErrorOr<std::unique_ptr<File>> openFileForRead(const Twine &Path) override;
directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
};
} // end anonymous namespace
return Result;
}
-std::error_code RealFileSystem::openFileForRead(const Twine &Name,
- std::unique_ptr<File> &Result) {
+ErrorOr<std::unique_ptr<File>>
+RealFileSystem::openFileForRead(const Twine &Name) {
int FD;
if (std::error_code EC = sys::fs::openFileForRead(Name, FD))
return EC;
- Result.reset(new RealFile(FD));
+ std::unique_ptr<File> Result(new RealFile(FD));
Result->setName(Name.str());
- return std::error_code();
+ return std::move(Result);
}
IntrusiveRefCntPtr<FileSystem> vfs::getRealFileSystem() {
return make_error_code(llvm::errc::no_such_file_or_directory);
}
-std::error_code
-OverlayFileSystem::openFileForRead(const llvm::Twine &Path,
- std::unique_ptr<File> &Result) {
+ErrorOr<std::unique_ptr<File>>
+OverlayFileSystem::openFileForRead(const llvm::Twine &Path) {
// FIXME: handle symlinks that cross file systems
for (iterator I = overlays_begin(), E = overlays_end(); I != E; ++I) {
- std::error_code EC = (*I)->openFileForRead(Path, Result);
- if (!EC || EC != llvm::errc::no_such_file_or_directory)
- return EC;
+ auto Result = (*I)->openFileForRead(Path);
+ if (Result || Result.getError() != llvm::errc::no_such_file_or_directory)
+ return Result;
}
return make_error_code(llvm::errc::no_such_file_or_directory);
}
IntrusiveRefCntPtr<FileSystem> ExternalFS);
ErrorOr<Status> status(const Twine &Path) override;
- std::error_code openFileForRead(const Twine &Path,
- std::unique_ptr<File> &Result) override;
+ ErrorOr<std::unique_ptr<File>> openFileForRead(const Twine &Path) override;
directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override{
ErrorOr<Entry *> E = lookupPath(Dir);
return status(Path, *Result);
}
-std::error_code
-VFSFromYAML::openFileForRead(const Twine &Path,
- std::unique_ptr<vfs::File> &Result) {
+ErrorOr<std::unique_ptr<File>> VFSFromYAML::openFileForRead(const Twine &Path) {
ErrorOr<Entry *> E = lookupPath(Path);
if (!E)
return E.getError();
if (!F) // FIXME: errc::not_a_file?
return make_error_code(llvm::errc::invalid_argument);
- if (std::error_code EC =
- ExternalFS->openFileForRead(F->getExternalContentsPath(), Result))
- return EC;
+ auto Result = ExternalFS->openFileForRead(F->getExternalContentsPath());
+ if (!Result)
+ return Result;
if (!F->useExternalName(UseExternalNames))
- Result->setName(Path.str());
+ (*Result)->setName(Path.str());
- return std::error_code();
+ return Result;
}
IntrusiveRefCntPtr<FileSystem>
// loaded from bitcode, do so now.
const std::string &LinkBCFile = CI.getCodeGenOpts().LinkBitcodeFile;
if (!LinkModuleToUse && !LinkBCFile.empty()) {
- std::string ErrorStr;
-
- std::unique_ptr<llvm::MemoryBuffer> BCBuf =
- CI.getFileManager().getBufferForFile(LinkBCFile, &ErrorStr);
+ auto BCBuf = CI.getFileManager().getBufferForFile(LinkBCFile);
if (!BCBuf) {
CI.getDiagnostics().Report(diag::err_cannot_open_file)
- << LinkBCFile << ErrorStr;
+ << LinkBCFile << BCBuf.getError().message();
return nullptr;
}
ErrorOr<llvm::Module *> ModuleOrErr =
- getLazyBitcodeModule(std::move(BCBuf), *VMContext);
+ getLazyBitcodeModule(std::move(*BCBuf), *VMContext);
if (std::error_code EC = ModuleOrErr.getError()) {
CI.getDiagnostics().Report(diag::err_cannot_open_file)
<< LinkBCFile << EC.message();
std::unique_ptr<llvm::MemoryBuffer>
ASTUnit::getBufferForFile(StringRef Filename, std::string *ErrorStr) {
assert(FileMgr);
- return FileMgr->getBufferForFile(Filename, ErrorStr);
+ auto Buffer = FileMgr->getBufferForFile(Filename);
+ if (Buffer)
+ return std::move(*Buffer);
+ if (ErrorStr)
+ *ErrorStr = Buffer.getError().message();
+ return nullptr;
}
/// \brief Configure the diagnostics object for use with ASTUnit.
// pick up the correct size, and simply override their contents as we do for
// STDIN.
if (File->isNamedPipe()) {
- std::string ErrorStr;
- if (std::unique_ptr<llvm::MemoryBuffer> MB =
- FileMgr.getBufferForFile(File, &ErrorStr, /*isVolatile=*/true)) {
+ auto MB = FileMgr.getBufferForFile(File, /*isVolatile=*/true);
+ if (MB) {
// Create a new virtual file that will have the correct size.
- File = FileMgr.getVirtualFile(InputFile, MB->getBufferSize(), 0);
- SourceMgr.overrideFileContents(File, std::move(MB));
+ File = FileMgr.getVirtualFile(InputFile, (*MB)->getBufferSize(), 0);
+ SourceMgr.overrideFileContents(File, std::move(*MB));
} else {
- Diags.Report(diag::err_cannot_open_file) << InputFile << ErrorStr;
+ Diags.Report(diag::err_cannot_open_file) << InputFile
+ << MB.getError().message();
return false;
}
}
}
CompilerInstance &CI = getCompilerInstance();
- if (std::unique_ptr<llvm::MemoryBuffer> Buffer =
- CI.getFileManager().getBufferForFile(getCurrentFile())) {
+ auto Buffer = CI.getFileManager().getBufferForFile(getCurrentFile());
+ if (Buffer) {
unsigned Preamble =
- Lexer::ComputePreamble(Buffer->getBuffer(), CI.getLangOpts()).first;
- llvm::outs().write(Buffer->getBufferStart(), Preamble);
+ Lexer::ComputePreamble((*Buffer)->getBuffer(), CI.getLangOpts()).first;
+ llvm::outs().write((*Buffer)->getBufferStart(), Preamble);
}
}
FileSystemOptions FO;
FileManager FileMgr(FO);
- std::unique_ptr<llvm::MemoryBuffer> Buffer = FileMgr.getBufferForFile(File);
+ auto Buffer = FileMgr.getBufferForFile(File);
if (!Buffer)
return SDError::CouldNotLoad;
llvm::BitstreamReader StreamFile;
- StreamFile.init((const unsigned char *)Buffer->getBufferStart(),
- (const unsigned char *)Buffer->getBufferEnd());
+ StreamFile.init((const unsigned char *)(*Buffer)->getBufferStart(),
+ (const unsigned char *)(*Buffer)->getBufferEnd());
llvm::BitstreamCursor Stream;
Stream.init(StreamFile);
unsigned FileSize = FE->getSize();
if (FileSize <= sizeof(HMapHeader)) return nullptr;
- std::unique_ptr<const llvm::MemoryBuffer> FileBuffer =
- FM.getBufferForFile(FE);
+ auto FileBuffer = FM.getBufferForFile(FE);
if (!FileBuffer) return nullptr; // Unreadable file?
- const char *FileStart = FileBuffer->getBufferStart();
+ const char *FileStart = (*FileBuffer)->getBufferStart();
// We know the file is at least as big as the header, check it now.
const HMapHeader *Header = reinterpret_cast<const HMapHeader*>(FileStart);
if (Header->Reserved != 0) return nullptr;
// Okay, everything looks good, create the header map.
- return new HeaderMap(std::move(FileBuffer), NeedsByteSwap);
+ return new HeaderMap(std::move(*FileBuffer), NeedsByteSwap);
}
//===----------------------------------------------------------------------===//
FileManager &FileMgr,
DiagnosticsEngine &Diags) {
// Open the AST file.
- std::string ErrStr;
- std::unique_ptr<llvm::MemoryBuffer> Buffer =
- FileMgr.getBufferForFile(ASTFileName, &ErrStr);
+ auto Buffer = FileMgr.getBufferForFile(ASTFileName);
if (!Buffer) {
- Diags.Report(diag::err_fe_unable_to_read_pch_file) << ASTFileName << ErrStr;
+ Diags.Report(diag::err_fe_unable_to_read_pch_file)
+ << ASTFileName << Buffer.getError().message();
return std::string();
}
// Initialize the stream
llvm::BitstreamReader StreamFile;
BitstreamCursor Stream;
- StreamFile.init((const unsigned char *)Buffer->getBufferStart(),
- (const unsigned char *)Buffer->getBufferEnd());
+ StreamFile.init((const unsigned char *)(*Buffer)->getBufferStart(),
+ (const unsigned char *)(*Buffer)->getBufferEnd());
Stream.init(StreamFile);
// Sniff for the signature.
FileManager &FileMgr,
ASTReaderListener &Listener) {
// Open the AST file.
- std::string ErrStr;
- std::unique_ptr<llvm::MemoryBuffer> Buffer =
- FileMgr.getBufferForFile(Filename, &ErrStr);
+ auto Buffer = FileMgr.getBufferForFile(Filename);
if (!Buffer) {
return true;
}
// Initialize the stream
llvm::BitstreamReader StreamFile;
BitstreamCursor Stream;
- StreamFile.init((const unsigned char *)Buffer->getBufferStart(),
- (const unsigned char *)Buffer->getBufferEnd());
+ StreamFile.init((const unsigned char *)(*Buffer)->getBufferStart(),
+ (const unsigned char *)(*Buffer)->getBufferEnd());
Stream.init(StreamFile);
// Sniff for the signature.
bool GlobalModuleIndexBuilder::loadModuleFile(const FileEntry *File) {
// Open the module file.
- std::string ErrorStr;
- std::unique_ptr<llvm::MemoryBuffer> Buffer =
- FileMgr.getBufferForFile(File, &ErrorStr, /*isVolatile=*/true);
+ auto Buffer = FileMgr.getBufferForFile(File, /*isVolatile=*/true);
if (!Buffer) {
return true;
}
// Initialize the input stream
llvm::BitstreamReader InStreamFile;
llvm::BitstreamCursor InStream;
- InStreamFile.init((const unsigned char *)Buffer->getBufferStart(),
- (const unsigned char *)Buffer->getBufferEnd());
+ InStreamFile.init((const unsigned char *)(*Buffer)->getBufferStart(),
+ (const unsigned char *)(*Buffer)->getBufferEnd());
InStream.init(InStreamFile);
// Sniff for the signature.
New->Buffer = std::move(Buffer);
} else {
// Open the AST file.
- std::error_code ec;
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buf(
+ (std::error_code()));
if (FileName == "-") {
- llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buf =
- llvm::MemoryBuffer::getSTDIN();
- ec = Buf.getError();
- if (ec)
- ErrorStr = ec.message();
- else
- New->Buffer = std::move(Buf.get());
+ Buf = llvm::MemoryBuffer::getSTDIN();
} else {
// Leave the FileEntry open so if it gets read again by another
// ModuleManager it must be the same underlying file.
// FIXME: Because FileManager::getFile() doesn't guarantee that it will
// give us an open file, this may not be 100% reliable.
- New->Buffer = FileMgr.getBufferForFile(New->File, &ErrorStr,
- /*IsVolatile*/ false,
- /*ShouldClose*/ false);
+ Buf = FileMgr.getBufferForFile(New->File,
+ /*IsVolatile=*/false,
+ /*ShouldClose=*/false);
}
-
- if (!New->Buffer)
+
+ if (!Buf) {
+ ErrorStr = Buf.getError().message();
return Missing;
+ }
+
+ New->Buffer = std::move(*Buf);
}
// Initialize the stream
return make_error_code(llvm::errc::no_such_file_or_directory);
return I->second;
}
- std::error_code openFileForRead(const Twine &Path,
- std::unique_ptr<vfs::File> &Result) override {
- llvm_unreachable("unimplemented");
- }
- std::error_code getBufferForFile(const Twine &Name,
- std::unique_ptr<MemoryBuffer> &Result,
- int64_t FileSize = -1,
- bool RequiresNullTerminator = true) {
+ ErrorOr<std::unique_ptr<vfs::File>>
+ openFileForRead(const Twine &Path) override {
llvm_unreachable("unimplemented");
}
// descriptor, which might not see the changes made.
// FIXME: Figure out whether there is a way to get the SourceManger to
// reopen the file.
- std::unique_ptr<const llvm::MemoryBuffer> FileBuffer(
- Context.Files.getBufferForFile(Path, nullptr));
- return FileBuffer->getBuffer();
+ auto FileBuffer = Context.Files.getBufferForFile(Path);
+ return (*FileBuffer)->getBuffer();
}
llvm::StringMap<std::string> TemporaryFiles;
// descriptor, which might not see the changes made.
// FIXME: Figure out whether there is a way to get the SourceManger to
// reopen the file.
- std::unique_ptr<const llvm::MemoryBuffer> FileBuffer(
- Files.getBufferForFile(Path, nullptr));
- return FileBuffer->getBuffer();
+ auto FileBuffer = Files.getBufferForFile(Path);
+ return (*FileBuffer)->getBuffer();
}
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;