[PATCH] D81964: [clangd] Make use of preamble bounds from the patch inside ReplayPreamble

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 16 13:12:26 PDT 2020


kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

Clangd was using bounds from the stale preamble, which might result in
crashes. For example:

  #include "a.h"
  #include "b.h" // this line is newly inserted
  #include "c.h"

PreambleBounds for the baseline only contains first two lines, but
ReplayPreamble logic contains an include from the third line. This would
result in a crash as we only lex preamble part of the current file
during ReplayPreamble.

This patch adds a `preambleBounds` method to PreamblePatch, which can be
used to figure out preamble bounds for the current version of the file.
Then uses it when attaching ReplayPreamble, so that it can lex the
up-to-date preamble region.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81964

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81964.271175.patch
Type: text/x-patch
Size: 8171 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200616/8451a071/attachment-0001.bin>


More information about the cfe-commits mailing list