ast: Inject Source parameter into create calls if not provided

This will be used to clean up some of the gross Source{} littering everywhere.

Bug: tint:396
Bug: tint:390
Change-Id: I63311378ac3ef6d246ac972b3335a50974d583bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35504
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2020-12-14 21:46:37 +00:00 committed by Commit Bot service account
parent 5aad70a069
commit f4daa505ec
4 changed files with 209 additions and 172 deletions

View File

@ -206,39 +206,37 @@ class Builder {
/// @param name the identifier name
/// @return an IdentifierExpression with the given name
IdentifierExpression* Expr(const std::string& name) {
return create<IdentifierExpression>(Source{}, mod->RegisterSymbol(name),
name);
return create<IdentifierExpression>(mod->RegisterSymbol(name), name);
}
/// @param name the identifier name
/// @return an IdentifierExpression with the given name
IdentifierExpression* Expr(const char* name) {
return create<IdentifierExpression>(Source{}, mod->RegisterSymbol(name),
name);
return create<IdentifierExpression>(mod->RegisterSymbol(name), name);
}
/// @param value the boolean value
/// @return a Scalar constructor for the given value
ScalarConstructorExpression* Expr(bool value) {
return create<ScalarConstructorExpression>(Source{}, Literal(value));
return create<ScalarConstructorExpression>(Literal(value));
}
/// @param value the float value
/// @return a Scalar constructor for the given value
ScalarConstructorExpression* Expr(f32 value) {
return create<ScalarConstructorExpression>(Source{}, Literal(value));
return create<ScalarConstructorExpression>(Literal(value));
}
/// @param value the integer value
/// @return a Scalar constructor for the given value
ScalarConstructorExpression* Expr(i32 value) {
return create<ScalarConstructorExpression>(Source{}, Literal(value));
return create<ScalarConstructorExpression>(Literal(value));
}
/// @param value the unsigned int value
/// @return a Scalar constructor for the given value
ScalarConstructorExpression* Expr(u32 value) {
return create<ScalarConstructorExpression>(Source{}, Literal(value));
return create<ScalarConstructorExpression>(Literal(value));
}
/// Converts `arg` to an `Expression` using `Expr()`, then appends it to
@ -277,27 +275,19 @@ class Builder {
/// @param val the boolan value
/// @return a boolean literal with the given value
BoolLiteral* Literal(bool val) {
return create<BoolLiteral>(Source{}, ty.bool_, val);
}
BoolLiteral* Literal(bool val) { return create<BoolLiteral>(ty.bool_, val); }
/// @param val the float value
/// @return a float literal with the given value
FloatLiteral* Literal(f32 val) {
return create<FloatLiteral>(Source{}, ty.f32, val);
}
FloatLiteral* Literal(f32 val) { return create<FloatLiteral>(ty.f32, val); }
/// @param val the unsigned int value
/// @return a UintLiteral with the given value
UintLiteral* Literal(u32 val) {
return create<UintLiteral>(Source{}, ty.u32, val);
}
UintLiteral* Literal(u32 val) { return create<UintLiteral>(ty.u32, val); }
/// @param val the integer value
/// @return the SintLiteral with the given value
SintLiteral* Literal(i32 val) {
return create<SintLiteral>(Source{}, ty.i32, val);
}
SintLiteral* Literal(i32 val) { return create<SintLiteral>(ty.i32, val); }
/// @param args the arguments for the type constructor
/// @return an `TypeConstructorExpression` of type `ty`, with the values
@ -482,9 +472,9 @@ class Builder {
/// @returns a `CallExpression` to the function `func`, with the
/// arguments of `args` converted to `Expression`s using `Expr()`.
template <typename... ARGS>
CallExpression Call(const std::string& func, ARGS&&... args) {
return CallExpression(Source{}, Expr(func),
ExprList(std::forward<ARGS>(args)...));
CallExpression* Call(const std::string& func, ARGS&&... args) {
return create<CallExpression>(Expr(func),
ExprList(std::forward<ARGS>(args)...));
}
/// @param lhs the left hand argument to the addition operation
@ -492,7 +482,7 @@ class Builder {
/// @returns a `BinaryExpression` summing the arguments `lhs` and `rhs`
template <typename LHS, typename RHS>
Expression* Add(LHS&& lhs, RHS&& rhs) {
return create<BinaryExpression>(Source{}, ast::BinaryOp::kAdd,
return create<BinaryExpression>(ast::BinaryOp::kAdd,
Expr(std::forward<LHS>(lhs)),
Expr(std::forward<RHS>(rhs)));
}
@ -502,7 +492,7 @@ class Builder {
/// @returns a `BinaryExpression` subtracting `rhs` from `lhs`
template <typename LHS, typename RHS>
Expression* Sub(LHS&& lhs, RHS&& rhs) {
return create<BinaryExpression>(Source{}, ast::BinaryOp::kSubtract,
return create<BinaryExpression>(ast::BinaryOp::kSubtract,
Expr(std::forward<LHS>(lhs)),
Expr(std::forward<RHS>(rhs)));
}
@ -516,12 +506,53 @@ class Builder {
Source{}, Expr(std::forward<ARR>(arr)), Expr(std::forward<IDX>(idx)));
}
/// Creates a new `Node` owned by the Module. When the Module is
/// destructed, the `Node` will also be destructed.
/// Creates a new ast::Node owned by the Module, with the explicit Source.
/// When the Module is destructed, the `Node` will also be destructed.
/// @param source the source to apply to the Node
/// @param args the arguments to pass to the type constructor
/// @returns the node pointer
template <typename T, typename... ARGS>
T* create(ARGS&&... args) {
ast::traits::EnableIfIsType<T, ast::Node>* create(const Source& source,
ARGS&&... args) {
return mod->create<T>(source, std::forward<ARGS>(args)...);
}
/// Creates a new ast::Node owned by the Module, with the explicit Source.
/// When the Module is destructed, the `Node` will also be destructed.
/// @param source the source to apply to the Node
/// @param args the arguments to pass to the type constructor
/// @returns the node pointer
template <typename T, typename... ARGS>
ast::traits::EnableIfIsType<T, ast::Node>* create(Source&& source,
ARGS&&... args) {
return mod->create<T>(std::move(source), std::forward<ARGS>(args)...);
}
/// Creates a new ast::type::Type owned by the Module, using the Builder's
/// current Source. When the Module is destructed, the `Node` will also be
/// destructed.
/// @param args the arguments to pass to the type constructor
/// @returns the node pointer
template <typename T, typename... ARGS>
ast::traits::EnableIfIsType<T, ast::Node>* create(ARGS&&... args) {
return mod->create<T>(source_, std::forward<ARGS>(args)...);
}
/// Creates a new type::Type owned by the Module.
/// When the Module is destructed, owned Module and the returned `Type` will
/// also be destructed. Types are unique (de-aliased), and so calling create()
/// for the same `T` and arguments will return the same pointer.
/// @warning Use this method to acquire a type only if all of its type
/// information is provided in the constructor arguments `args`.<br>
/// If the type requires additional configuration after construction that
/// affect its fundamental type, build the type with `std::make_unique`, make
/// any necessary alterations and then call unique_type() instead.
/// @param args the arguments to pass to the type constructor
/// @returns the de-aliased type pointer
template <typename T, typename... ARGS>
traits::EnableIfIsType<T, ast::type::Type>* create(ARGS&&... args) {
static_assert(std::is_base_of<type::Type, T>::value,
"T does not derive from type::Type");
return mod->create<T>(std::forward<ARGS>(args)...);
}
@ -533,6 +564,9 @@ class Builder {
protected:
/// Called whenever a new variable is built with `Var()`.
virtual void OnVariableBuilt(Variable*) {}
/// The source to use when creating AST nodes.
Source source_;
};
/// BuilderWithModule is a `Builder` that constructs and owns its `Module`.

View File

@ -24,6 +24,7 @@
#include <vector>
#include "src/ast/function.h"
#include "src/ast/traits.h"
#include "src/ast/type/alias_type.h"
#include "src/ast/type_manager.h"
#include "src/ast/variable.h"
@ -34,10 +35,6 @@ namespace ast {
/// Represents all the source in a given program.
class Module {
template <typename T, typename BASE>
using EnableIfIsType =
typename std::enable_if<std::is_base_of<BASE, T>::value, T>::type;
public:
/// Constructor
Module();
@ -107,12 +104,12 @@ class Module {
/// @returns a string representation of the module
std::string to_str() const;
/// Creates a new `Node` owned by the Module. When the Module is
/// destructed, the `Node` will also be destructed.
/// Creates a new Node owned by the Module. When the Module is
/// destructed, the Node will also be destructed.
/// @param args the arguments to pass to the type constructor
/// @returns the node pointer
template <typename T, typename... ARGS>
EnableIfIsType<T, Node>* create(ARGS&&... args) {
traits::EnableIfIsType<T, Node>* create(ARGS&&... args) {
static_assert(std::is_base_of<Node, T>::value,
"T does not derive from Node");
auto uptr = std::make_unique<T>(std::forward<ARGS>(args)...);
@ -121,7 +118,7 @@ class Module {
return ptr;
}
/// Creates a new `Type` owned by the Module.
/// Creates a new type::Type owned by the Module.
/// When the Module is destructed, owned Module and the returned
/// `Type` will also be destructed.
/// Types are unique (de-aliased), and so calling create() for the same `T`
@ -134,7 +131,7 @@ class Module {
/// @param args the arguments to pass to the type constructor
/// @returns the de-aliased type pointer
template <typename T, typename... ARGS>
EnableIfIsType<T, type::Type>* create(ARGS&&... args) {
traits::EnableIfIsType<T, type::Type>* create(ARGS&&... args) {
static_assert(std::is_base_of<type::Type, T>::value,
"T does not derive from type::Type");
return type_mgr_.Get<T>(std::forward<ARGS>(args)...);
@ -148,7 +145,7 @@ class Module {
/// @param ty the type to add to the module
/// @returns the de-aliased type pointer
template <typename T>
EnableIfIsType<T, type::Type>* unique_type(std::unique_ptr<T> ty) {
traits::EnableIfIsType<T, type::Type>* unique_type(std::unique_ptr<T> ty) {
return static_cast<T*>(type_mgr_.Get(std::move(ty)));
}

View File

@ -55,6 +55,12 @@ struct FirstParamType<R (C::*)(Arg) const> {
template <typename F>
using FirstParamTypeT = typename FirstParamType<F>::type;
/// If T is a base of BASE then EnableIfIsType resolves to type T, otherwise an
/// invalid type.
template <typename T, typename BASE>
using EnableIfIsType =
typename std::enable_if<std::is_base_of<BASE, T>::value, T>::type;
} // namespace traits
} // namespace ast
} // namespace tint

View File

@ -80,14 +80,14 @@ TEST_P(IntrinsicBoolTest, Call_Bool) {
auto param = GetParam();
auto* var = Var("v", ast::StorageClass::kPrivate, ty.vec3<bool>());
auto expr = Call(param.name, "v");
auto* expr = Call(param.name, "v");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 6u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 6u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeBool
%3 = OpTypeVector %4 3
%2 = OpTypePointer Private %3
@ -109,14 +109,14 @@ TEST_P(IntrinsicFloatTest, Call_Float_Scalar) {
auto param = GetParam();
auto* var = Var("v", ast::StorageClass::kPrivate, ty.f32);
auto expr = Call(param.name, "v");
auto* expr = Call(param.name, "v");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Private %3
%4 = OpConstantNull %3
@ -133,14 +133,14 @@ TEST_P(IntrinsicFloatTest, Call_Float_Vector) {
auto param = GetParam();
auto* var = Var("v", ast::StorageClass::kPrivate, ty.vec3<f32>());
auto expr = Call(param.name, "v");
auto* expr = Call(param.name, "v");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 6u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 6u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeFloat 32
%3 = OpTypeVector %4 3
%2 = OpTypePointer Private %3
@ -164,14 +164,14 @@ TEST_P(IntrinsicIntTest, Call_SInt_Scalar) {
auto param = GetParam();
auto* var = Var("v", ast::StorageClass::kPrivate, ty.i32);
auto expr = Call(param.name, "v");
auto* expr = Call(param.name, "v");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeInt 32 1
%2 = OpTypePointer Private %3
%4 = OpConstantNull %3
@ -187,14 +187,14 @@ TEST_P(IntrinsicIntTest, Call_SInt_Vector) {
auto param = GetParam();
auto* var = Var("v", ast::StorageClass::kPrivate, ty.vec3<i32>());
auto expr = Call(param.name, "v");
auto* expr = Call(param.name, "v");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 6u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 6u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 1
%3 = OpTypeVector %4 3
%2 = OpTypePointer Private %3
@ -211,14 +211,14 @@ TEST_P(IntrinsicIntTest, Call_UInt_Scalar) {
auto param = GetParam();
auto* var = Var("v", ast::StorageClass::kPrivate, ty.u32);
auto expr = Call(param.name, "v");
auto* expr = Call(param.name, "v");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeInt 32 0
%2 = OpTypePointer Private %3
%4 = OpConstantNull %3
@ -234,14 +234,14 @@ TEST_P(IntrinsicIntTest, Call_UInt_Vector) {
auto param = GetParam();
auto* var = Var("v", ast::StorageClass::kPrivate, ty.vec3<u32>());
auto expr = Call(param.name, "v");
auto* expr = Call(param.name, "v");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 6u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 6u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 0
%3 = OpTypeVector %4 3
%2 = OpTypePointer Private %3
@ -261,14 +261,14 @@ INSTANTIATE_TEST_SUITE_P(
TEST_F(IntrinsicBuilderTest, Call_Dot) {
auto* var = Var("v", ast::StorageClass::kPrivate, ty.vec3<f32>());
auto expr = Call("dot", "v", "v");
auto* expr = Call("dot", "v", "v");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 6u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 6u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeFloat 32
%3 = OpTypeVector %4 3
%2 = OpTypePointer Private %3
@ -287,14 +287,14 @@ TEST_P(IntrinsicDeriveTest, Call_Derivative_Scalar) {
auto param = GetParam();
auto* var = Var("v", ast::StorageClass::kPrivate, ty.f32);
auto expr = Call(param.name, "v");
auto* expr = Call(param.name, "v");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Private %3
%4 = OpConstantNull %3
@ -310,14 +310,14 @@ TEST_P(IntrinsicDeriveTest, Call_Derivative_Vector) {
auto param = GetParam();
auto* var = Var("v", ast::StorageClass::kPrivate, ty.vec3<f32>());
auto expr = Call(param.name, "v");
auto* expr = Call(param.name, "v");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 6u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 6u) << b.error();
if (param.name != "dpdx" && param.name != "dpdy" && param.name != "fwidth") {
EXPECT_EQ(DumpInstructions(b.capabilities()),
@ -353,15 +353,15 @@ TEST_F(IntrinsicBuilderTest, Call_OuterProduct) {
auto* v2 = Var("v2", ast::StorageClass::kPrivate, ty.vec2<f32>());
auto* v3 = Var("v3", ast::StorageClass::kPrivate, ty.vec3<f32>());
auto expr = Call("outerProduct", "v2", "v3");
auto* expr = Call("outerProduct", "v2", "v3");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(v2)) << b.error();
ASSERT_TRUE(b.GenerateGlobalVariable(v3)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 10u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 10u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeFloat 32
%3 = OpTypeVector %4 2
@ -384,15 +384,15 @@ TEST_F(IntrinsicBuilderTest, Call_OuterProduct) {
TEST_F(IntrinsicBuilderTest, Call_Select) {
auto* v3 = Var("v3", ast::StorageClass::kPrivate, ty.vec3<f32>());
auto* bool_v3 = Var("bool_v3", ast::StorageClass::kPrivate, ty.vec3<bool>());
auto expr = Call("select", "v3", "v3", "bool_v3");
auto* expr = Call("select", "v3", "v3", "bool_v3");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(v3)) << b.error();
ASSERT_TRUE(b.GenerateGlobalVariable(bool_v3)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 11u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 11u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeFloat 32
%3 = OpTypeVector %4 3
@ -426,17 +426,17 @@ TEST_F(IntrinsicBuilderTest, Call_TextureSampleCompare_Twice) {
auto* sampler = Var("sampler", ast::StorageClass::kNone, &s);
ASSERT_TRUE(b.GenerateGlobalVariable(sampler)) << b.error();
auto expr1 = Call("textureSampleCompare", "texture", "sampler",
vec2<f32>(1.0f, 2.0f), 2.0f);
auto* expr1 = Call("textureSampleCompare", "texture", "sampler",
vec2<f32>(1.0f, 2.0f), 2.0f);
auto expr2 = Call("textureSampleCompare", "texture", "sampler",
vec2<f32>(1.0f, 2.0f), 2.0f);
auto* expr2 = Call("textureSampleCompare", "texture", "sampler",
vec2<f32>(1.0f, 2.0f), 2.0f);
EXPECT_TRUE(td.DetermineResultType(&expr1)) << td.error();
EXPECT_TRUE(td.DetermineResultType(&expr2)) << td.error();
EXPECT_TRUE(td.DetermineResultType(expr1)) << td.error();
EXPECT_TRUE(td.DetermineResultType(expr2)) << td.error();
EXPECT_EQ(b.GenerateExpression(&expr1), 8u) << b.error();
EXPECT_EQ(b.GenerateExpression(&expr2), 18u) << b.error();
EXPECT_EQ(b.GenerateExpression(expr1), 8u) << b.error();
EXPECT_EQ(b.GenerateExpression(expr2), 18u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeFloat 32
%3 = OpTypeImage %4 2D 1 0 0 1 Unknown
@ -467,9 +467,9 @@ TEST_F(IntrinsicBuilderTest, Call_TextureSampleCompare_Twice) {
TEST_F(IntrinsicBuilderTest, Call_GLSLMethod_WithLoad) {
auto* var = Var("ident", ast::StorageClass::kPrivate, ty.f32);
auto expr = Call("round", "ident");
auto* expr = Call("round", "ident");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -479,7 +479,7 @@ TEST_F(IntrinsicBuilderTest, Call_GLSLMethod_WithLoad) {
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 9u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 9u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%10 = OpExtInstImport "GLSL.std.450"
OpName %1 "ident"
OpName %7 "a_func"
@ -503,8 +503,8 @@ using Intrinsic_Builtin_SingleParam_Float_Test =
TEST_P(Intrinsic_Builtin_SingleParam_Float_Test, Call_Scalar) {
auto param = GetParam();
auto expr = Call(param.name, 1.0f);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call(param.name, 1.0f);
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -513,7 +513,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Float_Test, Call_Scalar) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -532,8 +532,8 @@ OpFunctionEnd
TEST_P(Intrinsic_Builtin_SingleParam_Float_Test, Call_Vector) {
auto param = GetParam();
auto expr = Call(param.name, vec2<f32>(1.0f, 1.0f));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call(param.name, vec2<f32>(1.0f, 1.0f));
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -542,7 +542,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Float_Test, Call_Vector) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -586,9 +586,9 @@ INSTANTIATE_TEST_SUITE_P(IntrinsicBuilderTest,
IntrinsicData{"trunc", "Trunc"}));
TEST_F(IntrinsicBuilderTest, Call_Length_Scalar) {
auto expr = Call("length", 1.0f);
auto* expr = Call("length", 1.0f);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -597,7 +597,7 @@ TEST_F(IntrinsicBuilderTest, Call_Length_Scalar) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -613,8 +613,8 @@ OpFunctionEnd
}
TEST_F(IntrinsicBuilderTest, Call_Length_Vector) {
auto expr = Call("length", vec2<f32>(1.0f, 1.0f));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call("length", vec2<f32>(1.0f, 1.0f));
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -623,7 +623,7 @@ TEST_F(IntrinsicBuilderTest, Call_Length_Vector) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -641,8 +641,8 @@ OpFunctionEnd
}
TEST_F(IntrinsicBuilderTest, Call_Normalize) {
auto expr = Call("normalize", vec2<f32>(1.0f, 1.0f));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call("normalize", vec2<f32>(1.0f, 1.0f));
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -651,7 +651,7 @@ TEST_F(IntrinsicBuilderTest, Call_Normalize) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -673,9 +673,9 @@ using Intrinsic_Builtin_DualParam_Float_Test =
TEST_P(Intrinsic_Builtin_DualParam_Float_Test, Call_Scalar) {
auto param = GetParam();
auto expr = Call(param.name, 1.0f, 1.0f);
auto* expr = Call(param.name, 1.0f, 1.0f);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -684,7 +684,7 @@ TEST_P(Intrinsic_Builtin_DualParam_Float_Test, Call_Scalar) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -703,9 +703,9 @@ OpFunctionEnd
TEST_P(Intrinsic_Builtin_DualParam_Float_Test, Call_Vector) {
auto param = GetParam();
auto expr = Call(param.name, vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
auto* expr = Call(param.name, vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -714,7 +714,7 @@ TEST_P(Intrinsic_Builtin_DualParam_Float_Test, Call_Vector) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -741,9 +741,9 @@ INSTANTIATE_TEST_SUITE_P(IntrinsicBuilderTest,
IntrinsicData{"step", "Step"}));
TEST_F(IntrinsicBuilderTest, Call_Distance_Scalar) {
auto expr = Call("distance", 1.0f, 1.0f);
auto* expr = Call("distance", 1.0f, 1.0f);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -752,7 +752,7 @@ TEST_F(IntrinsicBuilderTest, Call_Distance_Scalar) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -768,9 +768,9 @@ OpFunctionEnd
}
TEST_F(IntrinsicBuilderTest, Call_Distance_Vector) {
auto expr = Call("distance", vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
auto* expr = Call("distance", vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -779,7 +779,7 @@ TEST_F(IntrinsicBuilderTest, Call_Distance_Vector) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -797,10 +797,10 @@ OpFunctionEnd
}
TEST_F(IntrinsicBuilderTest, Call_Cross) {
auto expr =
auto* expr =
Call("cross", vec3<f32>(1.0f, 1.0f, 1.0f), vec3<f32>(1.0f, 1.0f, 1.0f));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -809,7 +809,7 @@ TEST_F(IntrinsicBuilderTest, Call_Cross) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -831,8 +831,8 @@ using Intrinsic_Builtin_ThreeParam_Float_Test =
TEST_P(Intrinsic_Builtin_ThreeParam_Float_Test, Call_Scalar) {
auto param = GetParam();
auto expr = Call(param.name, 1.0f, 1.0f, 1.0f);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call(param.name, 1.0f, 1.0f, 1.0f);
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -841,7 +841,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Float_Test, Call_Scalar) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -860,10 +860,10 @@ OpFunctionEnd
TEST_P(Intrinsic_Builtin_ThreeParam_Float_Test, Call_Vector) {
auto param = GetParam();
auto expr = Call(param.name, vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f),
vec2<f32>(1.0f, 1.0f));
auto* expr = Call(param.name, vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f),
vec2<f32>(1.0f, 1.0f));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -872,7 +872,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Float_Test, Call_Vector) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -904,8 +904,8 @@ using Intrinsic_Builtin_SingleParam_Sint_Test =
TEST_P(Intrinsic_Builtin_SingleParam_Sint_Test, Call_Scalar) {
auto param = GetParam();
auto expr = Call(param.name, 1);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call(param.name, 1);
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -914,7 +914,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Sint_Test, Call_Scalar) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -933,8 +933,8 @@ OpFunctionEnd
TEST_P(Intrinsic_Builtin_SingleParam_Sint_Test, Call_Vector) {
auto param = GetParam();
auto expr = Call(param.name, vec2<i32>(1, 1));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call(param.name, vec2<i32>(1, 1));
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -943,7 +943,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Sint_Test, Call_Vector) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -969,8 +969,8 @@ using Intrinsic_Builtin_SingleParam_Uint_Test =
TEST_P(Intrinsic_Builtin_SingleParam_Uint_Test, Call_Scalar) {
auto param = GetParam();
auto expr = Call(param.name, 1u);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call(param.name, 1u);
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -979,7 +979,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Uint_Test, Call_Scalar) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -998,8 +998,8 @@ OpFunctionEnd
TEST_P(Intrinsic_Builtin_SingleParam_Uint_Test, Call_Vector) {
auto param = GetParam();
auto expr = Call(param.name, vec2<u32>(1u, 1u));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call(param.name, vec2<u32>(1u, 1u));
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -1008,7 +1008,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Uint_Test, Call_Vector) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -1034,8 +1034,8 @@ using Intrinsic_Builtin_DualParam_SInt_Test =
TEST_P(Intrinsic_Builtin_DualParam_SInt_Test, Call_Scalar) {
auto param = GetParam();
auto expr = Call(param.name, 1, 1);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call(param.name, 1, 1);
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -1044,7 +1044,7 @@ TEST_P(Intrinsic_Builtin_DualParam_SInt_Test, Call_Scalar) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -1063,8 +1063,8 @@ OpFunctionEnd
TEST_P(Intrinsic_Builtin_DualParam_SInt_Test, Call_Vector) {
auto param = GetParam();
auto expr = Call(param.name, vec2<i32>(1, 1), vec2<i32>(1, 1));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call(param.name, vec2<i32>(1, 1), vec2<i32>(1, 1));
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -1073,7 +1073,7 @@ TEST_P(Intrinsic_Builtin_DualParam_SInt_Test, Call_Vector) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -1100,8 +1100,8 @@ using Intrinsic_Builtin_DualParam_UInt_Test =
TEST_P(Intrinsic_Builtin_DualParam_UInt_Test, Call_Scalar) {
auto param = GetParam();
auto expr = Call(param.name, 1u, 1u);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call(param.name, 1u, 1u);
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -1110,7 +1110,7 @@ TEST_P(Intrinsic_Builtin_DualParam_UInt_Test, Call_Scalar) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -1129,8 +1129,8 @@ OpFunctionEnd
TEST_P(Intrinsic_Builtin_DualParam_UInt_Test, Call_Vector) {
auto param = GetParam();
auto expr = Call(param.name, vec2<u32>(1u, 1u), vec2<u32>(1u, 1u));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call(param.name, vec2<u32>(1u, 1u), vec2<u32>(1u, 1u));
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -1139,7 +1139,7 @@ TEST_P(Intrinsic_Builtin_DualParam_UInt_Test, Call_Vector) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -1166,8 +1166,8 @@ using Intrinsic_Builtin_ThreeParam_Sint_Test =
TEST_P(Intrinsic_Builtin_ThreeParam_Sint_Test, Call_Scalar) {
auto param = GetParam();
auto expr = Call(param.name, 1, 1, 1);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call(param.name, 1, 1, 1);
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -1176,7 +1176,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Sint_Test, Call_Scalar) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -1195,10 +1195,10 @@ OpFunctionEnd
TEST_P(Intrinsic_Builtin_ThreeParam_Sint_Test, Call_Vector) {
auto param = GetParam();
auto expr =
auto* expr =
Call(param.name, vec2<i32>(1, 1), vec2<i32>(1, 1), vec2<i32>(1, 1));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -1207,7 +1207,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Sint_Test, Call_Vector) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -1233,8 +1233,8 @@ using Intrinsic_Builtin_ThreeParam_Uint_Test =
TEST_P(Intrinsic_Builtin_ThreeParam_Uint_Test, Call_Scalar) {
auto param = GetParam();
auto expr = Call(param.name, 1u, 1u, 1u);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call(param.name, 1u, 1u, 1u);
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -1243,7 +1243,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Uint_Test, Call_Scalar) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -1262,10 +1262,10 @@ OpFunctionEnd
TEST_P(Intrinsic_Builtin_ThreeParam_Uint_Test, Call_Vector) {
auto param = GetParam();
auto expr =
auto* expr =
Call(param.name, vec2<u32>(1u, 1u), vec2<u32>(1u, 1u), vec2<u32>(1u, 1u));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -1274,7 +1274,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Uint_Test, Call_Vector) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
%2 = OpTypeVoid
@ -1297,9 +1297,9 @@ INSTANTIATE_TEST_SUITE_P(IntrinsicBuilderTest,
TEST_F(IntrinsicBuilderTest, Call_Determinant) {
auto* var = Var("var", ast::StorageClass::kPrivate, ty.mat3x3<f32>());
auto expr = Call("determinant", "var");
auto* expr = Call("determinant", "var");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -1309,7 +1309,7 @@ TEST_F(IntrinsicBuilderTest, Call_Determinant) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 11u) << b.error();
EXPECT_EQ(b.GenerateCallExpression(expr), 11u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%12 = OpExtInstImport "GLSL.std.450"
OpName %3 "a_func"
@ -1342,10 +1342,10 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength) {
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
auto expr = Call("arrayLength", create<ast::MemberAccessorExpression>(
Source{}, Expr("b"), Expr("a")));
auto* expr = Call("arrayLength", create<ast::MemberAccessorExpression>(
Source{}, Expr("b"), Expr("a")));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -1354,7 +1354,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateExpression(&expr), 11u) << b.error();
EXPECT_EQ(b.GenerateExpression(expr), 11u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()),
R"(%2 = OpTypeVoid
@ -1384,10 +1384,10 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) {
ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s);
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
auto expr = Call("arrayLength", create<ast::MemberAccessorExpression>(
Source{}, Expr("b"), Expr("a")));
auto* expr = Call("arrayLength", create<ast::MemberAccessorExpression>(
Source{}, Expr("b"), Expr("a")));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -1396,7 +1396,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateExpression(&expr), 11u) << b.error();
EXPECT_EQ(b.GenerateExpression(expr), 11u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()),
R"(%2 = OpTypeVoid
@ -1434,8 +1434,8 @@ TEST_F(IntrinsicBuilderTest, DISABLED_Call_ArrayLength_Ptr) {
create<ast::MemberAccessorExpression>(Source{}, Expr("b"), Expr("a")),
{});
auto expr = Call("arrayLength", "ptr_var");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
auto* expr = Call("arrayLength", "ptr_var");
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
ast::Function func(
Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, ty.void_,
@ -1444,7 +1444,7 @@ TEST_F(IntrinsicBuilderTest, DISABLED_Call_ArrayLength_Ptr) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateExpression(&expr), 11u) << b.error();
EXPECT_EQ(b.GenerateExpression(expr), 11u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"( ... )");