Resolver: Fix UB with nullptr method calls
Change-Id: Iaa098d7851ffaf01aac384fe623c94809948fe2e Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51182 Commit-Queue: Ben Clayton <bclayton@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com> Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
57b2a06ba7
commit
e9f5f63ea0
|
@ -501,14 +501,19 @@ Resolver::VariableInfo* Resolver::Variable(ast::Variable* var,
|
||||||
// TODO(crbug.com/tint/802): Temporary while ast::AccessControl exits.
|
// TODO(crbug.com/tint/802): Temporary while ast::AccessControl exits.
|
||||||
auto find_first_access_control =
|
auto find_first_access_control =
|
||||||
[this](ast::Type* ty) -> ast::AccessControl* {
|
[this](ast::Type* ty) -> ast::AccessControl* {
|
||||||
ast::AccessControl* ac = ty->As<ast::AccessControl>();
|
if (ty == nullptr) {
|
||||||
if (ac) {
|
return nullptr;
|
||||||
|
}
|
||||||
|
if (ast::AccessControl* ac = ty->As<ast::AccessControl>()) {
|
||||||
return ac;
|
return ac;
|
||||||
}
|
}
|
||||||
while (auto* tn = ty->As<ast::TypeName>()) {
|
while (auto* tn = ty->As<ast::TypeName>()) {
|
||||||
ty = name_to_ast_type_[tn->name()];
|
auto it = name_to_ast_type_.find(tn->name());
|
||||||
ac = ty->As<ast::AccessControl>();
|
if (it == name_to_ast_type_.end()) {
|
||||||
if (ac) {
|
break;
|
||||||
|
}
|
||||||
|
ty = it->second;
|
||||||
|
if (auto* ac = ty->As<ast::AccessControl>()) {
|
||||||
return ac;
|
return ac;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue