Add a convenience API SourceManager::addMemBufferCopy() to simplify adding a

buffer in case the client does not need a pointer to the buffer.


Swift SVN r14777
This commit is contained in:
Dmitri Hrybenko
2014-03-07 11:41:08 +00:00
parent b9c87184ea
commit ef0942c69c
6 changed files with 34 additions and 24 deletions

View File

@@ -98,13 +98,26 @@ public:
return unsigned(BufferID);
}
// FIXME: remove this overload.
/// Adds a memory buffer to the SourceManager, taking ownership of it.
///
/// FIXME: remove this overload.
size_t addNewSourceBuffer(llvm::MemoryBuffer *Buffer);
size_t addNewSourceBuffer(std::unique_ptr<llvm::MemoryBuffer> Buffer) {
return addNewSourceBuffer(Buffer.release());
}
/// Creates a copy of a \c MemoryBuffer and adds it to the \c SourceManager,
/// taking ownership of the copy.
size_t addMemBufferCopy(llvm::MemoryBuffer *Buffer);
/// Creates and adds a memory buffer to the \c SourceManager, taking
/// ownership of the newly created copy.
///
/// \p InputData and \p BufIdentifier are copied, so that this memory can go
/// away as soon as this function returns.
size_t addMemBufferCopy(StringRef InputData, StringRef BufIdentifier = "");
/// Returns a buffer ID for a previously added buffer with the given
/// buffer identifier, or Nothing if there is no such buffer.
Optional<unsigned> getIDForBufferIdentifier(StringRef BufIdentifier);