tint: Have ast::CallExpression use ast::Identifier

Instead of ast::IdentifierExpression.
The name is not an expression, as it resolves to a function, builtin or
type.

Bug: tint:1257
Change-Id: I13143f2bbc208e9e2934dad20fe5c9aa59520b68
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118341
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton
2023-02-02 15:16:28 +00:00
committed by Dawn LUCI CQ
parent 6e31bc24b1
commit 999db74a24
18 changed files with 105 additions and 103 deletions

View File

@@ -39,10 +39,7 @@ TEST_F(ResolverBuiltinValidationTest, FunctionTypeMustMatchReturnStatementType_v
TEST_F(ResolverBuiltinValidationTest, InvalidPipelineStageDirect) {
// @compute @workgroup_size(1) fn func { return dpdx(1.0); }
auto* dpdx = create<ast::CallExpression>(Source{{3, 4}}, Expr("dpdx"),
utils::Vector{
Expr(1_f),
});
auto* dpdx = Call(Source{{3, 4}}, "dpdx", 1_f);
Func(Source{{1, 2}}, "func", utils::Empty, ty.void_(),
utils::Vector{
CallStmt(dpdx),
@@ -62,10 +59,7 @@ TEST_F(ResolverBuiltinValidationTest, InvalidPipelineStageIndirect) {
// fn f2 { f1(); }
// @compute @workgroup_size(1) fn main { return f2(); }
auto* dpdx = create<ast::CallExpression>(Source{{3, 4}}, Expr("dpdx"),
utils::Vector{
Expr(1_f),
});
auto* dpdx = Call(Source{{3, 4}}, "dpdx", 1_f);
Func(Source{{1, 2}}, "f0", utils::Empty, ty.void_(),
utils::Vector{
CallStmt(dpdx),
@@ -138,7 +132,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsFunctionUsedAsType) {
TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalConstUsedAsFunction) {
GlobalConst(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i));
WrapInFunction(Call(Expr(Source{{56, 78}}, "mix"), 1_f, 2_f, 3_f));
WrapInFunction(Call(Ident(Source{{56, 78}}, "mix"), 1_f, 2_f, 3_f));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), R"(56:78 error: cannot call variable 'mix'
@@ -167,7 +161,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalConstUsedAsType)
TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalVarUsedAsFunction) {
GlobalVar(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i), type::AddressSpace::kPrivate);
WrapInFunction(Call(Expr(Source{{56, 78}}, "mix"), 1_f, 2_f, 3_f));
WrapInFunction(Call(Ident(Source{{56, 78}}, "mix"), 1_f, 2_f, 3_f));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), R"(56:78 error: cannot call variable 'mix'

View File

@@ -39,6 +39,7 @@
#include "src/tint/ast/for_loop_statement.h"
#include "src/tint/ast/i32.h"
#include "src/tint/ast/id_attribute.h"
#include "src/tint/ast/identifier.h"
#include "src/tint/ast/if_statement.h"
#include "src/tint/ast/increment_decrement_statement.h"
#include "src/tint/ast/internal_attribute.h"

View File

@@ -548,7 +548,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
return node;
}
case SymbolUseKind::CallFunction: {
auto* node = b.Expr(source, symbol);
auto* node = b.Ident(source, symbol);
statements.Push(b.CallStmt(b.Call(node)));
return node;
}
@@ -651,7 +651,8 @@ TEST_F(ResolverDependencyGraphUsedBeforeDeclTest, FuncCall) {
// fn A() { B(); }
// fn B() {}
Func("A", utils::Empty, ty.void_(), utils::Vector{CallStmt(Call(Expr(Source{{12, 34}}, "B")))});
Func("A", utils::Empty, ty.void_(),
utils::Vector{CallStmt(Call(Ident(Source{{12, 34}}, "B")))});
Func(Source{{56, 78}}, "B", utils::Empty, ty.void_(), utils::Vector{Return()});
Build();
@@ -812,7 +813,7 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, DirectCall) {
// fn main() { main(); }
Func(Source{{12, 34}}, "main", utils::Empty, ty.void_(),
utils::Vector{CallStmt(Call(Expr(Source{{56, 78}}, "main")))});
utils::Vector{CallStmt(Call(Ident(Source{{56, 78}}, "main")))});
Build(R"(12:34 error: cyclic dependency found: 'main' -> 'main'
56:78 note: function 'main' calls function 'main' here)");
@@ -826,17 +827,17 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, IndirectCall) {
// 5: fn b() { c(); }
Func(Source{{1, 1}}, "a", utils::Empty, ty.void_(),
utils::Vector{CallStmt(Call(Expr(Source{{1, 10}}, "b")))});
utils::Vector{CallStmt(Call(Ident(Source{{1, 10}}, "b")))});
Func(Source{{2, 1}}, "e", utils::Empty, ty.void_(), utils::Empty);
Func(Source{{3, 1}}, "d", utils::Empty, ty.void_(),
utils::Vector{
CallStmt(Call(Expr(Source{{3, 10}}, "e"))),
CallStmt(Call(Expr(Source{{3, 10}}, "b"))),
CallStmt(Call(Ident(Source{{3, 10}}, "e"))),
CallStmt(Call(Ident(Source{{3, 10}}, "b"))),
});
Func(Source{{4, 1}}, "c", utils::Empty, ty.void_(),
utils::Vector{CallStmt(Call(Expr(Source{{4, 10}}, "d")))});
utils::Vector{CallStmt(Call(Ident(Source{{4, 10}}, "d")))});
Func(Source{{5, 1}}, "b", utils::Empty, ty.void_(),
utils::Vector{CallStmt(Call(Expr(Source{{5, 10}}, "c")))});
utils::Vector{CallStmt(Call(Ident(Source{{5, 10}}, "c")))});
Build(R"(5:1 error: cyclic dependency found: 'b' -> 'c' -> 'd' -> 'b'
5:10 note: function 'b' calls function 'c' here
@@ -1232,7 +1233,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
};
#define V add_use(value_decl, Expr(value_sym), __LINE__, "V()")
#define T add_use(type_decl, ty.type_name(type_sym), __LINE__, "T()")
#define F add_use(func_decl, Expr(func_sym), __LINE__, "F()")
#define F add_use(func_decl, Ident(func_sym), __LINE__, "F()")
Alias(Sym(), T);
Structure(Sym(), //

View File

@@ -5330,7 +5330,7 @@ TEST_F(UniformityAnalysisTest, MaximumNumberOfPointerParameters) {
args.Push(b.AddressOf(name));
}
main_body.Push(b.Assign("v0", "non_uniform_global"));
main_body.Push(b.CallStmt(b.create<ast::CallExpression>(b.Expr("foo"), args)));
main_body.Push(b.CallStmt(b.create<ast::CallExpression>(b.Ident("foo"), args)));
main_body.Push(b.If(b.Equal("v254", 0_i), b.Block(b.CallStmt(b.Call("workgroupBarrier")))));
b.Func("main", utils::Empty, ty.void_(), main_body);