Track the file kind on SourceLocation rather than computing it from the file name. (#2999)

This will be more correct if a user file is named prelude.carbon, and
reduces the explorer runtime by about 10% by removing a string
comparison from the check for whether trace output is enabled.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
Richard Smith
2023-07-19 23:07:53 +00:00
committed by GitHub
co-authored by Jon Ross-Perkins
parent 41e357492b
commit ea60e4f491
29 changed files with 168 additions and 146 deletions
+3 -2
View File
@@ -23,8 +23,9 @@ fn Foo() {}
TEST(ParseTest, ParseFromString) {
Arena arena;
ErrorOr<AST> parse_result = ParseFromString(
&arena, "file.carbon", FileContents, /*parser_debug=*/false);
ErrorOr<AST> parse_result =
ParseFromString(&arena, "file.carbon", FileKind::Main, FileContents,
/*parser_debug=*/false);
ASSERT_TRUE(parse_result.ok());
EXPECT_EQ(parse_result->declarations.size(), 1);
}