mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
Add Source to sem::Struct
This CL adds a Source to the sem::Struct. The uses of struct->Declaration()->source now use the source stored directly on the struct. Bug: tint:1718 Change-Id: I860c67764f85d98b3f655247e18f93fa0fef9436 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/112447 Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
8954189545
commit
f745e4e2bf
@@ -151,7 +151,7 @@ TEST_F(ResolverInferredTypeTest, InferStruct_Pass) {
|
||||
auto* str = Structure("S", utils::Vector{member});
|
||||
|
||||
auto* expected_type =
|
||||
create<sem::Struct>(str, str->name,
|
||||
create<sem::Struct>(str, str->source, str->name,
|
||||
sem::StructMemberList{create<sem::StructMember>(
|
||||
member, member->source, member->symbol, create<sem::I32>(), 0u, 0u,
|
||||
0u, 4u, std::nullopt)},
|
||||
|
||||
@@ -823,6 +823,7 @@ sem::Struct* build_struct(ProgramBuilder& b,
|
||||
uint32_t size_with_padding = utils::RoundUp(max_align, offset);
|
||||
return b.create<sem::Struct>(
|
||||
/* declaration */ nullptr,
|
||||
/* source */ Source{},
|
||||
/* name */ b.Sym(name),
|
||||
/* members */ members,
|
||||
/* align */ max_align,
|
||||
|
||||
@@ -3299,7 +3299,7 @@ sem::Struct* Resolver::Structure(const ast::Struct* str) {
|
||||
}
|
||||
|
||||
auto* out = builder_->create<sem::Struct>(
|
||||
str, str->name, sem_members, static_cast<uint32_t>(struct_align),
|
||||
str, str->source, str->name, sem_members, static_cast<uint32_t>(struct_align),
|
||||
static_cast<uint32_t>(struct_size), static_cast<uint32_t>(size_no_padding));
|
||||
|
||||
for (size_t i = 0; i < sem_members.size(); i++) {
|
||||
|
||||
@@ -446,8 +446,7 @@ bool Validator::AddressSpaceLayout(const sem::Type* store_ty,
|
||||
|
||||
// Recurse into the member type.
|
||||
if (!AddressSpaceLayout(m->Type(), address_space, m->Declaration()->type->source)) {
|
||||
AddNote("see layout of struct:\n" + str->Layout(symbols_),
|
||||
str->Declaration()->source);
|
||||
AddNote("see layout of struct:\n" + str->Layout(symbols_), str->Source());
|
||||
note_usage();
|
||||
return false;
|
||||
}
|
||||
@@ -463,12 +462,11 @@ bool Validator::AddressSpaceLayout(const sem::Type* store_ty,
|
||||
std::to_string(required_align) + ") on this member",
|
||||
m->Source());
|
||||
|
||||
AddNote("see layout of struct:\n" + str->Layout(symbols_),
|
||||
str->Declaration()->source);
|
||||
AddNote("see layout of struct:\n" + str->Layout(symbols_), str->Source());
|
||||
|
||||
if (auto* member_str = m->Type()->As<sem::Struct>()) {
|
||||
AddNote("and layout of struct member:\n" + member_str->Layout(symbols_),
|
||||
member_str->Declaration()->source);
|
||||
member_str->Source());
|
||||
}
|
||||
|
||||
note_usage();
|
||||
@@ -490,13 +488,12 @@ bool Validator::AddressSpaceLayout(const sem::Type* store_ty,
|
||||
"'. Consider setting @align(16) on this member",
|
||||
m->Source());
|
||||
|
||||
AddNote("see layout of struct:\n" + str->Layout(symbols_),
|
||||
str->Declaration()->source);
|
||||
AddNote("see layout of struct:\n" + str->Layout(symbols_), str->Source());
|
||||
|
||||
auto* prev_member_str = prev_member->Type()->As<sem::Struct>();
|
||||
AddNote("and layout of previous member struct:\n" +
|
||||
prev_member_str->Layout(symbols_),
|
||||
prev_member_str->Declaration()->source);
|
||||
prev_member_str->Source());
|
||||
note_usage();
|
||||
return false;
|
||||
}
|
||||
@@ -2017,7 +2014,7 @@ bool Validator::Alias(const ast::Alias*) const {
|
||||
|
||||
bool Validator::Structure(const sem::Struct* str, ast::PipelineStage stage) const {
|
||||
if (str->Members().empty()) {
|
||||
AddError("structures must have at least one member", str->Declaration()->source);
|
||||
AddError("structures must have at least one member", str->Source());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user