Put a newline at the end of the padded buffers used for the

precompiled preamble. This will suppress the -pedantic "no newline at
end of file" warning.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109301 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Douglas Gregor 2010-07-24 00:42:07 +00:00
Родитель 754f3490c5
Коммит 592508ed99
1 изменённых файлов: 6 добавлений и 4 удалений

Просмотреть файл

@ -513,7 +513,8 @@ static llvm::MemoryBuffer *CreatePaddedMainFileBuffer(llvm::MemoryBuffer *Old,
memcpy(const_cast<char*>(Result->getBufferStart()),
Old->getBufferStart(), Old->getBufferSize());
memset(const_cast<char*>(Result->getBufferStart()) + Old->getBufferSize(),
' ', NewSize - Old->getBufferSize() - 1);
' ', NewSize - Old->getBufferSize() - 2);
const_cast<char*>(Result->getBufferEnd())[-2] = '\n';
const_cast<char*>(Result->getBufferEnd())[-1] = 0;
if (DeleteOld)
@ -565,7 +566,7 @@ llvm::MemoryBuffer *ASTUnit::BuildPrecompiledPreamble() {
// the main-file buffer within the precompiled preamble to fit the
// new main file.
if (Preamble.size() == NewPreamble.second &&
NewPreamble.first->getBufferSize() < PreambleReservedSize &&
NewPreamble.first->getBufferSize() < PreambleReservedSize-2 &&
memcmp(&Preamble[0], NewPreamble.first->getBufferStart(),
NewPreamble.second) == 0) {
// The preamble has not changed. We may be able to re-use the precompiled
@ -603,9 +604,10 @@ llvm::MemoryBuffer *ASTUnit::BuildPrecompiledPreamble() {
memcpy(const_cast<char*>(PreambleBuffer->getBufferStart()),
NewPreamble.first->getBufferStart(), Preamble.size());
memset(const_cast<char*>(PreambleBuffer->getBufferStart()) + Preamble.size(),
' ', PreambleReservedSize - Preamble.size() - 1);
' ', PreambleReservedSize - Preamble.size() - 2);
const_cast<char*>(PreambleBuffer->getBufferEnd())[-1] = 0;
const_cast<char*>(PreambleBuffer->getBufferEnd())[-2] = '\n';
// Save the preamble text for later; we'll need to compare against it for
// subsequent reparses.
Preamble.assign(NewPreamble.first->getBufferStart(),