make "ContentCache::Buffer" mutable to avoid a const_cast.

llvm-svn: 62403
This commit is contained in:
Chris Lattner 2009-01-17 03:54:16 +00:00
parent 1ed28ce3fd
commit 800979259e
2 changed files with 13 additions and 15 deletions

View File

@ -51,7 +51,7 @@ namespace SrcMgr {
class ContentCache {
/// Buffer - The actual buffer containing the characters from the input
/// file. This is owned by the ContentCache object.
const llvm::MemoryBuffer* Buffer;
mutable const llvm::MemoryBuffer *Buffer;
public:
/// Reference to the file entry. This reference does not own
@ -108,7 +108,7 @@ namespace SrcMgr {
/// ReadToSourceManager - Reconstitute a ContentCache from Bitcode
// and store it in the specified SourceManager.
static void ReadToSourceManager(llvm::Deserializer& D, SourceManager& SMgr,
static void ReadToSourceManager(llvm::Deserializer &D, SourceManager &SM,
FileManager *FMgr, std::vector<char> &Buf);
private:

View File

@ -56,9 +56,7 @@ const llvm::MemoryBuffer* ContentCache::getBuffer() const {
if (!Buffer && Entry) {
// FIXME: Should we support a way to not have to do this check over
// and over if we cannot open the file?
// FIXME: This const_cast is ugly. Should we make getBuffer() non-const?
const_cast<ContentCache*>(this)->Buffer =
MemoryBuffer::getFile(Entry->getName(), 0, Entry->getSize());
Buffer = MemoryBuffer::getFile(Entry->getName(), 0, Entry->getSize());
}
#endif
return Buffer;