Validate that Symbols are all part of the same program

Assert in each AST constructor that symbols belong to the program of the parent.

Bug: tint:709
Change-Id: I82ae9b23c88e89714a44e057a0272f0293385aaf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47624
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Ben Clayton
2021-04-15 18:20:03 +00:00
committed by Commit Bot service account
parent f0c816a757
commit 13ef87caab
21 changed files with 127 additions and 46 deletions

View File

@@ -23,7 +23,7 @@ class ScopeStackTest : public ProgramBuilder, public testing::Test {};
TEST_F(ScopeStackTest, Global) {
ScopeStack<uint32_t> s;
Symbol sym(1);
Symbol sym(1, ID());
s.set_global(sym, 5);
uint32_t val = 0;
@@ -43,7 +43,7 @@ TEST_F(ScopeStackTest, Global_SetWithPointer) {
TEST_F(ScopeStackTest, Global_CanNotPop) {
ScopeStack<uint32_t> s;
Symbol sym(1);
Symbol sym(1, ID());
s.set_global(sym, 5);
s.pop_scope();
@@ -54,7 +54,7 @@ TEST_F(ScopeStackTest, Global_CanNotPop) {
TEST_F(ScopeStackTest, Scope) {
ScopeStack<uint32_t> s;
Symbol sym(1);
Symbol sym(1, ID());
s.push_scope();
s.set(sym, 5);
@@ -65,7 +65,7 @@ TEST_F(ScopeStackTest, Scope) {
TEST_F(ScopeStackTest, Get_MissingSymbol) {
ScopeStack<uint32_t> s;
Symbol sym(1);
Symbol sym(1, ID());
uint32_t ret = 0;
EXPECT_FALSE(s.get(sym, &ret));
EXPECT_EQ(ret, 0u);
@@ -73,8 +73,8 @@ TEST_F(ScopeStackTest, Get_MissingSymbol) {
TEST_F(ScopeStackTest, Has) {
ScopeStack<uint32_t> s;
Symbol sym(1);
Symbol sym2(2);
Symbol sym(1, ID());
Symbol sym2(2, ID());
s.set_global(sym2, 3);
s.push_scope();
s.set(sym, 5);
@@ -85,7 +85,7 @@ TEST_F(ScopeStackTest, Has) {
TEST_F(ScopeStackTest, ReturnsScopeBeforeGlobalFirst) {
ScopeStack<uint32_t> s;
Symbol sym(1);
Symbol sym(1, ID());
s.set_global(sym, 3);
s.push_scope();
s.set(sym, 5);