[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 11:34:40 +0000 (13:34 +0200)
commitbff0c56ff92106afad22b54a90e1c612da4d6f99
tree448d9a83694596d70c4f97c62f3061c70c410ed2
parent4e8e5d60b46ea80fa66316164820c6bf781b6ee3
[clangd] Copy existing includes in ReplayPreamble

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.
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/unittests/ParsedASTTests.cpp