mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-19 01:46:35 +00:00
Fix Undefined Behaviour
All caused by calling Castable::As<> on nullptr objects. Bug: tint:760 Change-Id: I0a408b3cd58086cfeab5a1af34d643f50f304948 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49523 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
30c03a5d50
commit
9481156eb9
@@ -627,8 +627,7 @@ Output DecomposeStorageAccess::Run(const Program* in, const DataMap&) {
|
||||
for (auto* node : ctx.src->ASTNodes().Objects()) {
|
||||
if (auto* ident = node->As<ast::IdentifierExpression>()) {
|
||||
// X
|
||||
auto* expr = sem.Get(ident);
|
||||
if (auto* var = expr->As<sem::VariableUser>()) {
|
||||
if (auto* var = sem.Get<sem::VariableUser>(ident)) {
|
||||
if (var->Variable()->StorageClass() == ast::StorageClass::kStorage) {
|
||||
// Variable to a storage buffer
|
||||
state.AddAccesss(ident, {
|
||||
|
||||
@@ -148,19 +148,22 @@ Output FirstIndexOffset::Run(const Program* in, const DataMap& data) {
|
||||
|
||||
// Fix up all references to the builtins with the offsets
|
||||
ctx.ReplaceAll([=, &ctx](ast::Expression* expr) -> ast::Expression* {
|
||||
auto* sem = ctx.src->Sem().Get(expr);
|
||||
if (auto* user = sem->As<sem::VariableUser>()) {
|
||||
auto it = builtin_vars.find(user->Variable());
|
||||
if (it != builtin_vars.end()) {
|
||||
return ctx.dst->Add(ctx.CloneWithoutTransform(expr),
|
||||
ctx.dst->MemberAccessor(buffer_name, it->second));
|
||||
if (auto* sem = ctx.src->Sem().Get(expr)) {
|
||||
if (auto* user = sem->As<sem::VariableUser>()) {
|
||||
auto it = builtin_vars.find(user->Variable());
|
||||
if (it != builtin_vars.end()) {
|
||||
return ctx.dst->Add(
|
||||
ctx.CloneWithoutTransform(expr),
|
||||
ctx.dst->MemberAccessor(buffer_name, it->second));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (auto* access = sem->As<sem::StructMemberAccess>()) {
|
||||
auto it = builtin_members.find(access->Member());
|
||||
if (it != builtin_members.end()) {
|
||||
return ctx.dst->Add(ctx.CloneWithoutTransform(expr),
|
||||
ctx.dst->MemberAccessor(buffer_name, it->second));
|
||||
if (auto* access = sem->As<sem::StructMemberAccess>()) {
|
||||
auto it = builtin_members.find(access->Member());
|
||||
if (it != builtin_members.end()) {
|
||||
return ctx.dst->Add(
|
||||
ctx.CloneWithoutTransform(expr),
|
||||
ctx.dst->MemberAccessor(buffer_name, it->second));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Not interested in this experssion. Just clone.
|
||||
|
||||
Reference in New Issue
Block a user