dawn-cmake/src
Ben Clayton 363a2e26e3 SymbolTable: Change behavior of anonymous symbols
SymbolTable::New() used to build and return a symbol without a registered name. When you asked for the name of the symbol it would return tint_symbol_N, where N is the numerical identifier for the symbol.

This approach was a major tripping hazzard for  transforms that liked to fetch the source program name, and register it in the new program (in this situation, you should always use `CloneContext::Clone(Symbol)`).
Without special casing for unnamed symbols, you could end up promoting the unnamed symbol to a named symbol, and then colliding against a new unnamed symbol.
This is exactly what happened in tint:711.

Instead, with this change:

* The concept of unnamed symbols has been removed. All symbols  now have a name.
* The signature of `SymbolTable::New()` has been changed to take a name parameter (which defaults to 'tint_symbol'). This can be used to create a new, unique named symbol (possibly with a suffix), which will not collide with any existing symbols. Note these symbols may still collide if `SymbolTable::Register()` is called with the same name. All Transforms that currently use `SymbolTable::Register()` will be fixed in another change.
* The CloneContext has been updated to use `SymbolTable::New()` instead of `Register()`. This means that any symbols defined before a clone will not collide.
* `CloneContext::CloneSymbols()` has been added which allows a transform to pre-clone all the symbols from the source program. This can be used to avoid the authored identifiers being suffixed with a number, in the case a transform calls New() before the symbol is cloned.
* `Symbol::to_str()` has been changed to return `$<id>` instead of `tint_symbol_N`. This is to avoid any confusion between the actual name and the symbol ID.

Bug: tint:711
Bug: tint:712
Change-Id: I526e4b49b7027545613859de487e6a275686107a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47631
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-13 20:07:57 +00:00
..
ast Fixup all doxygen warnings 2021-04-09 16:51:38 +00:00
diagnostic wgsl: Deprecate '-> void' on functions 2021-04-08 14:39:47 +00:00
inspector [inspector] Add support for new entry point IO syntax 2021-04-08 22:41:08 +00:00
reader SymbolTable: Change behavior of anonymous symbols 2021-04-13 20:07:57 +00:00
resolver Resolver: compute canonical types and store them as semantic::Variable::Type 2021-04-13 13:32:33 +00:00
semantic Resolver: compute canonical types and store them as semantic::Variable::Type 2021-04-13 13:32:33 +00:00
transform SymbolTable: Change behavior of anonymous symbols 2021-04-13 20:07:57 +00:00
type SymbolTable: Change behavior of anonymous symbols 2021-04-13 20:07:57 +00:00
utils Support optional file extension in TmpFile 2021-04-13 19:07:47 +00:00
writer SymbolTable: Change behavior of anonymous symbols 2021-04-13 20:07:57 +00:00
BUILD.gn writer/hlsl: Move the renamer into the sanitizer transform 2021-04-09 17:28:18 +00:00
CMakeLists.txt writer/hlsl: Move the renamer into the sanitizer transform 2021-04-09 17:28:18 +00:00
block_allocator.h Add tint::BlockAllocator<T> 2021-01-21 15:30:10 +00:00
block_allocator_test.cc Add tint::BlockAllocator<T> 2021-01-21 15:30:10 +00:00
castable.cc Pull Is() out of castable and into a new TypeInfo 2021-03-02 20:30:08 +00:00
castable.h transform::VertexPulling - use DataMap for inputs 2021-04-13 18:46:47 +00:00
castable_test.cc Remove unusued param 2021-03-15 21:28:22 +00:00
clone_context.cc SymbolTable: Change behavior of anonymous symbols 2021-04-13 20:07:57 +00:00
clone_context.h SymbolTable: Change behavior of anonymous symbols 2021-04-13 20:07:57 +00:00
clone_context_test.cc SymbolTable: Change behavior of anonymous symbols 2021-04-13 20:07:57 +00:00
debug.cc Remove all unnecessary includes 2021-03-09 11:11:17 +00:00
debug.h debug: Add TINT_UNIMPLEMENTED() 2021-03-17 04:55:33 +00:00
debug_test.cc Add TINT_ASSERT() 2021-03-09 13:52:18 +00:00
demangler.cc SymbolTable: Change behavior of anonymous symbols 2021-04-13 20:07:57 +00:00
demangler.h Simplify calls to ast::Node::[to_]str() 2021-01-29 11:22:40 +00:00
demangler_test.cc SymbolTable: Change behavior of anonymous symbols 2021-04-13 20:07:57 +00:00
intrinsic_table.cc Speed up intrinsic table registration 2021-04-07 20:35:11 +00:00
intrinsic_table.h Remove all unnecessary includes 2021-03-09 11:11:17 +00:00
intrinsic_table_test.cc Resolver: compute canonical types and store them as semantic::Variable::Type 2021-04-13 13:32:33 +00:00
program.cc Replace all uses of assert() with TINT_ICE macros 2021-03-31 20:43:26 +00:00
program.h Remove all unnecessary includes 2021-03-09 11:11:17 +00:00
program_builder.cc hlsl/writer: Transpose matrices 2021-04-07 15:54:11 +00:00
program_builder.h Resolver: compute canonical types and store them as semantic::Variable::Type 2021-04-13 13:32:33 +00:00
program_builder_test.cc Have ProgramBuilder::Func() register the function 2021-02-02 14:29:15 +00:00
program_test.cc ast: Replace IsValid() with TINT_ASSERT() 2021-03-10 11:41:49 +00:00
scope_stack.h Add std::hash<tint::Symbol> specialization 2021-01-11 22:02:42 +00:00
scope_stack_test.cc Remove all unnecessary includes 2021-03-09 11:11:17 +00:00
source.cc Source: Restructure Source::File 2021-02-18 21:40:19 +00:00
source.h Fix VS clang-cl build 2021-03-09 21:51:50 +00:00
symbol.cc SymbolTable: Change behavior of anonymous symbols 2021-04-13 20:07:57 +00:00
symbol.h Add std::hash<tint::Symbol> specialization 2021-01-11 22:02:42 +00:00
symbol_table.cc SymbolTable: Change behavior of anonymous symbols 2021-04-13 20:07:57 +00:00
symbol_table.h SymbolTable: Change behavior of anonymous symbols 2021-04-13 20:07:57 +00:00
symbol_table_test.cc SymbolTable: Change behavior of anonymous symbols 2021-04-13 20:07:57 +00:00
symbol_test.cc SymbolTable: Change behavior of anonymous symbols 2021-04-13 20:07:57 +00:00
test_main.cc Remove all unnecessary includes 2021-03-09 11:11:17 +00:00
traits.h Remove all unnecessary includes 2021-03-09 11:11:17 +00:00
traits_test.cc Remove all unnecessary includes 2021-03-09 11:11:17 +00:00