diff options
Diffstat (limited to 'lib/Lex/Preprocessor.cpp')
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 8b4b1ddf4149..4598383c1c93 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -258,9 +258,10 @@ bool Preprocessor::SetCodeCompletionPoint(const FileEntry *File, // Truncate the buffer. if (Position < Buffer->getBufferEnd()) { + llvm::StringRef Data(Buffer->getBufferStart(), + Position-Buffer->getBufferStart()); MemoryBuffer *TruncatedBuffer - = MemoryBuffer::getMemBufferCopy(Buffer->getBufferStart(), Position, - Buffer->getBufferIdentifier()); + = MemoryBuffer::getMemBufferCopy(Data, Buffer->getBufferIdentifier()); SourceMgr.overrideFileContents(File, TruncatedBuffer); } @@ -508,9 +509,7 @@ bool Preprocessor::EnterMainSourceFile() { // Preprocess Predefines to populate the initial preprocessor state. llvm::MemoryBuffer *SB = - llvm::MemoryBuffer::getMemBufferCopy(Predefines.data(), - Predefines.data() + Predefines.size(), - "<built-in>"); + llvm::MemoryBuffer::getMemBufferCopy(Predefines, "<built-in>"); assert(SB && "Cannot fail to create predefined source buffer"); FileID FID = SourceMgr.createFileIDForMemBuffer(SB); assert(!FID.isInvalid() && "Could not create FileID for predefines?"); |