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
+4 -2
View File
@@ -11,6 +11,7 @@
#include "common/check.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/StringExtras.h"
#include "toolchain/base/value_store.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/null_diagnostics.h"
#include "toolchain/lex/token_kind.h"
@@ -374,14 +375,14 @@ class LexerBenchHelper {
auto Lex() -> TokenizedBuffer {
DiagnosticConsumer& consumer = NullDiagnosticConsumer();
return TokenizedBuffer::Lex(source_, consumer);
return TokenizedBuffer::Lex(value_stores_, source_, consumer);
}
auto DiagnoseErrors() -> std::string {
std::string result;
llvm::raw_string_ostream out(result);
StreamDiagnosticConsumer consumer(out);
auto buffer = TokenizedBuffer::Lex(source_, consumer);
auto buffer = TokenizedBuffer::Lex(value_stores_, source_, consumer);
consumer.Flush();
CARBON_CHECK(buffer.has_errors())
<< "Asked to diagnose errors but none found!";
@@ -398,6 +399,7 @@ class LexerBenchHelper {
fs_, filename_, ConsoleDiagnosticConsumer()));
}
SharedValueStores value_stores_;
llvm::vfs::InMemoryFileSystem fs_;
std::string filename_ = "test.carbon";
SourceBuffer source_;