include the null at the end of a memorybuffer as part of the buffer.
authorChris Lattner <sabre@nondot.org>
Wed, 18 Mar 2009 20:36:45 +0000 (20:36 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 18 Mar 2009 20:36:45 +0000 (20:36 +0000)
This allows tblgen to handle include "foo.td" when the quote is exactly
the last character in a file.  rdar://6695728

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67232 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/TGSourceMgr.cpp

index 9c39230def2114c40add5a681233503896fec195..e4d1c40dc6ca4d6435b22725c187f1c6337eae55 100644 (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;
 }