writer/[hlsl,msl]: Default `name_printed` to false
Addresses the review comment:
https://dawn-review.googlesource.com/c/tint/+/59302/4/src/writer/msl/generator_impl.cc#1932
Change-Id: I4cd6e0e626748328ca2bacc74aa9127cb224cf4a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59448
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc
index 5ba656a..a85a555 100644
--- a/src/writer/hlsl/generator_impl.cc
+++ b/src/writer/hlsl/generator_impl.cc
@@ -2912,6 +2912,9 @@
ast::Access access,
const std::string& name,
bool* name_printed /* = nullptr */) {
+ if (name_printed) {
+ *name_printed = false;
+ }
switch (storage_class) {
case ast::StorageClass::kStorage:
if (access != ast::Access::kRead) {
@@ -3091,11 +3094,11 @@
ast::StorageClass storage_class,
ast::Access access,
const std::string& name) {
- bool printed_name = false;
- if (!EmitType(out, type, storage_class, access, name, &printed_name)) {
+ bool name_printed = false;
+ if (!EmitType(out, type, storage_class, access, name, &name_printed)) {
return false;
}
- if (!name.empty() && !printed_name) {
+ if (!name.empty() && !name_printed) {
out << " " << name;
}
return true;
diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc
index f4efca4..f9cfe89 100644
--- a/src/writer/msl/generator_impl.cc
+++ b/src/writer/msl/generator_impl.cc
@@ -1930,6 +1930,9 @@
const sem::Type* type,
const std::string& name,
bool* name_printed /* = nullptr */) {
+ if (name_printed) {
+ *name_printed = false;
+ }
if (auto* atomic = type->As<sem::Atomic>()) {
if (atomic->Type()->Is<sem::I32>()) {
out << "atomic_int";
@@ -2000,12 +2003,12 @@
out << " ";
if (ptr->StoreType()->Is<sem::Array>()) {
std::string inner = "(*" + name + ")";
- if (name_printed) {
- *name_printed = true;
- }
if (!EmitType(out, ptr->StoreType(), inner)) {
return false;
}
+ if (name_printed) {
+ *name_printed = true;
+ }
} else {
if (!EmitType(out, ptr->StoreType(), "")) {
return false;