include the null at the end of a memorybuffer as part of the buffer.

This allows tblgen to handle include "foo.td" when the quote is exactly
the last character in a file.  rdar://6695728

llvm-svn: 67232
This commit is contained in:
Chris Lattner 2009-03-18 20:36:45 +00:00
parent 5def81401f
commit 0f6dc78cfe
1 changed files with 3 additions and 1 deletions

View File

@ -28,7 +28,9 @@ TGSourceMgr::~TGSourceMgr() {
int TGSourceMgr::FindBufferContainingLoc(TGLoc Loc) const {
for (unsigned i = 0, e = Buffers.size(); i != e; ++i)
if (Loc.getPointer() >= Buffers[i].Buffer->getBufferStart() &&
Loc.getPointer() < Buffers[i].Buffer->getBufferEnd())
// Use <= here so that a pointer to the null at the end of the buffer
// is included as part of the buffer.
Loc.getPointer() <= Buffers[i].Buffer->getBufferEnd())
return i;
return -1;
}