mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-15 08:06:19 +00:00
tint/utils: Make Hashmap::Find() safer to use
Don't return a raw pointer to the map entry's value, instead return a new Reference which re-looks up the entry if the map is mutated. Change-Id: I031749785faeac98e2a129a776493cb0371a5cb9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110540 Reviewed-by: Antonio Maiorano <amaiorano@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
597ad53029
commit
7c6e229a18
@@ -3522,7 +3522,7 @@ bool FunctionEmitter::EmitStatementsInBasicBlock(const BlockInfo& block_info,
|
||||
const auto phi_id = assignment.phi_id;
|
||||
auto* const lhs_expr = builder_.Expr(namer_.Name(phi_id));
|
||||
// If RHS value is actually a phi we just cpatured, then use it.
|
||||
auto* const copy_sym = copied_phis.Find(assignment.value_id);
|
||||
auto copy_sym = copied_phis.Find(assignment.value_id);
|
||||
auto* const rhs_expr =
|
||||
copy_sym ? builder_.Expr(*copy_sym) : MakeExpression(assignment.value_id).expr;
|
||||
AddStatement(builder_.Assign(lhs_expr, rhs_expr));
|
||||
|
||||
@@ -666,7 +666,7 @@ class ParserImpl : Reader {
|
||||
/// @param id a SPIR-V ID
|
||||
/// @returns the AST variable or null.
|
||||
const ast::Var* GetModuleVariable(uint32_t id) {
|
||||
auto* entry = module_variable_.Find(id);
|
||||
auto entry = module_variable_.Find(id);
|
||||
return entry ? *entry : nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user