Skip to content

Commit

Permalink
git-clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
cdleary committed Aug 18, 2024
1 parent 5726be6 commit 0b1a69a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
19 changes: 12 additions & 7 deletions xls/dslx/type_system/deduce_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ using ColonRefSubjectT =

} // namespace

// Resolves a `TypeAlias` AST node to a `ColonRef` subject -- this requires us to
// traverse through aliases transitively to find a subject.
// Resolves a `TypeAlias` AST node to a `ColonRef` subject -- this requires us
// to traverse through aliases transitively to find a subject.
//
// Has to be an enum or builtin-type name, given the context we're in: looking
// for _values_ hanging off, e.g. in service of a `::` ref.
Expand Down Expand Up @@ -101,19 +101,23 @@ ResolveTypeAliasToDirectColonRefSubject(ImportData* import_data,
current_type_definition = type_ref_type->type_ref()->type_definition();
}

VLOG(5) << absl::StreamFormat("ResolveTypeDefToDirectColonRefSubject; arrived at type definition: `%s`", ToAstNode(current_type_definition)->ToString());
VLOG(5) << absl::StreamFormat(
"ResolveTypeDefToDirectColonRefSubject; arrived at type definition: `%s`",
ToAstNode(current_type_definition)->ToString());

if (std::holds_alternative<ColonRef*>(current_type_definition)) {
ColonRef* colon_ref = std::get<ColonRef*>(current_type_definition);
type_info = import_data->GetRootTypeInfo(colon_ref->owner()).value();
XLS_ASSIGN_OR_RETURN(ColonRefSubjectT subject, ResolveColonRefSubjectForTypeChecking(
import_data, type_info, colon_ref));
XLS_ASSIGN_OR_RETURN(ColonRefSubjectT subject,
ResolveColonRefSubjectForTypeChecking(
import_data, type_info, colon_ref));
XLS_RET_CHECK(std::holds_alternative<Module*>(subject));
Module* module = std::get<Module*>(subject);

// Grab the type definition being referred to by the `ColonRef` -- this is
// what we now have to traverse to (or we may have arrived).
XLS_ASSIGN_OR_RETURN(current_type_definition, module->GetTypeDefinition(colon_ref->attr()));
XLS_ASSIGN_OR_RETURN(current_type_definition,
module->GetTypeDefinition(colon_ref->attr()));

if (std::holds_alternative<TypeAlias*>(current_type_definition)) {
TypeAlias* new_alias = std::get<TypeAlias*>(current_type_definition);
Expand Down Expand Up @@ -338,7 +342,8 @@ absl::StatusOr<ColonRefSubjectT> ResolveColonRefSubjectForTypeChecking(
const ColonRef* colon_ref) {
XLS_RET_CHECK_EQ(colon_ref->owner(), type_info->module());

VLOG(5) << absl::StreamFormat("ResolveColonRefSubject for `%s`", colon_ref->ToString());
VLOG(5) << absl::StreamFormat("ResolveColonRefSubject for `%s`",
colon_ref->ToString());

// If the subject is a name reference we use a helper routine.
if (std::holds_alternative<NameRef*>(colon_ref->subject())) {
Expand Down
5 changes: 3 additions & 2 deletions xls/dslx/type_system/type_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,9 @@ void TypeInfo::AddImport(Import* import, Module* module, TypeInfo* type_info) {
}

std::optional<const ImportedInfo*> TypeInfo::GetImported(Import* import) const {
CHECK_EQ(import->owner(), module_)
<< absl::StreamFormat("Import node is owned by: `%s` vs this TypeInfo is for `%s`", import->owner()->name(), module_->name());
CHECK_EQ(import->owner(), module_) << absl::StreamFormat(
"Import node is owned by: `%s` vs this TypeInfo is for `%s`",
import->owner()->name(), module_->name());
auto* self = GetRoot();
auto it = self->imports_.find(import);
if (it == self->imports_.end()) {
Expand Down

0 comments on commit 0b1a69a

Please sign in to comment.