[clangd] Copy existing includes in ReplayPreamble
authorKadir Cetinkaya <kadircet@google.com>
Tue, 2 Jun 2020 09:52:55 +0000 (11:52 +0200)
committerKadir Cetinkaya <kadircet@google.com>
Tue, 2 Jun 2020 12:31:45 +0000 (14:31 +0200)
commit8506877c87aa602736aee1fffbd80b886fa40b79
treed1c860b0ccc11c029aacae8bc3336f2174a54445
parenta0f13b33742372bf00640eb18a2f3229176fc77d
[clangd] Copy existing includes in ReplayPreamble

Summary:
ReplayPreamble was just grabbing the reference of IncludeStructure
passed to it and then replayed any includes seen so while exiting
built-in file.

This implies any include seen in built-in files being replayed as part
of preamble, even though they are not. This wasn't an issue until we've
started patching preambles, as includes from built-in files were not
mapped back to main-file.

This patch copies over existing includes at the time of
ReplayPreamble::attach and only replies those to prevent any includes
from the preamble patch getting mixed-in.

Reviewers: sammccall, jkorous

Subscribers: ilya-biryukov, MaskRay, dexonsmith, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80988
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/unittests/ParsedASTTests.cpp