[cfe-commits] r109301 - /cfe/trunk/lib/Frontend/ASTUnit.cpp
Douglas Gregor
dgregor at apple.com
Fri Jul 23 17:42:07 PDT 2010
Author: dgregor
Date: Fri Jul 23 19:42:07 2010
New Revision: 109301
URL: http://llvm.org/viewvc/llvm-project?rev=109301&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=109301&r1=109300&r2=109301&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Fri Jul 23 19:42:07 2010
@@ -513,7 +513,8 @@
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 @@
// 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 @@
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(),
More information about the cfe-commits
mailing list