Add value store to be shared across compile stages. (#3311)

This updates lexing to use the data. I'll do checking separately, just
to split changes.

Note the ValueStore structure is also set up such that SemIR::File can
use it for other fields.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
Jon Ross-Perkins
2023-10-20 15:00:53 +00:00
committed by GitHub
co-authored by Richard Smith
parent 629c63c7d1
commit d13f76e001
26 changed files with 389 additions and 227 deletions
+3 -1
View File
@@ -89,13 +89,15 @@ static auto getName(Parse::Tree& p, Parse::Node node)
void LanguageServer::OnDocumentSymbol(
clang::clangd::DocumentSymbolParams const& params,
clang::clangd::Callback<std::vector<clang::clangd::DocumentSymbol>> cb) {
SharedValueStores value_stores;
llvm::vfs::InMemoryFileSystem vfs;
auto file = params.textDocument.uri.file().str();
vfs.addFile(file, /*mtime=*/0,
llvm::MemoryBuffer::getMemBufferCopy(files_.at(file)));
auto buf = SourceBuffer::CreateFromFile(vfs, file, NullDiagnosticConsumer());
auto lexed = Lex::TokenizedBuffer::Lex(*buf, NullDiagnosticConsumer());
auto lexed =
Lex::TokenizedBuffer::Lex(value_stores, *buf, NullDiagnosticConsumer());
auto parsed = Parse::Tree::Parse(lexed, NullDiagnosticConsumer(), nullptr);
std::vector<clang::clangd::DocumentSymbol> result;
for (const auto& node : parsed.postorder()) {