mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 06:34:41 +01:00
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:
co-authored by
Jon Ross-Perkins
parent
41e357492b
commit
ea60e4f491
@@ -12,10 +12,12 @@ namespace Carbon {
|
||||
void AddPrelude(std::string_view prelude_file_name, Nonnull<Arena*> arena,
|
||||
std::vector<Nonnull<Declaration*>>* declarations,
|
||||
int* num_prelude_declarations) {
|
||||
ErrorOr<AST> parse_result = Parse(arena, prelude_file_name, false);
|
||||
ErrorOr<AST> parse_result =
|
||||
Parse(arena, prelude_file_name, FileKind::Prelude, false);
|
||||
if (!parse_result.ok()) {
|
||||
// Try again with tracing, to help diagnose the problem.
|
||||
ErrorOr<AST> trace_parse_result = Parse(arena, prelude_file_name, true);
|
||||
ErrorOr<AST> trace_parse_result =
|
||||
Parse(arena, prelude_file_name, FileKind::Prelude, true);
|
||||
CARBON_FATAL() << "Failed to parse prelude:\n"
|
||||
<< trace_parse_result.error();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user