Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Jul 2017 11:50:17 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r321719 - head/contrib/llvm/tools/clang/lib/Lex
Message-ID:  <201707301150.v6UBoHBN015948@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Sun Jul 30 11:50:16 2017
New Revision: 321719
URL: https://svnweb.freebsd.org/changeset/base/321719

Log:
  Pull in r309503 from upstream clang trunk (by Richard Smith):
  
    PR33902: Invalidate line number cache when adding more text to
    existing buffer.
  
    This led to crashes as the line number cache would report a bogus
    line number for a line of code, and we'd try to find a nonexistent
    column within the line when printing diagnostics.
  
  This fixes an assertion when building the graphics/champlain port.
  
  Reported by:	antoine, kwm
  PR:		219139

Modified:
  head/contrib/llvm/tools/clang/lib/Lex/ScratchBuffer.cpp

Modified: head/contrib/llvm/tools/clang/lib/Lex/ScratchBuffer.cpp
==============================================================================
--- head/contrib/llvm/tools/clang/lib/Lex/ScratchBuffer.cpp	Sun Jul 30 10:49:13 2017	(r321718)
+++ head/contrib/llvm/tools/clang/lib/Lex/ScratchBuffer.cpp	Sun Jul 30 11:50:16 2017	(r321719)
@@ -35,6 +35,14 @@ SourceLocation ScratchBuffer::getToken(const char *Buf
                                        const char *&DestPtr) {
   if (BytesUsed+Len+2 > ScratchBufSize)
     AllocScratchBuffer(Len+2);
+  else {
+    // Clear out the source line cache if it's already been computed.
+    // FIXME: Allow this to be incrementally extended.
+    auto *ContentCache = const_cast<SrcMgr::ContentCache *>(
+        SourceMgr.getSLocEntry(SourceMgr.getFileID(BufferStartLoc))
+                 .getFile().getContentCache());
+    ContentCache->SourceLineCache = nullptr;
+  }
 
   // Prefix the token with a \n, so that it looks like it is the first thing on
   // its own virtual line in caret diagnostics.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707301150.v6UBoHBN015948>