Add ProgramID feed it into all ast::Nodes

This will be used to detect accidental leaks of program objects between programs.

Bug: tint:709
Change-Id: I20f784a2c673d19a04a880b3ec91dfe2eb743bdb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47622
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton
2021-04-13 23:27:27 +00:00
committed by Commit Bot service account
parent f01ed13a25
commit e6995de232
126 changed files with 589 additions and 233 deletions

View File

@@ -48,7 +48,8 @@ using ResolverValidationTest = ResolverTest;
class FakeStmt : public ast::Statement {
public:
explicit FakeStmt(Source source) : ast::Statement(source) {}
FakeStmt(ProgramID program_id, Source source)
: ast::Statement(program_id, source) {}
FakeStmt* Clone(CloneContext*) const override { return nullptr; }
void to_str(const semantic::Info&, std::ostream& out, size_t) const override {
out << "Fake";
@@ -57,7 +58,8 @@ class FakeStmt : public ast::Statement {
class FakeExpr : public ast::Expression {
public:
explicit FakeExpr(Source source) : ast::Expression(source) {}
FakeExpr(ProgramID program_id, Source source)
: ast::Expression(program_id, source) {}
FakeExpr* Clone(CloneContext*) const override { return nullptr; }
void to_str(const semantic::Info&, std::ostream&, size_t) const override {}
};
@@ -179,8 +181,8 @@ TEST_F(ResolverValidationTest,
}
TEST_F(ResolverValidationTest, Expr_Error_Unknown) {
FakeExpr e(Source{Source::Location{2, 30}});
WrapInFunction(&e);
auto* e = create<FakeExpr>(Source{Source::Location{2, 30}});
WrapInFunction(e);
EXPECT_FALSE(r()->Resolve());