Split Semantics into Check and SemIR namespaces (#3138)

Splits IR files into SemIR, and logic files into Check. These will be
split into separate directories as part of a later move; the namespaces
are being done first in order to vet the switch, and hopefully make
conflicts a little easier to manage due to the substantial renames.

A lot of this is just automated removal of Semantics prefixes from
names, adding namespace references where needed. A few special-cases
are:

- SemanticsIR -> SemIR::File
- A few things were discussed, like Unit, CompileUnit, or CompiledUnit.
Unit was too vague for chandlerc, and I thought CompileUnit might lead
to incorrect inferences (CompilationUnit would be more precise, but
typically written as SemIR::CompilationUnit which is pretty long). File
seemed to be a short name that we could agree on.
- SemanticsIRFormatter -> SemIR::Formatter
- FormatSemanticsIR -> SemIR::FormatFile
- SemanticsFileTest -> CheckFileTest
- It remains in the Testing namespace, where just "FileTest" might be
too broad a name.
- SemanticsDeclarationNameStack::Context ->
Check::DeclarationNameStack::NameContext
  - This avoids a Check::Context name shadowing.

Changes check_internal.h to include ostream.h to improve finding of
Print/operator<< (otherwise it didn't compile).

This is part of #3070
This commit is contained in:
Jon Ross-Perkins
2023-08-23 22:51:23 +00:00
committed by GitHub
parent b2db2ca7cf
commit 67da700dd5
53 changed files with 1337 additions and 1466 deletions
+4 -4
View File
@@ -438,9 +438,9 @@ auto Driver::Compile(const CompileOptions& options) -> bool {
return !has_errors;
}
const SemanticsIR builtin_ir = SemanticsIR::MakeBuiltinIR();
const SemIR::File builtin_ir = SemIR::File::MakeBuiltinIR();
CARBON_VLOG() << "*** SemanticsIR::MakeFromParseTree ***\n";
const SemanticsIR semantics_ir = SemanticsIR::MakeFromParseTree(
const SemIR::File semantics_ir = SemIR::File::MakeFromParseTree(
builtin_ir, tokenized_source, parse_tree, *consumer, vlog_stream_);
// We've finished all steps that can produce diagnostics. Emit the
@@ -449,7 +449,7 @@ auto Driver::Compile(const CompileOptions& options) -> bool {
consumer->Flush();
has_errors |= semantics_ir.has_errors();
CARBON_VLOG() << "*** SemanticsIR::MakeFromParseTree done ***\n";
CARBON_VLOG() << "*** SemIR::File::MakeFromParseTree done ***\n";
if (options.dump_raw_semantics_ir) {
semantics_ir.Print(output_stream_, options.builtin_semantics_ir);
if (options.dump_semantics_ir) {
@@ -458,7 +458,7 @@ auto Driver::Compile(const CompileOptions& options) -> bool {
}
if (options.dump_semantics_ir) {
consumer->Flush();
FormatSemanticsIR(tokenized_source, parse_tree, semantics_ir,
SemIR::FormatFile(tokenized_source, parse_tree, semantics_ir,
output_stream_);
}
CARBON_VLOG() << "semantics_ir: " << semantics_ir;