diff --git a/src/ast/access_decoration.h b/src/ast/access_decoration.h index dcf2d950e2..e58c13a228 100644 --- a/src/ast/access_decoration.h +++ b/src/ast/access_decoration.h @@ -49,7 +49,7 @@ class AccessDecoration : public Castable { AccessDecoration* Clone(CloneContext* ctx) const override; private: - AccessControl value_ = ast::AccessControl::kReadWrite; + AccessControl const value_; }; } // namespace ast diff --git a/src/ast/array_accessor_expression.h b/src/ast/array_accessor_expression.h index d35c20a172..ebcf9c63c0 100644 --- a/src/ast/array_accessor_expression.h +++ b/src/ast/array_accessor_expression.h @@ -64,8 +64,8 @@ class ArrayAccessorExpression private: ArrayAccessorExpression(const ArrayAccessorExpression&) = delete; - Expression* array_ = nullptr; - Expression* idx_expr_ = nullptr; + Expression* const array_; + Expression* const idx_expr_; }; } // namespace ast diff --git a/src/ast/assignment_statement.h b/src/ast/assignment_statement.h index a91b0000ae..01b5ac5265 100644 --- a/src/ast/assignment_statement.h +++ b/src/ast/assignment_statement.h @@ -61,8 +61,8 @@ class AssignmentStatement : public Castable { private: AssignmentStatement(const AssignmentStatement&) = delete; - Expression* lhs_ = nullptr; - Expression* rhs_ = nullptr; + Expression* const lhs_; + Expression* const rhs_; }; } // namespace ast diff --git a/src/ast/binary_expression.h b/src/ast/binary_expression.h index 8283a5dbda..9bce5489e5 100644 --- a/src/ast/binary_expression.h +++ b/src/ast/binary_expression.h @@ -127,9 +127,9 @@ class BinaryExpression : public Castable { private: BinaryExpression(const BinaryExpression&) = delete; - BinaryOp op_ = BinaryOp::kNone; - Expression* lhs_ = nullptr; - Expression* rhs_ = nullptr; + BinaryOp const op_; + Expression* const lhs_; + Expression* const rhs_; }; inline std::ostream& operator<<(std::ostream& out, BinaryOp op) { diff --git a/src/ast/binding_decoration.h b/src/ast/binding_decoration.h index ae4cc4504a..e4d73e3698 100644 --- a/src/ast/binding_decoration.h +++ b/src/ast/binding_decoration.h @@ -49,7 +49,7 @@ class BindingDecoration BindingDecoration* Clone(CloneContext* ctx) const override; private: - uint32_t value_; + uint32_t const value_; }; } // namespace ast diff --git a/src/ast/bitcast_expression.h b/src/ast/bitcast_expression.h index 5ef92b3fc3..ccee67edf2 100644 --- a/src/ast/bitcast_expression.h +++ b/src/ast/bitcast_expression.h @@ -61,8 +61,8 @@ class BitcastExpression : public Castable { private: BitcastExpression(const BitcastExpression&) = delete; - type::Type* type_ = nullptr; - Expression* expr_ = nullptr; + type::Type* const type_; + Expression* const expr_; }; } // namespace ast diff --git a/src/ast/block_statement.h b/src/ast/block_statement.h index d485bdf7a6..08e4b066bf 100644 --- a/src/ast/block_statement.h +++ b/src/ast/block_statement.h @@ -83,7 +83,7 @@ class BlockStatement : public Castable { private: BlockStatement(const BlockStatement&) = delete; - StatementList statements_; + StatementList const statements_; }; } // namespace ast diff --git a/src/ast/bool_literal.h b/src/ast/bool_literal.h index 1b984f5f2d..2896913d33 100644 --- a/src/ast/bool_literal.h +++ b/src/ast/bool_literal.h @@ -52,7 +52,7 @@ class BoolLiteral : public Castable { BoolLiteral* Clone(CloneContext* ctx) const override; private: - bool value_; + bool const value_; }; } // namespace ast diff --git a/src/ast/builtin_decoration.h b/src/ast/builtin_decoration.h index 5a1419bee3..7c437d50e4 100644 --- a/src/ast/builtin_decoration.h +++ b/src/ast/builtin_decoration.h @@ -48,7 +48,7 @@ class BuiltinDecoration BuiltinDecoration* Clone(CloneContext* ctx) const override; private: - Builtin builtin_ = Builtin::kNone; + Builtin const builtin_; }; } // namespace ast diff --git a/src/ast/call_expression.h b/src/ast/call_expression.h index c5547e90d9..d52ab4e5d7 100644 --- a/src/ast/call_expression.h +++ b/src/ast/call_expression.h @@ -60,8 +60,8 @@ class CallExpression : public Castable { private: CallExpression(const CallExpression&) = delete; - Expression* func_ = nullptr; - ExpressionList params_; + Expression* const func_; + ExpressionList const params_; }; } // namespace ast diff --git a/src/ast/call_statement.h b/src/ast/call_statement.h index 59f7bed14b..c8aa837010 100644 --- a/src/ast/call_statement.h +++ b/src/ast/call_statement.h @@ -57,7 +57,7 @@ class CallStatement : public Castable { private: CallStatement(const CallStatement&) = delete; - CallExpression* call_ = nullptr; + CallExpression* const call_; }; } // namespace ast diff --git a/src/ast/case_statement.h b/src/ast/case_statement.h index c9c424e8b8..b7933422cb 100644 --- a/src/ast/case_statement.h +++ b/src/ast/case_statement.h @@ -73,8 +73,8 @@ class CaseStatement : public Castable { private: CaseStatement(const CaseStatement&) = delete; - CaseSelectorList selectors_; - BlockStatement* body_ = nullptr; + CaseSelectorList const selectors_; + BlockStatement* const body_; }; /// A list of case statements diff --git a/src/ast/constant_id_decoration.h b/src/ast/constant_id_decoration.h index bb990ae254..0d2b407769 100644 --- a/src/ast/constant_id_decoration.h +++ b/src/ast/constant_id_decoration.h @@ -48,7 +48,7 @@ class ConstantIdDecoration ConstantIdDecoration* Clone(CloneContext* ctx) const override; private: - uint32_t value_ = 0; + uint32_t const value_; }; } // namespace ast diff --git a/src/ast/else_statement.h b/src/ast/else_statement.h index 646672028d..7b08fa53ed 100644 --- a/src/ast/else_statement.h +++ b/src/ast/else_statement.h @@ -69,8 +69,8 @@ class ElseStatement : public Castable { private: ElseStatement(const ElseStatement&) = delete; - Expression* condition_ = nullptr; - BlockStatement* body_ = nullptr; + Expression* const condition_; + BlockStatement* const body_; }; /// A list of else statements diff --git a/src/ast/expression.h b/src/ast/expression.h index 5809d2e912..12e038cfa5 100644 --- a/src/ast/expression.h +++ b/src/ast/expression.h @@ -52,7 +52,7 @@ class Expression : public Castable { private: Expression(const Expression&) = delete; - type::Type* result_type_ = nullptr; + type::Type* result_type_ = nullptr; // Semantic info }; /// A list of expressions diff --git a/src/ast/float_literal.h b/src/ast/float_literal.h index ad33124932..bbf58f838d 100644 --- a/src/ast/float_literal.h +++ b/src/ast/float_literal.h @@ -50,7 +50,7 @@ class FloatLiteral : public Castable { FloatLiteral* Clone(CloneContext* ctx) const override; private: - float value_; + float const value_; }; } // namespace ast diff --git a/src/ast/function.h b/src/ast/function.h index 14b6789376..4f22016b2a 100644 --- a/src/ast/function.h +++ b/src/ast/function.h @@ -202,15 +202,16 @@ class Function : public Castable { const std::vector> ReferencedSampledTextureVariablesImpl(bool multisampled) const; - Symbol symbol_; - std::string name_; - VariableList params_; - type::Type* return_type_ = nullptr; - BlockStatement* body_ = nullptr; - std::vector referenced_module_vars_; - std::vector local_referenced_module_vars_; - std::vector ancestor_entry_points_; - FunctionDecorationList decorations_; + Symbol const symbol_; + std::string const name_; + VariableList const params_; + type::Type* const return_type_; + BlockStatement* const body_; + + std::vector referenced_module_vars_; // Semantic info + std::vector local_referenced_module_vars_; // Semantic info + std::vector ancestor_entry_points_; // Semantic info + FunctionDecorationList decorations_; // Semantic info }; /// A list of functions diff --git a/src/ast/identifier_expression.h b/src/ast/identifier_expression.h index 40750daaad..b30c4cc282 100644 --- a/src/ast/identifier_expression.h +++ b/src/ast/identifier_expression.h @@ -83,10 +83,11 @@ class IdentifierExpression : public Castable { private: IdentifierExpression(const IdentifierExpression&) = delete; - Intrinsic intrinsic_ = Intrinsic::kNone; - std::unique_ptr intrinsic_sig_; - Symbol sym_; - std::string name_; + Symbol const sym_; + std::string const name_; + + Intrinsic intrinsic_ = Intrinsic::kNone; // Semantic info + std::unique_ptr intrinsic_sig_; // Semantic info }; } // namespace ast diff --git a/src/ast/if_statement.h b/src/ast/if_statement.h index f489c4a930..11515abd57 100644 --- a/src/ast/if_statement.h +++ b/src/ast/if_statement.h @@ -51,8 +51,6 @@ class IfStatement : public Castable { /// @returns the else statements const ElseStatementList& else_statements() const { return else_statements_; } - /// @returns the else statements - ElseStatementList& else_statements() { return else_statements_; } /// @returns true if there are else statements bool has_else_statements() const { return !else_statements_.empty(); } @@ -76,9 +74,9 @@ class IfStatement : public Castable { private: IfStatement(const IfStatement&) = delete; - Expression* condition_ = nullptr; - BlockStatement* body_ = nullptr; - ElseStatementList else_statements_; + Expression* const condition_; + BlockStatement* const body_; + ElseStatementList const else_statements_; }; } // namespace ast diff --git a/src/ast/literal.h b/src/ast/literal.h index dea8a63563..f5127ef11a 100644 --- a/src/ast/literal.h +++ b/src/ast/literal.h @@ -52,7 +52,7 @@ class Literal : public Castable { explicit Literal(const Source& source, type::Type* type); private: - type::Type* type_ = nullptr; + type::Type* const type_; }; } // namespace ast diff --git a/src/ast/location_decoration.h b/src/ast/location_decoration.h index f6583ea326..fc2496369d 100644 --- a/src/ast/location_decoration.h +++ b/src/ast/location_decoration.h @@ -49,7 +49,7 @@ class LocationDecoration LocationDecoration* Clone(CloneContext* ctx) const override; private: - uint32_t value_; + uint32_t const value_; }; } // namespace ast diff --git a/src/ast/loop_statement.h b/src/ast/loop_statement.h index 6eb4b392b8..e80eb943b2 100644 --- a/src/ast/loop_statement.h +++ b/src/ast/loop_statement.h @@ -71,8 +71,8 @@ class LoopStatement : public Castable { private: LoopStatement(const LoopStatement&) = delete; - BlockStatement* body_ = nullptr; - BlockStatement* continuing_ = nullptr; + BlockStatement* const body_; + BlockStatement* const continuing_; }; } // namespace ast diff --git a/src/ast/member_accessor_expression.h b/src/ast/member_accessor_expression.h index 982fc66c3d..d9aef791e9 100644 --- a/src/ast/member_accessor_expression.h +++ b/src/ast/member_accessor_expression.h @@ -64,8 +64,8 @@ class MemberAccessorExpression private: MemberAccessorExpression(const MemberAccessorExpression&) = delete; - Expression* struct_ = nullptr; - IdentifierExpression* member_ = nullptr; + Expression* const struct_; + IdentifierExpression* const member_; }; } // namespace ast diff --git a/src/ast/node.h b/src/ast/node.h index b4f6120ef0..b3d5cdee28 100644 --- a/src/ast/node.h +++ b/src/ast/node.h @@ -75,7 +75,7 @@ class Node : public Castable { private: Node(const Node&) = delete; - Source source_; + Source const source_; }; } // namespace ast diff --git a/src/ast/return_statement.cc b/src/ast/return_statement.cc index 3583138bbe..93f9b4fb88 100644 --- a/src/ast/return_statement.cc +++ b/src/ast/return_statement.cc @@ -22,7 +22,8 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::ReturnStatement); namespace tint { namespace ast { -ReturnStatement::ReturnStatement(const Source& source) : Base(source) {} +ReturnStatement::ReturnStatement(const Source& source) + : Base(source), value_(nullptr) {} ReturnStatement::ReturnStatement(const Source& source, Expression* value) : Base(source), value_(value) {} diff --git a/src/ast/return_statement.h b/src/ast/return_statement.h index 8b00e2a000..5a56ba6a55 100644 --- a/src/ast/return_statement.h +++ b/src/ast/return_statement.h @@ -62,7 +62,7 @@ class ReturnStatement : public Castable { private: ReturnStatement(const ReturnStatement&) = delete; - Expression* value_ = nullptr; + Expression* const value_; }; } // namespace ast diff --git a/src/ast/scalar_constructor_expression.h b/src/ast/scalar_constructor_expression.h index ee7e835f02..5c96ef9b3a 100644 --- a/src/ast/scalar_constructor_expression.h +++ b/src/ast/scalar_constructor_expression.h @@ -58,7 +58,7 @@ class ScalarConstructorExpression private: ScalarConstructorExpression(const ScalarConstructorExpression&) = delete; - Literal* literal_ = nullptr; + Literal* const literal_; }; } // namespace ast diff --git a/src/ast/set_decoration.h b/src/ast/set_decoration.h index 1ea07b2041..ec97a32535 100644 --- a/src/ast/set_decoration.h +++ b/src/ast/set_decoration.h @@ -48,7 +48,7 @@ class SetDecoration : public Castable { SetDecoration* Clone(CloneContext* ctx) const override; private: - uint32_t value_; + uint32_t const value_; }; } // namespace ast diff --git a/src/ast/sint_literal.h b/src/ast/sint_literal.h index cf4ac57730..2df717df91 100644 --- a/src/ast/sint_literal.h +++ b/src/ast/sint_literal.h @@ -50,7 +50,7 @@ class SintLiteral : public Castable { SintLiteral* Clone(CloneContext* ctx) const override; private: - int32_t value_; + int32_t const value_; }; } // namespace ast diff --git a/src/ast/stage_decoration.h b/src/ast/stage_decoration.h index a8ee49ff5f..4208c7da16 100644 --- a/src/ast/stage_decoration.h +++ b/src/ast/stage_decoration.h @@ -47,7 +47,7 @@ class StageDecoration : public Castable { StageDecoration* Clone(CloneContext* ctx) const override; private: - PipelineStage stage_ = PipelineStage::kNone; + PipelineStage const stage_; }; } // namespace ast diff --git a/src/ast/stride_decoration.h b/src/ast/stride_decoration.h index dc8997826e..ad9977833d 100644 --- a/src/ast/stride_decoration.h +++ b/src/ast/stride_decoration.h @@ -48,7 +48,7 @@ class StrideDecoration : public Castable { StrideDecoration* Clone(CloneContext* ctx) const override; private: - uint32_t stride_; + uint32_t const stride_; }; } // namespace ast diff --git a/src/ast/struct.h b/src/ast/struct.h index 36e78ba5fb..260bfb6e5f 100644 --- a/src/ast/struct.h +++ b/src/ast/struct.h @@ -74,8 +74,8 @@ class Struct : public Castable { private: Struct(const Struct&) = delete; - StructMemberList members_; - StructDecorationList decorations_; + StructMemberList const members_; + StructDecorationList const decorations_; }; } // namespace ast diff --git a/src/ast/struct_member.h b/src/ast/struct_member.h index 73470b6e04..fb72fb1023 100644 --- a/src/ast/struct_member.h +++ b/src/ast/struct_member.h @@ -77,9 +77,9 @@ class StructMember : public Castable { private: StructMember(const StructMember&) = delete; - std::string name_; - type::Type* type_ = nullptr; - StructMemberDecorationList decorations_; + std::string const name_; + type::Type* const type_; + StructMemberDecorationList const decorations_; }; /// A list of struct members diff --git a/src/ast/struct_member_offset_decoration.h b/src/ast/struct_member_offset_decoration.h index 001d777ff8..445483b891 100644 --- a/src/ast/struct_member_offset_decoration.h +++ b/src/ast/struct_member_offset_decoration.h @@ -49,7 +49,7 @@ class StructMemberOffsetDecoration StructMemberOffsetDecoration* Clone(CloneContext* ctx) const override; private: - uint32_t offset_; + uint32_t const offset_; }; } // namespace ast diff --git a/src/ast/switch_statement.h b/src/ast/switch_statement.h index 917d6aada8..b964724746 100644 --- a/src/ast/switch_statement.h +++ b/src/ast/switch_statement.h @@ -45,8 +45,6 @@ class SwitchStatement : public Castable { /// @returns true if this is a default statement bool IsDefault() const { return condition_ == nullptr; } - /// @returns the Switch body - CaseStatementList& body() { return body_; } /// @returns the Switch body const CaseStatementList& body() const { return body_; } @@ -69,8 +67,8 @@ class SwitchStatement : public Castable { private: SwitchStatement(const SwitchStatement&) = delete; - Expression* condition_ = nullptr; - CaseStatementList body_; + Expression* const condition_; + CaseStatementList const body_; }; } // namespace ast diff --git a/src/ast/type/access_control_type.h b/src/ast/type/access_control_type.h index bffd44e6f0..e018b95a9b 100644 --- a/src/ast/type/access_control_type.h +++ b/src/ast/type/access_control_type.h @@ -66,8 +66,8 @@ class AccessControl : public Castable { AccessControl* Clone(CloneContext* ctx) const override; private: - ast::AccessControl access_ = ast::AccessControl::kReadOnly; - Type* subtype_ = nullptr; + ast::AccessControl const access_; + Type* const subtype_; }; } // namespace type diff --git a/src/ast/type/alias_type.h b/src/ast/type/alias_type.h index 2fcd45c30a..d90a99eba6 100644 --- a/src/ast/type/alias_type.h +++ b/src/ast/type/alias_type.h @@ -63,9 +63,9 @@ class Alias : public Castable { Alias* Clone(CloneContext* ctx) const override; private: - Symbol symbol_; - std::string name_; - Type* subtype_ = nullptr; + Symbol const symbol_; + std::string const name_; + Type* const subtype_; }; } // namespace type diff --git a/src/ast/type/array_type.h b/src/ast/type/array_type.h index a120a46d77..eafb2048e8 100644 --- a/src/ast/type/array_type.h +++ b/src/ast/type/array_type.h @@ -76,9 +76,9 @@ class Array : public Castable { Array* Clone(CloneContext* ctx) const override; private: - Type* subtype_ = nullptr; - uint32_t size_ = 0; - ArrayDecorationList decos_; + Type* const subtype_; + uint32_t const size_; + ArrayDecorationList const decos_; }; } // namespace type diff --git a/src/ast/type/matrix_type.h b/src/ast/type/matrix_type.h index ef39c1ac89..500f43eb83 100644 --- a/src/ast/type/matrix_type.h +++ b/src/ast/type/matrix_type.h @@ -61,9 +61,9 @@ class Matrix : public Castable { Matrix* Clone(CloneContext* ctx) const override; private: - Type* subtype_ = nullptr; - uint32_t rows_ = 2; - uint32_t columns_ = 2; + Type* const subtype_; + uint32_t const rows_; + uint32_t const columns_; }; } // namespace type diff --git a/src/ast/type/multisampled_texture_type.h b/src/ast/type/multisampled_texture_type.h index cdbfdb4776..4fb45e2577 100644 --- a/src/ast/type/multisampled_texture_type.h +++ b/src/ast/type/multisampled_texture_type.h @@ -46,7 +46,7 @@ class MultisampledTexture : public Castable { MultisampledTexture* Clone(CloneContext* ctx) const override; private: - Type* type_ = nullptr; + Type* const type_; }; } // namespace type diff --git a/src/ast/type/pointer_type.h b/src/ast/type/pointer_type.h index b22b130521..7a9a61b4c8 100644 --- a/src/ast/type/pointer_type.h +++ b/src/ast/type/pointer_type.h @@ -50,8 +50,8 @@ class Pointer : public Castable { Pointer* Clone(CloneContext* ctx) const override; private: - Type* subtype_; - StorageClass storage_class_; + Type* const subtype_; + StorageClass const storage_class_; }; } // namespace type diff --git a/src/ast/type/sampled_texture_type.h b/src/ast/type/sampled_texture_type.h index 54d9da4b42..cdc93fa6bb 100644 --- a/src/ast/type/sampled_texture_type.h +++ b/src/ast/type/sampled_texture_type.h @@ -46,7 +46,7 @@ class SampledTexture : public Castable { SampledTexture* Clone(CloneContext* ctx) const override; private: - Type* type_ = nullptr; + Type* const type_; }; } // namespace type diff --git a/src/ast/type/sampler_type.h b/src/ast/type/sampler_type.h index 4e71fbbc34..28a60e8faf 100644 --- a/src/ast/type/sampler_type.h +++ b/src/ast/type/sampler_type.h @@ -58,7 +58,7 @@ class Sampler : public Castable { Sampler* Clone(CloneContext* ctx) const override; private: - SamplerKind kind_ = SamplerKind::kSampler; + SamplerKind const kind_; }; } // namespace type diff --git a/src/ast/type/storage_texture_type.h b/src/ast/type/storage_texture_type.h index 9f88b4d825..33e18159b5 100644 --- a/src/ast/type/storage_texture_type.h +++ b/src/ast/type/storage_texture_type.h @@ -101,9 +101,10 @@ class StorageTexture : public Castable { StorageTexture* Clone(CloneContext* ctx) const override; private: - Type* type_ = nullptr; - ast::AccessControl access_ = ast::AccessControl::kReadOnly; - ImageFormat image_format_ = ImageFormat::kRgba32Float; + ast::AccessControl const access_; + ImageFormat const image_format_; + + Type* type_ = nullptr; // Semantic info }; } // namespace type diff --git a/src/ast/type/struct_type.h b/src/ast/type/struct_type.h index d372c1c129..d1a939c4ac 100644 --- a/src/ast/type/struct_type.h +++ b/src/ast/type/struct_type.h @@ -68,9 +68,9 @@ class Struct : public Castable { Struct* Clone(CloneContext* ctx) const override; private: - Symbol symbol_; - std::string name_; - ast::Struct* struct_ = nullptr; + Symbol const symbol_; + std::string const name_; + ast::Struct* const struct_; uint64_t LargestMemberBaseAlignment(MemoryLayout mem_layout) const; }; diff --git a/src/ast/type/texture_type.h b/src/ast/type/texture_type.h index ccac6de667..88af3fa3ef 100644 --- a/src/ast/type/texture_type.h +++ b/src/ast/type/texture_type.h @@ -56,7 +56,7 @@ class Texture : public Castable { TextureDimension dim() const { return dim_; } private: - TextureDimension dim_ = TextureDimension::k1d; + TextureDimension const dim_; }; } // namespace type diff --git a/src/ast/type/vector_type.h b/src/ast/type/vector_type.h index 9634f43232..4228c59a06 100644 --- a/src/ast/type/vector_type.h +++ b/src/ast/type/vector_type.h @@ -58,8 +58,8 @@ class Vector : public Castable { Vector* Clone(CloneContext* ctx) const override; private: - Type* subtype_ = nullptr; - uint32_t size_ = 2; + Type* const subtype_; + uint32_t const size_; }; } // namespace type diff --git a/src/ast/type_constructor_expression.h b/src/ast/type_constructor_expression.h index 3863adca60..66f45b1d29 100644 --- a/src/ast/type_constructor_expression.h +++ b/src/ast/type_constructor_expression.h @@ -63,8 +63,8 @@ class TypeConstructorExpression private: TypeConstructorExpression(const TypeConstructorExpression&) = delete; - type::Type* type_ = nullptr; - ExpressionList values_; + type::Type* const type_; + ExpressionList const values_; }; } // namespace ast diff --git a/src/ast/uint_literal.h b/src/ast/uint_literal.h index 9010b6d593..3464a88d0d 100644 --- a/src/ast/uint_literal.h +++ b/src/ast/uint_literal.h @@ -50,7 +50,7 @@ class UintLiteral : public Castable { UintLiteral* Clone(CloneContext* ctx) const override; private: - uint32_t value_; + uint32_t const value_; }; } // namespace ast diff --git a/src/ast/unary_op_expression.h b/src/ast/unary_op_expression.h index 5ec3dcf5a0..0a9d352643 100644 --- a/src/ast/unary_op_expression.h +++ b/src/ast/unary_op_expression.h @@ -61,8 +61,8 @@ class UnaryOpExpression : public Castable { private: UnaryOpExpression(const UnaryOpExpression&) = delete; - UnaryOp op_ = UnaryOp::kNegation; - Expression* expr_ = nullptr; + UnaryOp const op_; + Expression* const expr_; }; } // namespace ast diff --git a/src/ast/variable.cc b/src/ast/variable.cc index e31b02e2f1..c94a97d6b5 100644 --- a/src/ast/variable.cc +++ b/src/ast/variable.cc @@ -34,11 +34,11 @@ Variable::Variable(const Source& source, VariableDecorationList decorations) : Base(source), name_(name), - storage_class_(sc), type_(type), is_const_(is_const), constructor_(constructor), - decorations_(std::move(decorations)) {} + decorations_(std::move(decorations)), + storage_class_(sc) {} Variable::Variable(Variable&&) = default; diff --git a/src/ast/variable.h b/src/ast/variable.h index b15d222aff..bf8c1db837 100644 --- a/src/ast/variable.h +++ b/src/ast/variable.h @@ -162,13 +162,14 @@ class Variable : public Castable { private: Variable(const Variable&) = delete; - std::string name_; - StorageClass storage_class_ = StorageClass::kNone; + std::string const name_; // The value type if a const or formal paramter, and the store type if a var - type::Type* type_ = nullptr; - bool is_const_ = false; - Expression* constructor_ = nullptr; - VariableDecorationList decorations_; + type::Type* const type_; + bool const is_const_; + Expression* const constructor_; + VariableDecorationList const decorations_; + + StorageClass storage_class_ = StorageClass::kNone; // Semantic info }; /// A list of variables diff --git a/src/ast/variable_decl_statement.h b/src/ast/variable_decl_statement.h index 88bef800c4..bc2bed7622 100644 --- a/src/ast/variable_decl_statement.h +++ b/src/ast/variable_decl_statement.h @@ -59,7 +59,7 @@ class VariableDeclStatement private: VariableDeclStatement(const VariableDeclStatement&) = delete; - Variable* variable_ = nullptr; + Variable* const variable_; }; } // namespace ast diff --git a/src/ast/workgroup_decoration.cc b/src/ast/workgroup_decoration.cc index 63fdf20b89..1e0e5d0b36 100644 --- a/src/ast/workgroup_decoration.cc +++ b/src/ast/workgroup_decoration.cc @@ -23,12 +23,12 @@ namespace tint { namespace ast { WorkgroupDecoration::WorkgroupDecoration(const Source& source, uint32_t x) - : Base(source), x_(x) {} + : WorkgroupDecoration(source, x, 1, 1) {} WorkgroupDecoration::WorkgroupDecoration(const Source& source, uint32_t x, uint32_t y) - : Base(source), x_(x), y_(y) {} + : WorkgroupDecoration(source, x, y, 1) {} WorkgroupDecoration::WorkgroupDecoration(const Source& source, uint32_t x, diff --git a/src/ast/workgroup_decoration.h b/src/ast/workgroup_decoration.h index 9946108620..d39421513d 100644 --- a/src/ast/workgroup_decoration.h +++ b/src/ast/workgroup_decoration.h @@ -64,9 +64,9 @@ class WorkgroupDecoration WorkgroupDecoration* Clone(CloneContext* ctx) const override; private: - uint32_t x_ = 1; - uint32_t y_ = 1; - uint32_t z_ = 1; + uint32_t const x_; + uint32_t const y_; + uint32_t const z_; }; } // namespace ast