mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-15 08:06:19 +00:00
ast: Keep style consistent
Methods and functions are `CamelCase()` Public fields are `snake_case` with no trailing `_` Private fields are `snake_case` with a trailing `_` Remove pointless getters on fully immutable fields. They provide no value, and just add `()` noise on use. Remove unused methods. Bug: tint:1231 Change-Id: If32efd039df48938efd5bc2186d51fe4853e9840 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/66600 Reviewed-by: David Neto <dneto@google.com> Commit-Queue: Ben Clayton <bclayton@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Tint LUCI CQ
parent
b3e6c0d62c
commit
4f3ff57c28
@@ -157,9 +157,9 @@ TEST_F(ResolverInferredTypeTest, InferStruct_Pass) {
|
||||
auto* str = Structure("S", {member}, {create<ast::StructBlockDecoration>()});
|
||||
|
||||
auto* expected_type = create<sem::Struct>(
|
||||
str, str->name(),
|
||||
str, str->name,
|
||||
sem::StructMemberList{create<sem::StructMember>(
|
||||
member, member->symbol(), create<sem::I32>(), 0, 0, 0, 4)},
|
||||
member, member->symbol, create<sem::I32>(), 0, 0, 0, 4)},
|
||||
0, 4, 4);
|
||||
|
||||
auto* ctor_expr = Construct(ty.Of(str));
|
||||
|
||||
@@ -1925,8 +1925,8 @@ const char* expected_texture_overload(
|
||||
TEST_P(ResolverIntrinsicTest_Texture, Call) {
|
||||
auto param = GetParam();
|
||||
|
||||
param.buildTextureVariable(this);
|
||||
param.buildSamplerVariable(this);
|
||||
param.BuildTextureVariable(this);
|
||||
param.BuildSamplerVariable(this);
|
||||
|
||||
auto* call = Call(param.function, param.args(this));
|
||||
auto* stmt = ast::intrinsic::test::ReturnsVoid(param.overload)
|
||||
|
||||
@@ -125,8 +125,8 @@ TEST_P(IntrinsicTextureSamplerValidationTest, ConstExpr) {
|
||||
auto& p = GetParam();
|
||||
auto param = std::get<0>(p);
|
||||
auto offset = std::get<1>(p);
|
||||
param.buildTextureVariable(this);
|
||||
param.buildSamplerVariable(this);
|
||||
param.BuildTextureVariable(this);
|
||||
param.BuildSamplerVariable(this);
|
||||
|
||||
auto args = param.args(this);
|
||||
// Make Resolver visit the Node about to be removed
|
||||
@@ -160,8 +160,8 @@ TEST_P(IntrinsicTextureSamplerValidationTest, ConstExprOfConstExpr) {
|
||||
auto& p = GetParam();
|
||||
auto param = std::get<0>(p);
|
||||
auto offset = std::get<1>(p);
|
||||
param.buildTextureVariable(this);
|
||||
param.buildSamplerVariable(this);
|
||||
param.BuildTextureVariable(this);
|
||||
param.BuildSamplerVariable(this);
|
||||
|
||||
auto args = param.args(this);
|
||||
// Make Resolver visit the Node about to be removed
|
||||
@@ -192,8 +192,8 @@ TEST_P(IntrinsicTextureSamplerValidationTest, ConstExprOfConstExpr) {
|
||||
TEST_P(IntrinsicTextureSamplerValidationTest, EmptyVectorConstructor) {
|
||||
auto& p = GetParam();
|
||||
auto param = std::get<0>(p);
|
||||
param.buildTextureVariable(this);
|
||||
param.buildSamplerVariable(this);
|
||||
param.BuildTextureVariable(this);
|
||||
param.BuildSamplerVariable(this);
|
||||
|
||||
auto args = param.args(this);
|
||||
// Make Resolver visit the Node about to be removed
|
||||
@@ -215,8 +215,8 @@ TEST_P(IntrinsicTextureSamplerValidationTest, GlobalConst) {
|
||||
auto& p = GetParam();
|
||||
auto param = std::get<0>(p);
|
||||
auto offset = std::get<1>(p);
|
||||
param.buildTextureVariable(this);
|
||||
param.buildSamplerVariable(this);
|
||||
param.BuildTextureVariable(this);
|
||||
param.BuildSamplerVariable(this);
|
||||
|
||||
auto args = param.args(this);
|
||||
// Make Resolver visit the Node about to be removed
|
||||
@@ -245,8 +245,8 @@ TEST_P(IntrinsicTextureSamplerValidationTest, ScalarConst) {
|
||||
auto& p = GetParam();
|
||||
auto param = std::get<0>(p);
|
||||
auto offset = std::get<1>(p);
|
||||
param.buildTextureVariable(this);
|
||||
param.buildSamplerVariable(this);
|
||||
param.BuildTextureVariable(this);
|
||||
param.BuildSamplerVariable(this);
|
||||
auto* x = Const("x", ty.i32(), Construct(ty.i32(), offset.x));
|
||||
|
||||
auto args = param.args(this);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -80,18 +80,18 @@ sem::Constant Resolver::EvaluateConstantValue(const ast::Expression* expr,
|
||||
sem::Constant Resolver::EvaluateConstantValue(
|
||||
const ast::ScalarConstructorExpression* scalar_ctor,
|
||||
const sem::Type* type) {
|
||||
auto* literal = scalar_ctor->literal();
|
||||
auto* literal = scalar_ctor->literal;
|
||||
if (auto* lit = literal->As<ast::SintLiteral>()) {
|
||||
return {type, {lit->value_as_i32()}};
|
||||
return {type, {lit->ValueAsI32()}};
|
||||
}
|
||||
if (auto* lit = literal->As<ast::UintLiteral>()) {
|
||||
return {type, {lit->value_as_u32()}};
|
||||
return {type, {lit->ValueAsU32()}};
|
||||
}
|
||||
if (auto* lit = literal->As<ast::FloatLiteral>()) {
|
||||
return {type, {lit->value()}};
|
||||
return {type, {lit->value}};
|
||||
}
|
||||
if (auto* lit = literal->As<ast::BoolLiteral>()) {
|
||||
return {type, {lit->IsTrue()}};
|
||||
return {type, {lit->value}};
|
||||
}
|
||||
TINT_UNREACHABLE(Resolver, builder_->Diagnostics());
|
||||
return {};
|
||||
@@ -100,7 +100,7 @@ sem::Constant Resolver::EvaluateConstantValue(
|
||||
sem::Constant Resolver::EvaluateConstantValue(
|
||||
const ast::TypeConstructorExpression* type_ctor,
|
||||
const sem::Type* type) {
|
||||
auto& ctor_values = type_ctor->values();
|
||||
auto& ctor_values = type_ctor->values;
|
||||
auto* vec = type->As<sem::Vector>();
|
||||
|
||||
// For now, only fold scalars and vectors
|
||||
|
||||
@@ -175,12 +175,12 @@ TEST_F(ResolverTest, Stmt_If) {
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
||||
ASSERT_NE(TypeOf(stmt->condition()), nullptr);
|
||||
ASSERT_NE(TypeOf(stmt->condition), nullptr);
|
||||
ASSERT_NE(TypeOf(else_lhs), nullptr);
|
||||
ASSERT_NE(TypeOf(else_rhs), nullptr);
|
||||
ASSERT_NE(TypeOf(lhs), nullptr);
|
||||
ASSERT_NE(TypeOf(rhs), nullptr);
|
||||
EXPECT_TRUE(TypeOf(stmt->condition())->Is<sem::Bool>());
|
||||
EXPECT_TRUE(TypeOf(stmt->condition)->Is<sem::Bool>());
|
||||
EXPECT_TRUE(TypeOf(else_lhs)->UnwrapRef()->Is<sem::F32>());
|
||||
EXPECT_TRUE(TypeOf(else_rhs)->Is<sem::F32>());
|
||||
EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<sem::F32>());
|
||||
@@ -253,11 +253,11 @@ TEST_F(ResolverTest, Stmt_Switch) {
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
||||
ASSERT_NE(TypeOf(stmt->condition()), nullptr);
|
||||
ASSERT_NE(TypeOf(stmt->condition), nullptr);
|
||||
ASSERT_NE(TypeOf(lhs), nullptr);
|
||||
ASSERT_NE(TypeOf(rhs), nullptr);
|
||||
|
||||
EXPECT_TRUE(TypeOf(stmt->condition())->Is<sem::I32>());
|
||||
EXPECT_TRUE(TypeOf(stmt->condition)->Is<sem::I32>());
|
||||
EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is<sem::F32>());
|
||||
EXPECT_TRUE(TypeOf(rhs)->Is<sem::F32>());
|
||||
EXPECT_EQ(BlockOf(lhs), case_block);
|
||||
@@ -282,7 +282,7 @@ TEST_F(ResolverTest, Stmt_Call) {
|
||||
|
||||
TEST_F(ResolverTest, Stmt_VariableDecl) {
|
||||
auto* var = Var("my_var", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
auto* init = var->constructor();
|
||||
auto* init = var->constructor;
|
||||
|
||||
auto* decl = Decl(var);
|
||||
WrapInFunction(decl);
|
||||
@@ -296,7 +296,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl) {
|
||||
TEST_F(ResolverTest, Stmt_VariableDecl_Alias) {
|
||||
auto* my_int = Alias("MyInt", ty.i32());
|
||||
auto* var = Var("my_var", ty.Of(my_int), ast::StorageClass::kNone, Expr(2));
|
||||
auto* init = var->constructor();
|
||||
auto* init = var->constructor;
|
||||
|
||||
auto* decl = Decl(var);
|
||||
WrapInFunction(decl);
|
||||
@@ -343,24 +343,24 @@ TEST_F(ResolverTest, Stmt_VariableDecl_OuterScopeAfterInnerScope) {
|
||||
|
||||
// Declare i32 "foo" inside a block
|
||||
auto* foo_i32 = Var("foo", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
auto* foo_i32_init = foo_i32->constructor();
|
||||
auto* foo_i32_init = foo_i32->constructor;
|
||||
auto* foo_i32_decl = Decl(foo_i32);
|
||||
|
||||
// Reference "foo" inside the block
|
||||
auto* bar_i32 = Var("bar", ty.i32(), ast::StorageClass::kNone, Expr("foo"));
|
||||
auto* bar_i32_init = bar_i32->constructor();
|
||||
auto* bar_i32_init = bar_i32->constructor;
|
||||
auto* bar_i32_decl = Decl(bar_i32);
|
||||
|
||||
auto* inner = Block(foo_i32_decl, bar_i32_decl);
|
||||
|
||||
// Declare f32 "foo" at function scope
|
||||
auto* foo_f32 = Var("foo", ty.f32(), ast::StorageClass::kNone, Expr(2.f));
|
||||
auto* foo_f32_init = foo_f32->constructor();
|
||||
auto* foo_f32_init = foo_f32->constructor;
|
||||
auto* foo_f32_decl = Decl(foo_f32);
|
||||
|
||||
// Reference "foo" at function scope
|
||||
auto* bar_f32 = Var("bar", ty.f32(), ast::StorageClass::kNone, Expr("foo"));
|
||||
auto* bar_f32_init = bar_f32->constructor();
|
||||
auto* bar_f32_init = bar_f32->constructor;
|
||||
auto* bar_f32_decl = Decl(bar_f32);
|
||||
|
||||
Func("func", params, ty.void_(), {inner, foo_f32_decl, bar_f32_decl},
|
||||
@@ -379,12 +379,12 @@ TEST_F(ResolverTest, Stmt_VariableDecl_OuterScopeAfterInnerScope) {
|
||||
EXPECT_EQ(StmtOf(bar_i32_init), bar_i32_decl);
|
||||
EXPECT_EQ(StmtOf(foo_f32_init), foo_f32_decl);
|
||||
EXPECT_EQ(StmtOf(bar_f32_init), bar_f32_decl);
|
||||
EXPECT_TRUE(CheckVarUsers(foo_i32, {bar_i32->constructor()}));
|
||||
EXPECT_TRUE(CheckVarUsers(foo_f32, {bar_f32->constructor()}));
|
||||
ASSERT_NE(VarOf(bar_i32->constructor()), nullptr);
|
||||
EXPECT_EQ(VarOf(bar_i32->constructor())->Declaration(), foo_i32);
|
||||
ASSERT_NE(VarOf(bar_f32->constructor()), nullptr);
|
||||
EXPECT_EQ(VarOf(bar_f32->constructor())->Declaration(), foo_f32);
|
||||
EXPECT_TRUE(CheckVarUsers(foo_i32, {bar_i32->constructor}));
|
||||
EXPECT_TRUE(CheckVarUsers(foo_f32, {bar_f32->constructor}));
|
||||
ASSERT_NE(VarOf(bar_i32->constructor), nullptr);
|
||||
EXPECT_EQ(VarOf(bar_i32->constructor)->Declaration(), foo_i32);
|
||||
ASSERT_NE(VarOf(bar_f32->constructor), nullptr);
|
||||
EXPECT_EQ(VarOf(bar_f32->constructor)->Declaration(), foo_f32);
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) {
|
||||
@@ -400,18 +400,18 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) {
|
||||
|
||||
// Declare i32 "foo" inside a function
|
||||
auto* fn_i32 = Var("foo", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
auto* fn_i32_init = fn_i32->constructor();
|
||||
auto* fn_i32_init = fn_i32->constructor;
|
||||
auto* fn_i32_decl = Decl(fn_i32);
|
||||
Func("func_i32", params, ty.void_(), {fn_i32_decl}, ast::DecorationList{});
|
||||
|
||||
// Declare f32 "foo" at module scope
|
||||
auto* mod_f32 = Var("foo", ty.f32(), ast::StorageClass::kPrivate, Expr(2.f));
|
||||
auto* mod_init = mod_f32->constructor();
|
||||
auto* mod_init = mod_f32->constructor;
|
||||
AST().AddGlobalVariable(mod_f32);
|
||||
|
||||
// Reference "foo" in another function
|
||||
auto* fn_f32 = Var("bar", ty.f32(), ast::StorageClass::kNone, Expr("foo"));
|
||||
auto* fn_f32_init = fn_f32->constructor();
|
||||
auto* fn_f32_init = fn_f32->constructor;
|
||||
auto* fn_f32_decl = Decl(fn_f32);
|
||||
Func("func_f32", params, ty.void_(), {fn_f32_decl}, ast::DecorationList{});
|
||||
|
||||
@@ -426,9 +426,9 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) {
|
||||
EXPECT_EQ(StmtOf(mod_init), nullptr);
|
||||
EXPECT_EQ(StmtOf(fn_f32_init), fn_f32_decl);
|
||||
EXPECT_TRUE(CheckVarUsers(fn_i32, {}));
|
||||
EXPECT_TRUE(CheckVarUsers(mod_f32, {fn_f32->constructor()}));
|
||||
ASSERT_NE(VarOf(fn_f32->constructor()), nullptr);
|
||||
EXPECT_EQ(VarOf(fn_f32->constructor())->Declaration(), mod_f32);
|
||||
EXPECT_TRUE(CheckVarUsers(mod_f32, {fn_f32->constructor}));
|
||||
ASSERT_NE(VarOf(fn_f32->constructor), nullptr);
|
||||
EXPECT_EQ(VarOf(fn_f32->constructor)->Declaration(), mod_f32);
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, ArraySize_UnsignedLiteral) {
|
||||
@@ -1115,7 +1115,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_Struct) {
|
||||
ASSERT_NE(sma, nullptr);
|
||||
EXPECT_TRUE(sma->Member()->Type()->Is<sem::F32>());
|
||||
EXPECT_EQ(sma->Member()->Index(), 1u);
|
||||
EXPECT_EQ(sma->Member()->Declaration()->symbol(),
|
||||
EXPECT_EQ(sma->Member()->Declaration()->symbol,
|
||||
Symbols().Get("second_member"));
|
||||
}
|
||||
|
||||
@@ -1623,7 +1623,7 @@ TEST_P(Expr_Binary_Test_Invalid, All) {
|
||||
ASSERT_EQ(r()->error(),
|
||||
"12:34 error: Binary expression operand types are invalid for "
|
||||
"this operation: " +
|
||||
FriendlyName(lhs_type) + " " + ast::FriendlyName(expr->op()) +
|
||||
FriendlyName(lhs_type) + " " + ast::FriendlyName(expr->op) +
|
||||
" " + FriendlyName(rhs_type));
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
@@ -1672,7 +1672,7 @@ TEST_P(Expr_Binary_Test_Invalid_VectorMatrixMultiply, All) {
|
||||
ASSERT_EQ(r()->error(),
|
||||
"12:34 error: Binary expression operand types are invalid for "
|
||||
"this operation: " +
|
||||
FriendlyName(lhs_type) + " " + ast::FriendlyName(expr->op()) +
|
||||
FriendlyName(lhs_type) + " " + ast::FriendlyName(expr->op) +
|
||||
" " + FriendlyName(rhs_type));
|
||||
}
|
||||
}
|
||||
@@ -1714,7 +1714,7 @@ TEST_P(Expr_Binary_Test_Invalid_MatrixMatrixMultiply, All) {
|
||||
ASSERT_EQ(r()->error(),
|
||||
"12:34 error: Binary expression operand types are invalid for "
|
||||
"this operation: " +
|
||||
FriendlyName(lhs_type) + " " + ast::FriendlyName(expr->op()) +
|
||||
FriendlyName(lhs_type) + " " + ast::FriendlyName(expr->op) +
|
||||
" " + FriendlyName(rhs_type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ using ResolverValidationTest = ResolverTest;
|
||||
|
||||
class FakeStmt : public Castable<FakeStmt, ast::Statement> {
|
||||
public:
|
||||
FakeStmt(ProgramID program_id, Source source) : Base(program_id, source) {}
|
||||
FakeStmt(ProgramID pid, Source src) : Base(pid, src) {}
|
||||
FakeStmt* Clone(CloneContext*) const override { return nullptr; }
|
||||
};
|
||||
|
||||
class FakeExpr : public Castable<FakeExpr, ast::Expression> {
|
||||
public:
|
||||
FakeExpr(ProgramID program_id, Source source) : Base(program_id, source) {}
|
||||
FakeExpr(ProgramID pid, Source src) : Base(pid, src) {}
|
||||
FakeExpr* Clone(CloneContext*) const override { return nullptr; }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user