diff --git a/BUILD.gn b/BUILD.gn index 18beefc4eb..a5b3291db0 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -258,8 +258,6 @@ source_set("libtint_core_src") { "src/ast/call_statement.h", "src/ast/case_statement.cc", "src/ast/case_statement.h", - "src/ast/clone_context.cc", - "src/ast/clone_context.h", "src/ast/constant_id_decoration.cc", "src/ast/constant_id_decoration.h", "src/ast/constructor_expression.cc", @@ -336,7 +334,6 @@ source_set("libtint_core_src") { "src/ast/struct_member_offset_decoration.h", "src/ast/switch_statement.cc", "src/ast/switch_statement.h", - "src/ast/traits.h", "src/ast/type_constructor_expression.cc", "src/ast/type_constructor_expression.h", "src/ast/type_decoration.cc", @@ -358,6 +355,8 @@ source_set("libtint_core_src") { "src/block_allocator.h", "src/castable.cc", "src/castable.h", + "src/clone_context.cc", + "src/clone_context.h", "src/demangler.cc", "src/demangler.h", "src/diagnostic/diagnostic.cc", @@ -383,6 +382,7 @@ source_set("libtint_core_src") { "src/symbol.h", "src/symbol_table.cc", "src/symbol_table.h", + "src/traits.h", "src/transform/bound_array_accessors.cc", "src/transform/bound_array_accessors.h", "src/transform/emit_vertex_point_size.cc", @@ -771,7 +771,6 @@ source_set("tint_unittests_core_src") { "src/ast/call_expression_test.cc", "src/ast/call_statement_test.cc", "src/ast/case_statement_test.cc", - "src/ast/clone_context_test.cc", "src/ast/constant_id_decoration_test.cc", "src/ast/continue_statement_test.cc", "src/ast/decoration_test.cc", @@ -803,7 +802,6 @@ source_set("tint_unittests_core_src") { "src/ast/struct_test.cc", "src/ast/switch_statement_test.cc", "src/ast/test_helper.h", - "src/ast/traits_test.cc", "src/ast/type_constructor_expression_test.cc", "src/ast/uint_literal_test.cc", "src/ast/unary_op_expression_test.cc", @@ -812,6 +810,7 @@ source_set("tint_unittests_core_src") { "src/ast/workgroup_decoration_test.cc", "src/block_allocator_test.cc", "src/castable_test.cc", + "src/clone_context_test.cc", "src/demangler_test.cc", "src/diagnostic/formatter_test.cc", "src/diagnostic/printer_test.cc", @@ -820,6 +819,7 @@ source_set("tint_unittests_core_src") { "src/scope_stack_test.cc", "src/symbol_table_test.cc", "src/symbol_test.cc", + "src/traits_test.cc", "src/transform/bound_array_accessors_test.cc", "src/transform/emit_vertex_point_size_test.cc", "src/transform/first_index_offset_test.cc", diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b7c4fa5c3d..c3aa242d96 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -72,8 +72,6 @@ set(TINT_LIB_SRCS ast/call_statement.h ast/case_statement.cc ast/case_statement.h - ast/clone_context.cc - ast/clone_context.h ast/constant_id_decoration.cc ast/constant_id_decoration.h ast/constructor_expression.cc @@ -150,7 +148,6 @@ set(TINT_LIB_SRCS ast/struct_member_offset_decoration.h ast/switch_statement.cc ast/switch_statement.h - ast/traits.h ast/type_constructor_expression.cc ast/type_constructor_expression.h ast/type_decoration.cc @@ -172,6 +169,8 @@ set(TINT_LIB_SRCS block_allocator.h castable.cc castable.h + clone_context.cc + clone_context.h demangler.cc demangler.h; diagnostic/diagnostic.cc @@ -197,6 +196,7 @@ set(TINT_LIB_SRCS symbol.h symbol_table.cc symbol_table.h + traits.h transform/emit_vertex_point_size.cc transform/emit_vertex_point_size.h transform/bound_array_accessors.cc @@ -401,7 +401,6 @@ if(${TINT_BUILD_TESTS}) ast/call_expression_test.cc ast/call_statement_test.cc ast/case_statement_test.cc - ast/clone_context_test.cc ast/constant_id_decoration_test.cc ast/continue_statement_test.cc ast/decoration_test.cc @@ -433,7 +432,6 @@ if(${TINT_BUILD_TESTS}) ast/struct_test.cc ast/switch_statement_test.cc ast/test_helper.h - ast/traits_test.cc ast/type_constructor_expression_test.cc ast/uint_literal_test.cc ast/unary_op_expression_test.cc @@ -442,6 +440,7 @@ if(${TINT_BUILD_TESTS}) ast/workgroup_decoration_test.cc block_allocator_test.cc castable_test.cc + clone_context_test.cc demangler_test.cc diagnostic/formatter_test.cc diagnostic/printer_test.cc @@ -450,6 +449,7 @@ if(${TINT_BUILD_TESTS}) scope_stack_test.cc symbol_table_test.cc symbol_test.cc + traits_test.cc type_determiner_test.cc type/access_control_type_test.cc type/alias_type_test.cc diff --git a/src/ast/access_decoration.cc b/src/ast/access_decoration.cc index 2346357741..50d35a90d4 100644 --- a/src/ast/access_decoration.cc +++ b/src/ast/access_decoration.cc @@ -14,8 +14,8 @@ #include "src/ast/access_decoration.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::AccessDecoration); diff --git a/src/ast/array_accessor_expression.cc b/src/ast/array_accessor_expression.cc index 82cfd2bf8b..7fd6d2e9dc 100644 --- a/src/ast/array_accessor_expression.cc +++ b/src/ast/array_accessor_expression.cc @@ -14,8 +14,8 @@ #include "src/ast/array_accessor_expression.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::ArrayAccessorExpression); diff --git a/src/ast/assignment_statement.cc b/src/ast/assignment_statement.cc index 4561263fda..896b2068ec 100644 --- a/src/ast/assignment_statement.cc +++ b/src/ast/assignment_statement.cc @@ -14,8 +14,8 @@ #include "src/ast/assignment_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::AssignmentStatement); diff --git a/src/ast/binary_expression.cc b/src/ast/binary_expression.cc index e8566fd66c..8851a62ff3 100644 --- a/src/ast/binary_expression.cc +++ b/src/ast/binary_expression.cc @@ -14,8 +14,8 @@ #include "src/ast/binary_expression.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::BinaryExpression); diff --git a/src/ast/binding_decoration.cc b/src/ast/binding_decoration.cc index 13d48d73ce..febb26413e 100644 --- a/src/ast/binding_decoration.cc +++ b/src/ast/binding_decoration.cc @@ -14,8 +14,8 @@ #include "src/ast/binding_decoration.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::BindingDecoration); diff --git a/src/ast/bitcast_expression.cc b/src/ast/bitcast_expression.cc index 4dc5eb371c..be772ba9ef 100644 --- a/src/ast/bitcast_expression.cc +++ b/src/ast/bitcast_expression.cc @@ -14,8 +14,8 @@ #include "src/ast/bitcast_expression.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::BitcastExpression); diff --git a/src/ast/block_statement.cc b/src/ast/block_statement.cc index cbaa0a6593..a9efd64c6b 100644 --- a/src/ast/block_statement.cc +++ b/src/ast/block_statement.cc @@ -14,8 +14,8 @@ #include "src/ast/block_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::BlockStatement); diff --git a/src/ast/bool_literal.cc b/src/ast/bool_literal.cc index c21d87fde8..43b5281372 100644 --- a/src/ast/bool_literal.cc +++ b/src/ast/bool_literal.cc @@ -14,8 +14,8 @@ #include "src/ast/bool_literal.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::BoolLiteral); diff --git a/src/ast/break_statement.cc b/src/ast/break_statement.cc index eba613e401..4951304221 100644 --- a/src/ast/break_statement.cc +++ b/src/ast/break_statement.cc @@ -14,8 +14,8 @@ #include "src/ast/break_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::BreakStatement); diff --git a/src/ast/builtin_decoration.cc b/src/ast/builtin_decoration.cc index d7abdbee45..ffeb76b739 100644 --- a/src/ast/builtin_decoration.cc +++ b/src/ast/builtin_decoration.cc @@ -14,8 +14,8 @@ #include "src/ast/builtin_decoration.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::BuiltinDecoration); diff --git a/src/ast/call_expression.cc b/src/ast/call_expression.cc index 5a45fdf984..ce332670d9 100644 --- a/src/ast/call_expression.cc +++ b/src/ast/call_expression.cc @@ -14,8 +14,8 @@ #include "src/ast/call_expression.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::CallExpression); diff --git a/src/ast/call_statement.cc b/src/ast/call_statement.cc index 43670f78fe..7e0c5e9c09 100644 --- a/src/ast/call_statement.cc +++ b/src/ast/call_statement.cc @@ -15,8 +15,8 @@ #include "src/ast/call_statement.h" #include "src/ast/call_expression.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::CallStatement); diff --git a/src/ast/case_statement.cc b/src/ast/case_statement.cc index 181a26341c..7ad253dced 100644 --- a/src/ast/case_statement.cc +++ b/src/ast/case_statement.cc @@ -14,8 +14,8 @@ #include "src/ast/case_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::CaseStatement); diff --git a/src/ast/constant_id_decoration.cc b/src/ast/constant_id_decoration.cc index 840a30d38e..5dc415677d 100644 --- a/src/ast/constant_id_decoration.cc +++ b/src/ast/constant_id_decoration.cc @@ -14,8 +14,8 @@ #include "src/ast/constant_id_decoration.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::ConstantIdDecoration); diff --git a/src/ast/continue_statement.cc b/src/ast/continue_statement.cc index 4d1597bbd0..00b8f818c0 100644 --- a/src/ast/continue_statement.cc +++ b/src/ast/continue_statement.cc @@ -14,8 +14,8 @@ #include "src/ast/continue_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::ContinueStatement); diff --git a/src/ast/discard_statement.cc b/src/ast/discard_statement.cc index cab164c94b..01a364fbc5 100644 --- a/src/ast/discard_statement.cc +++ b/src/ast/discard_statement.cc @@ -14,8 +14,8 @@ #include "src/ast/discard_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::DiscardStatement); diff --git a/src/ast/else_statement.cc b/src/ast/else_statement.cc index 6a1a0147f5..7b44308401 100644 --- a/src/ast/else_statement.cc +++ b/src/ast/else_statement.cc @@ -14,8 +14,8 @@ #include "src/ast/else_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::ElseStatement); diff --git a/src/ast/fallthrough_statement.cc b/src/ast/fallthrough_statement.cc index db51488d8e..46bb30fca4 100644 --- a/src/ast/fallthrough_statement.cc +++ b/src/ast/fallthrough_statement.cc @@ -14,8 +14,8 @@ #include "src/ast/fallthrough_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::FallthroughStatement); diff --git a/src/ast/float_literal.cc b/src/ast/float_literal.cc index 5ce4347ca5..b7154079b6 100644 --- a/src/ast/float_literal.cc +++ b/src/ast/float_literal.cc @@ -17,8 +17,8 @@ #include #include -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::FloatLiteral); diff --git a/src/ast/function.cc b/src/ast/function.cc index 47863ca0aa..88b5b96269 100644 --- a/src/ast/function.cc +++ b/src/ast/function.cc @@ -16,11 +16,11 @@ #include -#include "src/ast/clone_context.h" #include "src/ast/module.h" #include "src/ast/stage_decoration.h" #include "src/ast/variable.h" #include "src/ast/workgroup_decoration.h" +#include "src/clone_context.h" #include "src/type/multisampled_texture_type.h" #include "src/type/sampled_texture_type.h" #include "src/type/texture_type.h" diff --git a/src/ast/group_decoration.cc b/src/ast/group_decoration.cc index 3bbd372856..c60ec4847d 100644 --- a/src/ast/group_decoration.cc +++ b/src/ast/group_decoration.cc @@ -14,8 +14,8 @@ #include "src/ast/group_decoration.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::GroupDecoration); diff --git a/src/ast/identifier_expression.cc b/src/ast/identifier_expression.cc index 9d6bafeb71..cd79099743 100644 --- a/src/ast/identifier_expression.cc +++ b/src/ast/identifier_expression.cc @@ -14,8 +14,8 @@ #include "src/ast/identifier_expression.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::IdentifierExpression); diff --git a/src/ast/if_statement.cc b/src/ast/if_statement.cc index aac56a89c2..0c3fcc5121 100644 --- a/src/ast/if_statement.cc +++ b/src/ast/if_statement.cc @@ -14,9 +14,9 @@ #include "src/ast/if_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/else_statement.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::IfStatement); diff --git a/src/ast/location_decoration.cc b/src/ast/location_decoration.cc index db28f0a1fe..e660e13763 100644 --- a/src/ast/location_decoration.cc +++ b/src/ast/location_decoration.cc @@ -14,8 +14,8 @@ #include "src/ast/location_decoration.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::LocationDecoration); diff --git a/src/ast/loop_statement.cc b/src/ast/loop_statement.cc index 9549cc0df5..e58476f012 100644 --- a/src/ast/loop_statement.cc +++ b/src/ast/loop_statement.cc @@ -14,8 +14,8 @@ #include "src/ast/loop_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::LoopStatement); diff --git a/src/ast/member_accessor_expression.cc b/src/ast/member_accessor_expression.cc index 6b60b35659..a75df0087a 100644 --- a/src/ast/member_accessor_expression.cc +++ b/src/ast/member_accessor_expression.cc @@ -14,8 +14,8 @@ #include "src/ast/member_accessor_expression.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::MemberAccessorExpression); diff --git a/src/ast/module.cc b/src/ast/module.cc index 3561263488..e439a8d53e 100644 --- a/src/ast/module.cc +++ b/src/ast/module.cc @@ -16,7 +16,7 @@ #include -#include "src/ast/clone_context.h" +#include "src/clone_context.h" #include "src/type/struct_type.h" namespace tint { diff --git a/src/ast/module.h b/src/ast/module.h index 76ed92e089..59858f9640 100644 --- a/src/ast/module.h +++ b/src/ast/module.h @@ -24,10 +24,10 @@ #include #include "src/ast/function.h" -#include "src/ast/traits.h" #include "src/ast/variable.h" #include "src/block_allocator.h" #include "src/symbol_table.h" +#include "src/traits.h" #include "src/type/alias_type.h" #include "src/type/type_manager.h" diff --git a/src/ast/node.h b/src/ast/node.h index 87e2ee9fee..924ffd13ad 100644 --- a/src/ast/node.h +++ b/src/ast/node.h @@ -23,13 +23,16 @@ #include "src/source.h" namespace tint { + +// Forward declarations +class CloneContext; namespace type { class Type; } + namespace ast { class Module; -class CloneContext; /// AST base class node class Node : public Castable { diff --git a/src/ast/null_literal.cc b/src/ast/null_literal.cc index 9b654a3000..61f4cf5f86 100644 --- a/src/ast/null_literal.cc +++ b/src/ast/null_literal.cc @@ -14,8 +14,8 @@ #include "src/ast/null_literal.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::NullLiteral); diff --git a/src/ast/return_statement.cc b/src/ast/return_statement.cc index 93f9b4fb88..94eb8c804a 100644 --- a/src/ast/return_statement.cc +++ b/src/ast/return_statement.cc @@ -14,8 +14,8 @@ #include "src/ast/return_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::ReturnStatement); diff --git a/src/ast/scalar_constructor_expression.cc b/src/ast/scalar_constructor_expression.cc index 7a1e5ff6b1..ed26446d90 100644 --- a/src/ast/scalar_constructor_expression.cc +++ b/src/ast/scalar_constructor_expression.cc @@ -14,8 +14,8 @@ #include "src/ast/scalar_constructor_expression.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::ScalarConstructorExpression); diff --git a/src/ast/sint_literal.cc b/src/ast/sint_literal.cc index 52b8b0eed8..3b1aa0bc6f 100644 --- a/src/ast/sint_literal.cc +++ b/src/ast/sint_literal.cc @@ -14,8 +14,8 @@ #include "src/ast/sint_literal.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::SintLiteral); diff --git a/src/ast/stage_decoration.cc b/src/ast/stage_decoration.cc index 50525f3e14..786e86e217 100644 --- a/src/ast/stage_decoration.cc +++ b/src/ast/stage_decoration.cc @@ -14,8 +14,8 @@ #include "src/ast/stage_decoration.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::StageDecoration); diff --git a/src/ast/stride_decoration.cc b/src/ast/stride_decoration.cc index 9e42cd750c..9d86e29c3a 100644 --- a/src/ast/stride_decoration.cc +++ b/src/ast/stride_decoration.cc @@ -14,8 +14,8 @@ #include "src/ast/stride_decoration.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::StrideDecoration); diff --git a/src/ast/struct.cc b/src/ast/struct.cc index 1cf1c38be4..146a9efea7 100644 --- a/src/ast/struct.cc +++ b/src/ast/struct.cc @@ -14,9 +14,9 @@ #include "src/ast/struct.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" #include "src/ast/struct_block_decoration.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::Struct); diff --git a/src/ast/struct_block_decoration.cc b/src/ast/struct_block_decoration.cc index 58f18bddd3..4dab8c1be2 100644 --- a/src/ast/struct_block_decoration.cc +++ b/src/ast/struct_block_decoration.cc @@ -14,8 +14,8 @@ #include "src/ast/struct_block_decoration.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::StructBlockDecoration); diff --git a/src/ast/struct_member.cc b/src/ast/struct_member.cc index a387cc03d5..aa64980708 100644 --- a/src/ast/struct_member.cc +++ b/src/ast/struct_member.cc @@ -14,9 +14,9 @@ #include "src/ast/struct_member.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" #include "src/ast/struct_member_offset_decoration.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::StructMember); diff --git a/src/ast/struct_member_offset_decoration.cc b/src/ast/struct_member_offset_decoration.cc index 4c3af19446..16608a754b 100644 --- a/src/ast/struct_member_offset_decoration.cc +++ b/src/ast/struct_member_offset_decoration.cc @@ -14,8 +14,8 @@ #include "src/ast/struct_member_offset_decoration.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::StructMemberOffsetDecoration); diff --git a/src/ast/switch_statement.cc b/src/ast/switch_statement.cc index 51cc0bfad7..a542548d40 100644 --- a/src/ast/switch_statement.cc +++ b/src/ast/switch_statement.cc @@ -15,8 +15,8 @@ #include "src/ast/switch_statement.h" #include "src/ast/case_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::SwitchStatement); diff --git a/src/ast/type_constructor_expression.cc b/src/ast/type_constructor_expression.cc index e704de0163..75f336d4ed 100644 --- a/src/ast/type_constructor_expression.cc +++ b/src/ast/type_constructor_expression.cc @@ -14,8 +14,8 @@ #include "src/ast/type_constructor_expression.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::TypeConstructorExpression); diff --git a/src/ast/uint_literal.cc b/src/ast/uint_literal.cc index c30a60822a..84d18def2a 100644 --- a/src/ast/uint_literal.cc +++ b/src/ast/uint_literal.cc @@ -14,8 +14,8 @@ #include "src/ast/uint_literal.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::UintLiteral); diff --git a/src/ast/unary_op_expression.cc b/src/ast/unary_op_expression.cc index a472ff9380..79042ad91e 100644 --- a/src/ast/unary_op_expression.cc +++ b/src/ast/unary_op_expression.cc @@ -14,8 +14,8 @@ #include "src/ast/unary_op_expression.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::UnaryOpExpression); diff --git a/src/ast/variable.cc b/src/ast/variable.cc index e053ffddae..0d5c3e5ee1 100644 --- a/src/ast/variable.cc +++ b/src/ast/variable.cc @@ -16,9 +16,9 @@ #include -#include "src/ast/clone_context.h" #include "src/ast/constant_id_decoration.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::Variable); diff --git a/src/ast/variable_decl_statement.cc b/src/ast/variable_decl_statement.cc index f5eb50f451..b9d99861b1 100644 --- a/src/ast/variable_decl_statement.cc +++ b/src/ast/variable_decl_statement.cc @@ -14,8 +14,8 @@ #include "src/ast/variable_decl_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::VariableDeclStatement); diff --git a/src/ast/workgroup_decoration.cc b/src/ast/workgroup_decoration.cc index 1e0e5d0b36..1c82475c54 100644 --- a/src/ast/workgroup_decoration.cc +++ b/src/ast/workgroup_decoration.cc @@ -14,8 +14,8 @@ #include "src/ast/workgroup_decoration.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::ast::WorkgroupDecoration); diff --git a/src/ast/clone_context.cc b/src/clone_context.cc similarity index 87% rename from src/ast/clone_context.cc rename to src/clone_context.cc index fe9e849425..2244411364 100644 --- a/src/ast/clone_context.cc +++ b/src/clone_context.cc @@ -12,14 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/ast/clone_context.h" +#include "src/clone_context.h" #include "src/ast/module.h" namespace tint { -namespace ast { -CloneContext::CloneContext(Module* to, Module const* from) +CloneContext::CloneContext(ast::Module* to, ast::Module const* from) : mod(to), src(from) {} CloneContext::~CloneContext() = default; @@ -31,5 +30,4 @@ void CloneContext::Clone() { src->Clone(this); } -} // namespace ast } // namespace tint diff --git a/src/ast/clone_context.h b/src/clone_context.h similarity index 96% rename from src/ast/clone_context.h rename to src/clone_context.h index 64a7b11b88..103127c64b 100644 --- a/src/ast/clone_context.h +++ b/src/clone_context.h @@ -12,22 +12,24 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_AST_CLONE_CONTEXT_H_ -#define SRC_AST_CLONE_CONTEXT_H_ +#ifndef SRC_CLONE_CONTEXT_H_ +#define SRC_CLONE_CONTEXT_H_ #include #include #include -#include "src/ast/traits.h" #include "src/castable.h" #include "src/source.h" #include "src/symbol.h" +#include "src/traits.h" namespace tint { -namespace ast { +// Forward declarations +namespace ast { class Module; +} // namespace ast /// CloneContext holds the state used while cloning AST nodes and types. class CloneContext { @@ -35,7 +37,7 @@ class CloneContext { /// Constructor /// @param to the target module to clone into /// @param from the source module to clone from - CloneContext(Module* to, Module const* from); + CloneContext(ast::Module* to, ast::Module const* from); /// Destructor ~CloneContext(); @@ -149,10 +151,10 @@ class CloneContext { void Clone(); /// The target module to clone into. - Module* const mod; + ast::Module* const mod; /// The source module to clone from. - Module const* const src; + ast::Module const* const src; private: using Transform = std::function; @@ -187,7 +189,6 @@ class CloneContext { std::vector transforms_; }; -} // namespace ast } // namespace tint -#endif // SRC_AST_CLONE_CONTEXT_H_ +#endif // SRC_CLONE_CONTEXT_H_ diff --git a/src/ast/clone_context_test.cc b/src/clone_context_test.cc similarity index 96% rename from src/ast/clone_context_test.cc rename to src/clone_context_test.cc index d8890a2c95..a3718a3d00 100644 --- a/src/ast/clone_context_test.cc +++ b/src/clone_context_test.cc @@ -12,17 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/ast/clone_context.h" +#include "src/clone_context.h" #include "gtest/gtest.h" #include "src/ast/module.h" namespace tint { -namespace ast { namespace { -struct Cloneable : public Castable { +struct Cloneable : public Castable { Cloneable() : Base(Source{}) {} Cloneable* a = nullptr; @@ -162,10 +161,9 @@ TEST(CloneContext, CloneWithReplacements) { } } // namespace -} // namespace ast -TINT_INSTANTIATE_CLASS_ID(ast::Cloneable); -TINT_INSTANTIATE_CLASS_ID(ast::Replaceable); -TINT_INSTANTIATE_CLASS_ID(ast::Replacement); +TINT_INSTANTIATE_CLASS_ID(Cloneable); +TINT_INSTANTIATE_CLASS_ID(Replaceable); +TINT_INSTANTIATE_CLASS_ID(Replacement); } // namespace tint diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index a18127f800..00d75455aa 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -705,7 +705,7 @@ DefInfo::~DefInfo() = default; bool StatementBuilder::IsValid() const { return true; } -ast::Node* StatementBuilder::Clone(ast::CloneContext*) const { +ast::Node* StatementBuilder::Clone(CloneContext*) const { return nullptr; } void StatementBuilder::to_str(std::ostream& out, size_t indent) const { diff --git a/src/reader/spirv/function.h b/src/reader/spirv/function.h index 6ea6e367d3..b2206fd141 100644 --- a/src/reader/spirv/function.h +++ b/src/reader/spirv/function.h @@ -350,7 +350,7 @@ class StatementBuilder : public Castable { private: bool IsValid() const override; - Node* Clone(ast::CloneContext*) const override; + Node* Clone(CloneContext*) const override; void to_str(std::ostream& out, size_t indent) const override; }; diff --git a/src/ast/traits.h b/src/traits.h similarity index 95% rename from src/ast/traits.h rename to src/traits.h index 7e27036106..3601cbc21e 100644 --- a/src/ast/traits.h +++ b/src/traits.h @@ -12,14 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_AST_TRAITS_H_ -#define SRC_AST_TRAITS_H_ +#ifndef SRC_TRAITS_H_ +#define SRC_TRAITS_H_ #include #include namespace tint { -namespace ast { namespace traits { /// NthTypeOf returns the `N`th type in `Types` @@ -72,7 +71,6 @@ using EnableIfIsType = typename std::enable_if::value, T>::type; } // namespace traits -} // namespace ast } // namespace tint -#endif // SRC_AST_TRAITS_H_ +#endif // SRC_TRAITS_H_ diff --git a/src/ast/traits_test.cc b/src/traits_test.cc similarity index 98% rename from src/ast/traits_test.cc rename to src/traits_test.cc index 66218271e4..8ce565c177 100644 --- a/src/ast/traits_test.cc +++ b/src/traits_test.cc @@ -12,14 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/ast/traits.h" +#include "src/traits.h" #include #include "gtest/gtest.h" namespace tint { -namespace ast { namespace traits { namespace { @@ -101,5 +100,4 @@ TEST(ParamType, Lambda) { } } // namespace traits -} // namespace ast } // namespace tint diff --git a/src/transform/bound_array_accessors.cc b/src/transform/bound_array_accessors.cc index bdfb9384d3..0c2c290c76 100644 --- a/src/transform/bound_array_accessors.cc +++ b/src/transform/bound_array_accessors.cc @@ -27,7 +27,6 @@ #include "src/ast/call_expression.h" #include "src/ast/call_statement.h" #include "src/ast/case_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/continue_statement.h" #include "src/ast/discard_statement.h" #include "src/ast/else_statement.h" @@ -44,6 +43,7 @@ #include "src/ast/unary_op_expression.h" #include "src/ast/variable.h" #include "src/ast/variable_decl_statement.h" +#include "src/clone_context.h" #include "src/type/array_type.h" #include "src/type/matrix_type.h" #include "src/type/u32_type.h" @@ -57,18 +57,17 @@ BoundArrayAccessors::~BoundArrayAccessors() = default; Transform::Output BoundArrayAccessors::Run(ast::Module* in) { Output out; - ast::CloneContext(&out.module, in) - .ReplaceAll( - [&](ast::CloneContext* ctx, ast::ArrayAccessorExpression* expr) { - return Transform(expr, ctx, &out.diagnostics); - }) + CloneContext(&out.module, in) + .ReplaceAll([&](CloneContext* ctx, ast::ArrayAccessorExpression* expr) { + return Transform(expr, ctx, &out.diagnostics); + }) .Clone(); return out; } ast::ArrayAccessorExpression* BoundArrayAccessors::Transform( ast::ArrayAccessorExpression* expr, - ast::CloneContext* ctx, + CloneContext* ctx, diag::List* diags) { auto* ret_type = expr->array()->result_type()->UnwrapAll(); if (!ret_type->Is() && !ret_type->Is() && diff --git a/src/transform/bound_array_accessors.h b/src/transform/bound_array_accessors.h index bfb75462bf..0d78df171b 100644 --- a/src/transform/bound_array_accessors.h +++ b/src/transform/bound_array_accessors.h @@ -48,7 +48,7 @@ class BoundArrayAccessors : public Transform { private: ast::ArrayAccessorExpression* Transform(ast::ArrayAccessorExpression* expr, - ast::CloneContext* ctx, + CloneContext* ctx, diag::List* diags); }; diff --git a/src/transform/emit_vertex_point_size.cc b/src/transform/emit_vertex_point_size.cc index a46a958553..dd2acf0487 100644 --- a/src/transform/emit_vertex_point_size.cc +++ b/src/transform/emit_vertex_point_size.cc @@ -19,11 +19,11 @@ #include "src/ast/assignment_statement.h" #include "src/ast/block_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/float_literal.h" #include "src/ast/identifier_expression.h" #include "src/ast/scalar_constructor_expression.h" #include "src/ast/variable.h" +#include "src/clone_context.h" #include "src/type/f32_type.h" #include "src/type/type_manager.h" @@ -73,9 +73,9 @@ Transform::Output EmitVertexPointSize::Run(ast::Module* in) { Source{}, pointsize_ident, one); // Add the pointsize assignment statement to the front of all vertex stages. - ast::CloneContext(&out.module, in) + CloneContext(&out.module, in) .ReplaceAll( - [&](ast::CloneContext* ctx, ast::Function* func) -> ast::Function* { + [&](CloneContext* ctx, ast::Function* func) -> ast::Function* { if (func->pipeline_stage() != ast::PipelineStage::kVertex) { return nullptr; // Just clone func } diff --git a/src/transform/first_index_offset.cc b/src/transform/first_index_offset.cc index df878ac343..2d74c11c7a 100644 --- a/src/transform/first_index_offset.cc +++ b/src/transform/first_index_offset.cc @@ -25,7 +25,6 @@ #include "src/ast/builtin_decoration.h" #include "src/ast/call_statement.h" #include "src/ast/case_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/constructor_expression.h" #include "src/ast/else_statement.h" #include "src/ast/expression.h" @@ -47,6 +46,7 @@ #include "src/ast/variable.h" #include "src/ast/variable_decl_statement.h" #include "src/ast/variable_decoration.h" +#include "src/clone_context.h" #include "src/type/struct_type.h" #include "src/type/u32_type.h" #include "src/type_determiner.h" @@ -61,7 +61,7 @@ constexpr char kFirstVertexName[] = "tint_first_vertex_index"; constexpr char kFirstInstanceName[] = "tint_first_instance_index"; constexpr char kIndexOffsetPrefix[] = "tint_first_index_offset_"; -ast::Variable* clone_variable_with_new_name(ast::CloneContext* ctx, +ast::Variable* clone_variable_with_new_name(CloneContext* ctx, ast::Variable* in, std::string new_name) { return ctx->mod->create( @@ -126,33 +126,32 @@ Transform::Output FirstIndexOffset::Run(ast::Module* in) { // these builtins. Output out; - ast::CloneContext(&out.module, in) - .ReplaceAll( - [&](ast::CloneContext* ctx, ast::Variable* var) -> ast::Variable* { - for (ast::VariableDecoration* dec : var->decorations()) { - if (auto* blt_dec = dec->As()) { - ast::Builtin blt_type = blt_dec->value(); - if (blt_type == ast::Builtin::kVertexIndex) { - vertex_index_sym = var->symbol(); - has_vertex_index_ = true; - return clone_variable_with_new_name( - ctx, var, - kIndexOffsetPrefix + in->SymbolToName(var->symbol())); - } else if (blt_type == ast::Builtin::kInstanceIndex) { - instance_index_sym = var->symbol(); - has_instance_index_ = true; - return clone_variable_with_new_name( - ctx, var, - kIndexOffsetPrefix + in->SymbolToName(var->symbol())); - } - } + CloneContext(&out.module, in) + .ReplaceAll([&](CloneContext* ctx, ast::Variable* var) -> ast::Variable* { + for (ast::VariableDecoration* dec : var->decorations()) { + if (auto* blt_dec = dec->As()) { + ast::Builtin blt_type = blt_dec->value(); + if (blt_type == ast::Builtin::kVertexIndex) { + vertex_index_sym = var->symbol(); + has_vertex_index_ = true; + return clone_variable_with_new_name( + ctx, var, + kIndexOffsetPrefix + in->SymbolToName(var->symbol())); + } else if (blt_type == ast::Builtin::kInstanceIndex) { + instance_index_sym = var->symbol(); + has_instance_index_ = true; + return clone_variable_with_new_name( + ctx, var, + kIndexOffsetPrefix + in->SymbolToName(var->symbol())); } - return nullptr; // Just clone var - }) + } + } + return nullptr; // Just clone var + }) .ReplaceAll( // Note: This happens in the same pass as the rename above // which determines the original builtin variable names, // but this should be fine, as variables are cloned first. - [&](ast::CloneContext* ctx, ast::Function* func) -> ast::Function* { + [&](CloneContext* ctx, ast::Function* func) -> ast::Function* { maybe_create_buffer_var(ctx->mod); if (buffer_var == nullptr) { return nullptr; // no transform need, just clone func diff --git a/src/transform/transform.cc b/src/transform/transform.cc index 65fadb92f8..54766a7b82 100644 --- a/src/transform/transform.cc +++ b/src/transform/transform.cc @@ -15,8 +15,8 @@ #include "src/transform/transform.h" #include "src/ast/block_statement.h" -#include "src/ast/clone_context.h" #include "src/ast/function.h" +#include "src/clone_context.h" namespace tint { namespace transform { @@ -25,7 +25,7 @@ Transform::Transform() = default; Transform::~Transform() = default; ast::Function* Transform::CloneWithStatementsAtStart( - ast::CloneContext* ctx, + CloneContext* ctx, ast::Function* in, ast::StatementList statements) { for (auto* s : *in->body()) { diff --git a/src/transform/transform.h b/src/transform/transform.h index 211be8a9a4..4684a21f61 100644 --- a/src/transform/transform.h +++ b/src/transform/transform.h @@ -57,7 +57,7 @@ class Transform { /// @param statements the statements to prepend to `in`'s body /// @return the cloned function static ast::Function* CloneWithStatementsAtStart( - ast::CloneContext* ctx, + CloneContext* ctx, ast::Function* in, ast::StatementList statements); }; diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc index 24f6da61e1..104e80a90a 100644 --- a/src/transform/vertex_pulling.cc +++ b/src/transform/vertex_pulling.cc @@ -20,7 +20,6 @@ #include "src/ast/assignment_statement.h" #include "src/ast/binary_expression.h" #include "src/ast/bitcast_expression.h" -#include "src/ast/clone_context.h" #include "src/ast/member_accessor_expression.h" #include "src/ast/scalar_constructor_expression.h" #include "src/ast/stride_decoration.h" @@ -33,6 +32,7 @@ #include "src/ast/uint_literal.h" #include "src/ast/variable.h" #include "src/ast/variable_decl_statement.h" +#include "src/clone_context.h" #include "src/type/array_type.h" #include "src/type/f32_type.h" #include "src/type/i32_type.h" @@ -109,15 +109,14 @@ Transform::Output VertexPulling::Run(ast::Module* in) { state.ConvertVertexInputVariablesToPrivate(); state.AddVertexStorageBuffers(); - ast::CloneContext(&out.module, in) - .ReplaceAll( - [&](ast::CloneContext* ctx, ast::Function* f) -> ast::Function* { - if (f == func) { - return CloneWithStatementsAtStart( - ctx, f, {state.CreateVertexPullingPreamble()}); - } - return nullptr; // Just clone func - }) + CloneContext(&out.module, in) + .ReplaceAll([&](CloneContext* ctx, ast::Function* f) -> ast::Function* { + if (f == func) { + return CloneWithStatementsAtStart( + ctx, f, {state.CreateVertexPullingPreamble()}); + } + return nullptr; // Just clone func + }) .Clone(); return out; diff --git a/src/type/access_control_type.cc b/src/type/access_control_type.cc index 82e0de1f6b..9f8a0748ef 100644 --- a/src/type/access_control_type.cc +++ b/src/type/access_control_type.cc @@ -16,8 +16,8 @@ #include -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::type::AccessControl); diff --git a/src/type/alias_type.cc b/src/type/alias_type.cc index 1a21feadbd..0826e04aa2 100644 --- a/src/type/alias_type.cc +++ b/src/type/alias_type.cc @@ -16,8 +16,8 @@ #include -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::type::Alias); diff --git a/src/type/array_type.cc b/src/type/array_type.cc index 7793f03f89..d5604a8a4a 100644 --- a/src/type/array_type.cc +++ b/src/type/array_type.cc @@ -17,9 +17,9 @@ #include #include -#include "src/ast/clone_context.h" #include "src/ast/module.h" #include "src/ast/stride_decoration.h" +#include "src/clone_context.h" #include "src/type/vector_type.h" TINT_INSTANTIATE_CLASS_ID(tint::type::Array); diff --git a/src/type/bool_type.cc b/src/type/bool_type.cc index ead02f8c43..19490646d5 100644 --- a/src/type/bool_type.cc +++ b/src/type/bool_type.cc @@ -14,8 +14,8 @@ #include "src/type/bool_type.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::type::Bool); diff --git a/src/type/depth_texture_type.cc b/src/type/depth_texture_type.cc index 770ced4768..7b0eddf55f 100644 --- a/src/type/depth_texture_type.cc +++ b/src/type/depth_texture_type.cc @@ -17,8 +17,8 @@ #include #include -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::type::DepthTexture); diff --git a/src/type/f32_type.cc b/src/type/f32_type.cc index 49611872cc..40820a3c71 100644 --- a/src/type/f32_type.cc +++ b/src/type/f32_type.cc @@ -14,8 +14,8 @@ #include "src/type/f32_type.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::type::F32); diff --git a/src/type/i32_type.cc b/src/type/i32_type.cc index 29fee5e8e8..947fe3c402 100644 --- a/src/type/i32_type.cc +++ b/src/type/i32_type.cc @@ -14,8 +14,8 @@ #include "src/type/i32_type.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::type::I32); diff --git a/src/type/matrix_type.cc b/src/type/matrix_type.cc index f151654289..6726cc882b 100644 --- a/src/type/matrix_type.cc +++ b/src/type/matrix_type.cc @@ -16,8 +16,8 @@ #include -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" #include "src/type/array_type.h" #include "src/type/vector_type.h" diff --git a/src/type/multisampled_texture_type.cc b/src/type/multisampled_texture_type.cc index 16bb04e76d..cef16640c1 100644 --- a/src/type/multisampled_texture_type.cc +++ b/src/type/multisampled_texture_type.cc @@ -17,8 +17,8 @@ #include #include -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::type::MultisampledTexture); diff --git a/src/type/pointer_type.cc b/src/type/pointer_type.cc index 5077d333f3..a012152989 100644 --- a/src/type/pointer_type.cc +++ b/src/type/pointer_type.cc @@ -14,8 +14,8 @@ #include "src/type/pointer_type.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::type::Pointer); diff --git a/src/type/sampled_texture_type.cc b/src/type/sampled_texture_type.cc index 3d5d00a26e..f0cdf901d3 100644 --- a/src/type/sampled_texture_type.cc +++ b/src/type/sampled_texture_type.cc @@ -17,8 +17,8 @@ #include #include -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::type::SampledTexture); diff --git a/src/type/sampler_type.cc b/src/type/sampler_type.cc index d4b0ae7021..310e80e857 100644 --- a/src/type/sampler_type.cc +++ b/src/type/sampler_type.cc @@ -14,8 +14,8 @@ #include "src/type/sampler_type.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::type::Sampler); diff --git a/src/type/storage_texture_type.cc b/src/type/storage_texture_type.cc index 1f175fd872..7e55cad0ec 100644 --- a/src/type/storage_texture_type.cc +++ b/src/type/storage_texture_type.cc @@ -17,8 +17,8 @@ #include #include -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::type::StorageTexture); diff --git a/src/type/struct_type.cc b/src/type/struct_type.cc index 39d65db2bb..d6d4d3e318 100644 --- a/src/type/struct_type.cc +++ b/src/type/struct_type.cc @@ -17,8 +17,8 @@ #include #include -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" #include "src/type/alias_type.h" #include "src/type/array_type.h" #include "src/type/matrix_type.h" diff --git a/src/type/type.h b/src/type/type.h index adbd9a1d73..c55d10abe4 100644 --- a/src/type/type.h +++ b/src/type/type.h @@ -21,15 +21,14 @@ namespace tint { +// Forward declarations +class CloneContext; namespace ast { class Module; -class CloneContext; } // namespace ast namespace type { -using CloneContext = ast::CloneContext; // TEMP - /// Supported memory layouts for calculating sizes enum class MemoryLayout { kUniformBuffer, kStorageBuffer }; @@ -43,7 +42,7 @@ class Type : public Castable { /// Clones this type and all transitive types using the `CloneContext` `ctx`. /// @param ctx the clone context /// @return the newly cloned type - virtual Type* Clone(ast::CloneContext* ctx) const = 0; + virtual Type* Clone(CloneContext* ctx) const = 0; /// @returns the name for this type. The type name is unique over all types. virtual std::string type_name() const = 0; diff --git a/src/type/u32_type.cc b/src/type/u32_type.cc index fd87b36a2b..e943505cfc 100644 --- a/src/type/u32_type.cc +++ b/src/type/u32_type.cc @@ -14,8 +14,8 @@ #include "src/type/u32_type.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::type::U32); diff --git a/src/type/vector_type.cc b/src/type/vector_type.cc index b56273b622..72c9f2a4ce 100644 --- a/src/type/vector_type.cc +++ b/src/type/vector_type.cc @@ -17,8 +17,8 @@ #include #include -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::type::Vector); diff --git a/src/type/void_type.cc b/src/type/void_type.cc index aa894a5b10..b6c4408e3c 100644 --- a/src/type/void_type.cc +++ b/src/type/void_type.cc @@ -14,8 +14,8 @@ #include "src/type/void_type.h" -#include "src/ast/clone_context.h" #include "src/ast/module.h" +#include "src/clone_context.h" TINT_INSTANTIATE_CLASS_ID(tint::type::Void); diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc index 1436199866..27a43790d9 100644 --- a/src/type_determiner_test.cc +++ b/src/type_determiner_test.cc @@ -74,7 +74,7 @@ namespace { class FakeStmt : public ast::Statement { public: explicit FakeStmt(Source source) : ast::Statement(source) {} - FakeStmt* Clone(ast::CloneContext*) const override { return nullptr; } + FakeStmt* Clone(CloneContext*) const override { return nullptr; } bool IsValid() const override { return true; } void to_str(std::ostream& out, size_t) const override { out << "Fake"; } }; @@ -82,7 +82,7 @@ class FakeStmt : public ast::Statement { class FakeExpr : public ast::Expression { public: explicit FakeExpr(Source source) : ast::Expression(source) {} - FakeExpr* Clone(ast::CloneContext*) const override { return nullptr; } + FakeExpr* Clone(CloneContext*) const override { return nullptr; } bool IsValid() const override { return true; } void to_str(std::ostream&, size_t) const override {} };