Fixup lint errors.

This CL fixes up the various lint errors.

Change-Id: If4d3077b55aadec33980452c43917194d803fac6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31680
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2020-11-03 16:26:09 +00:00 committed by Commit Bot service account
parent de6938789c
commit d5fd7e02ba
59 changed files with 112 additions and 63 deletions

View File

@ -60,8 +60,9 @@ def CheckChange(input_api, output_api):
results += input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
input_api, output_api)
results += input_api.canned_checks.CheckDoNotSubmit(input_api, output_api)
results += input_api.canned_checks.CheckChangeLintsClean(
input_api, output_api)
results += input_api.canned_checks.CheckChangeLintsClean(input_api,
output_api,
lint_filters="")
results += input_api.canned_checks.CheckGenderNeutral(
input_api, output_api)

View File

@ -24,9 +24,8 @@
#include "spirv-tools/libspirv.hpp"
#endif // TINT_BUILD_SPV_READER
#include "tint/tint.h"
#include "src/diagnostic/printer.h"
#include "tint/tint.h"
namespace {

View File

@ -46,8 +46,7 @@ class BlockStatement : public Statement {
/// @param index the index to insert at
/// @param stmt the statement to insert
void insert(size_t index, std::unique_ptr<ast::Statement> stmt) {
statements_.insert(statements_.begin() + static_cast<long>(index),
std::move(stmt));
statements_.insert(statements_.begin() + index, std::move(stmt));
}
/// @returns true if the block is empty

View File

@ -18,6 +18,7 @@
#include <memory>
#include <ostream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

View File

@ -43,7 +43,8 @@ TEST_F(IfStatementTest, Creation_WithSource) {
auto body = std::make_unique<ast::BlockStatement>();
body->append(std::make_unique<DiscardStatement>());
IfStatement stmt(Source{Source::Location{20, 2}}, std::move(cond), std::move(body));
IfStatement stmt(Source{Source::Location{20, 2}}, std::move(cond),
std::move(body));
auto src = stmt.source();
EXPECT_EQ(src.range.begin.line, 20u);
EXPECT_EQ(src.range.begin.column, 2u);

View File

@ -15,6 +15,7 @@
#ifndef SRC_AST_LOOP_STATEMENT_H_
#define SRC_AST_LOOP_STATEMENT_H_
#include <memory>
#include <utility>
#include "src/ast/block_statement.h"

View File

@ -51,7 +51,8 @@ TEST_F(SwitchStatementTest, Creation) {
TEST_F(SwitchStatementTest, Creation_WithSource) {
auto ident = std::make_unique<IdentifierExpression>("ident");
SwitchStatement stmt(Source{Source::Location{20, 2}}, std::move(ident), CaseStatementList());
SwitchStatement stmt(Source{Source::Location{20, 2}}, std::move(ident),
CaseStatementList());
auto src = stmt.source();
EXPECT_EQ(src.range.begin.line, 20u);
EXPECT_EQ(src.range.begin.column, 2u);

View File

@ -15,9 +15,10 @@
#ifndef SRC_AST_TYPE_ACCESS_CONTROL_TYPE_H_
#define SRC_AST_TYPE_ACCESS_CONTROL_TYPE_H_
#include "src/ast/type/type.h"
#include <string>
#include "src/ast/access_control.h"
#include "src/ast/type/type.h"
namespace tint {
namespace ast {

View File

@ -18,6 +18,7 @@
#include <assert.h>
#include <string>
#include <utility>
#include "src/ast/array_decoration.h"
#include "src/ast/type/type.h"

View File

@ -14,6 +14,9 @@
#include "src/ast/type/array_type.h"
#include <memory>
#include <utility>
#include "gtest/gtest.h"
#include "src/ast/stride_decoration.h"
#include "src/ast/type/i32_type.h"

View File

@ -14,10 +14,11 @@
#include "src/ast/type/storage_texture_type.h"
#include "src/ast/identifier_expression.h"
#include "src/type_determiner.h"
#include <memory>
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h"
#include "src/type_determiner.h"
namespace tint {
namespace ast {

View File

@ -13,9 +13,9 @@
// limitations under the License.
#include "src/diagnostic/formatter.h"
#include "src/diagnostic/diagnostic.h"
#include "gtest/gtest.h"
#include "src/diagnostic/diagnostic.h"
namespace tint {
namespace diag {

View File

@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/diagnostic/printer.h"
#include <unistd.h>
#include <cstring>
#include "src/diagnostic/printer.h"
namespace tint {
namespace diag {
namespace {

View File

@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/diagnostic/printer.h"
#include <cstring>
#include "src/diagnostic/printer.h"
namespace tint {
namespace diag {
namespace {

View File

@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/diagnostic/printer.h"
#include <cstring>
#include "src/diagnostic/printer.h"
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>

View File

@ -15,6 +15,7 @@
#ifndef SRC_INSPECTOR_ENTRY_POINT_H_
#define SRC_INSPECTOR_ENTRY_POINT_H_
#include <string>
#include <tuple>
#include <vector>

View File

@ -16,6 +16,7 @@
#include <algorithm>
#include <map>
#include <utility>
#include "src/ast/bool_literal.h"
#include "src/ast/constructor_expression.h"

View File

@ -14,6 +14,8 @@
#include "src/inspector/inspector.h"
#include <utility>
#include "gtest/gtest.h"
#include "src/ast/assignment_statement.h"
#include "src/ast/bool_literal.h"
@ -52,7 +54,6 @@
#include "src/ast/workgroup_decoration.h"
#include "src/context.h"
#include "src/type_determiner.h"
#include "tint/tint.h"
namespace tint {

View File

@ -12,12 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/reader/spirv/function.h"
#include <string>
#include <vector>
#include "gmock/gmock.h"
#include "src/reader/spirv/function.h"
#include "src/reader/spirv/parser_impl.h"
#include "src/reader/spirv/parser_impl_test_helper.h"
#include "src/reader/spirv/spirv_tools_helpers_test.h"

View File

@ -643,7 +643,7 @@ TEST_F(SpvParserTest,
TEST_F(
SpvParserTest,
RegisterMerges_GoodLoopMerge_MultiBlockLoop_ContinueIsNotHeader_BranchConditional) {
RegisterMerges_GoodLoopMerge_MultiBlockLoop_ContinueIsNotHeader_BranchConditional) { // NOLINT
auto* p = parser(test::Assemble(CommonTypes() + R"(
%100 = OpFunction %void None %voidfn
@ -4570,7 +4570,7 @@ TEST_F(SpvParserTest,
TEST_F(
SpvParserTest,
ClassifyCFGEdges_BackEdge_MultiBlockLoop_MultiBlockContinueConstruct_ContinueIsNotHeader) {
ClassifyCFGEdges_BackEdge_MultiBlockLoop_MultiBlockContinueConstruct_ContinueIsNotHeader) { // NOLINT
auto assembly = CommonTypes() + R"(
%100 = OpFunction %void None %voidfn
@ -4606,7 +4606,7 @@ TEST_F(
TEST_F(
SpvParserTest,
ClassifyCFGEdges_BackEdge_MultiBlockLoop_MultiBlockContinueConstruct_ContinueIsHeader) {
ClassifyCFGEdges_BackEdge_MultiBlockLoop_MultiBlockContinueConstruct_ContinueIsHeader) { // NOLINT
auto assembly = CommonTypes() + R"(
%100 = OpFunction %void None %voidfn

View File

@ -1460,7 +1460,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_StorageBuffer_NonWritable_NotAllMembers) {
TEST_F(
SpvParserTest,
ModuleScopeVar_StorageBuffer_NonWritable_NotAllMembers_DuplicatedOnSameMember) {
ModuleScopeVar_StorageBuffer_NonWritable_NotAllMembers_DuplicatedOnSameMember) { // NOLINT
// Variable should have access(read_write)
auto* p = parser(test::Assemble(R"(
OpName %myvar "myvar"

View File

@ -14,6 +14,8 @@
#include "src/reader/wgsl/parser.h"
#include <utility>
#include "src/reader/wgsl/parser_impl.h"
namespace tint {

View File

@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <string>
#include "gtest/gtest.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
#include <string>
namespace tint {
namespace reader {
namespace wgsl {

View File

@ -17,6 +17,8 @@
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "gtest/gtest.h"
#include "src/context.h"

View File

@ -12,9 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <sstream>
#include "src/source.h"
#include "source.h"
#include <sstream>
#include <utility>
namespace tint {
namespace {

View File

@ -14,6 +14,9 @@
#include "src/transform/bound_array_accessors_transform.h"
#include <memory>
#include <utility>
#include "src/ast/assignment_statement.h"
#include "src/ast/binary_expression.h"
#include "src/ast/bitcast_expression.h"

View File

@ -15,6 +15,8 @@
#ifndef SRC_TRANSFORM_BOUND_ARRAY_ACCESSORS_TRANSFORM_H_
#define SRC_TRANSFORM_BOUND_ARRAY_ACCESSORS_TRANSFORM_H_
#include <string>
#include "src/ast/array_accessor_expression.h"
#include "src/ast/expression.h"
#include "src/ast/module.h"
@ -23,8 +25,6 @@
#include "src/scope_stack.h"
#include "src/transform/transformer.h"
#include <string>
namespace tint {
namespace transform {

View File

@ -15,6 +15,7 @@
#include "src/transform/bound_array_accessors_transform.h"
#include <memory>
#include <utility>
#include "gtest/gtest.h"
#include "src/ast/array_accessor_expression.h"

View File

@ -17,6 +17,8 @@
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "src/transform/transformer.h"

View File

@ -14,6 +14,8 @@
#include "src/transform/vertex_pulling_transform.h"
#include <utility>
#include "src/ast/array_accessor_expression.h"
#include "src/ast/assignment_statement.h"
#include "src/ast/binary_expression.h"

View File

@ -15,6 +15,11 @@
#ifndef SRC_TRANSFORM_VERTEX_PULLING_TRANSFORM_H_
#define SRC_TRANSFORM_VERTEX_PULLING_TRANSFORM_H_
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "src/ast/expression.h"
#include "src/ast/function.h"
#include "src/ast/module.h"
@ -23,11 +28,6 @@
#include "src/context.h"
#include "src/transform/transformer.h"
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
namespace tint {
namespace transform {

View File

@ -14,6 +14,8 @@
#include "src/transform/vertex_pulling_transform.h"
#include <utility>
#include "gtest/gtest.h"
#include "src/ast/decorated_variable.h"
#include "src/ast/function.h"

View File

@ -552,8 +552,8 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
return true;
}
if (ast::intrinsic::IsTextureIntrinsic(ident->intrinsic())) {
// TODO: Remove the LOD param from textureLoad on storage textures when
// https://github.com/gpuweb/gpuweb/pull/1032 gets merged.
// TODO(dsinclair): Remove the LOD param from textureLoad on storage
// textures when https://github.com/gpuweb/gpuweb/pull/1032 gets merged.
uint32_t num_of_params =
(ident->intrinsic() == ast::Intrinsic::kTextureLoad ||
ident->intrinsic() == ast::Intrinsic::kTextureSample)

View File

@ -17,6 +17,7 @@
#include <string>
#include <unordered_map>
#include <vector>
#include "src/ast/module.h"
#include "src/ast/type/storage_texture_type.h"

View File

@ -13,6 +13,7 @@
// limitations under the License.
#include "src/validator.h"
#include "src/validator_impl.h"
namespace tint {

View File

@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/validator_impl.h"
#include "gtest/gtest.h"
#include "spirv/unified1/GLSL.std.450.h"
#include "src/ast/case_statement.h"
@ -30,6 +28,7 @@
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
#include "src/type_determiner.h"
#include "src/validator_impl.h"
#include "src/validator_test_helper.h"
namespace tint {

View File

@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/validator_impl.h"
#include "gtest/gtest.h"
#include "spirv/unified1/GLSL.std.450.h"
#include "src/ast/call_statement.h"
@ -28,6 +26,7 @@
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
#include "src/type_determiner.h"
#include "src/validator_impl.h"
#include "src/validator_test_helper.h"
namespace tint {

View File

@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/validator_impl.h"
#include "gtest/gtest.h"
#include "spirv/unified1/GLSL.std.450.h"
#include "src/ast/array_accessor_expression.h"
@ -54,6 +52,7 @@
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
#include "src/type_determiner.h"
#include "src/validator_impl.h"
#include "src/validator_test_helper.h"
namespace tint {

View File

@ -13,6 +13,9 @@
// limitations under the License.
#include "src/validator_test_helper.h"
#include <memory>
#include "src/type_manager.h"
namespace tint {

View File

@ -15,6 +15,8 @@
#ifndef SRC_VALIDATOR_TEST_HELPER_H_
#define SRC_VALIDATOR_TEST_HELPER_H_
#include <memory>
#include "src/ast/type/void_type.h"
#include "src/type_determiner.h"
#include "src/validator_impl.h"

View File

@ -14,7 +14,10 @@
#include "src/writer/hlsl/generator_impl.h"
#include <limits>
#include <sstream>
#include <utility>
#include <vector>
#include "src/ast/array_accessor_expression.h"
#include "src/ast/assignment_statement.h"

View File

@ -15,6 +15,9 @@
#ifndef SRC_WRITER_HLSL_GENERATOR_IMPL_H_
#define SRC_WRITER_HLSL_GENERATOR_IMPL_H_
#include <string>
#include <unordered_map>
#include "src/ast/intrinsic.h"
#include "src/ast/literal.h"
#include "src/ast/module.h"

View File

@ -65,7 +65,8 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_UInt) {
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Float) {
ast::type::F32Type f32;
// Use a number close to 1<<30 but whose decimal representation ends in 0.
auto lit = std::make_unique<ast::FloatLiteral>(&f32, float((1 << 30) - 4));
auto lit = std::make_unique<ast::FloatLiteral>(
&f32, static_cast<float>((1 << 30) - 4));
ast::ScalarConstructorExpression expr(std::move(lit));
ASSERT_TRUE(gen().EmitConstructor(pre(), out(), &expr)) << gen().error();

View File

@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <memory>
#include "src/ast/assignment_statement.h"
#include "src/ast/decorated_variable.h"
#include "src/ast/identifier_expression.h"
@ -30,8 +32,6 @@
#include "src/type_determiner.h"
#include "src/writer/hlsl/test_helper.h"
#include <memory>
namespace tint {
namespace writer {
namespace hlsl {

View File

@ -564,7 +564,7 @@ void frag_main() {
TEST_F(
HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_Called_By_EntryPoints_WithLocationGlobals_And_Params) {
Emit_FunctionDecoration_Called_By_EntryPoints_WithLocationGlobals_And_Params) { // NOLINT
ast::type::VoidType void_type;
ast::type::F32Type f32;
@ -731,7 +731,7 @@ ep_1_out ep_1() {
TEST_F(
HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_Called_By_EntryPoints_WithBuiltinGlobals_And_Params) {
Emit_FunctionDecoration_Called_By_EntryPoints_WithBuiltinGlobals_And_Params) { // NOLINT
ast::type::VoidType void_type;
ast::type::F32Type f32;
ast::type::VectorType vec4(&f32, 4);

View File

@ -1041,7 +1041,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
TEST_F(
HlslGeneratorImplTest_MemberAccessor,
EmitExpression_MemberAccessor_StorageBuffer_Load_MultiLevel_Swizzle_SingleLetter) {
EmitExpression_MemberAccessor_StorageBuffer_Load_MultiLevel_Swizzle_SingleLetter) { // NOLINT
// struct Data {
// [[offset(0)]] a : vec3<i32>;
// [[offset(16)]] b : vec3<f32>;

View File

@ -13,6 +13,7 @@
// limitations under the License.
#include "src/writer/hlsl/namer.h"
#include "gtest/gtest.h"
namespace tint {

View File

@ -16,6 +16,7 @@
#define SRC_WRITER_HLSL_TEST_HELPER_H_
#include <sstream>
#include <string>
#include "gtest/gtest.h"
#include "src/ast/module.h"

View File

@ -14,6 +14,11 @@
#include "src/writer/msl/generator_impl.h"
#include <algorithm>
#include <limits>
#include <utility>
#include <vector>
#include "src/ast/array_accessor_expression.h"
#include "src/ast/assignment_statement.h"
#include "src/ast/binary_expression.h"

View File

@ -72,7 +72,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_UInt) {
TEST_F(MslGeneratorImplTest, EmitConstructor_Float) {
ast::type::F32Type f32;
// Use a number close to 1<<30 but whose decimal representation ends in 0.
auto lit = std::make_unique<ast::FloatLiteral>(&f32, float((1 << 30) - 4));
auto lit = std::make_unique<ast::FloatLiteral>(
&f32, static_cast<float>((1 << 30) - 4));
ast::ScalarConstructorExpression expr(std::move(lit));
ast::Module m;

View File

@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <memory>
#include "gtest/gtest.h"
#include "src/ast/assignment_statement.h"
#include "src/ast/decorated_variable.h"
@ -30,8 +32,6 @@
#include "src/type_determiner.h"
#include "src/writer/msl/generator_impl.h"
#include <memory>
namespace tint {
namespace writer {
namespace msl {

View File

@ -485,7 +485,7 @@ fragment void frag_main(const device Data& coord [[buffer(0)]]) {
TEST_F(
MslGeneratorImplTest,
Emit_FunctionDecoration_Called_By_EntryPoints_WithLocationGlobals_And_Params) {
Emit_FunctionDecoration_Called_By_EntryPoints_WithLocationGlobals_And_Params) { // NOLINT
ast::type::VoidType void_type;
ast::type::F32Type f32;
@ -666,7 +666,7 @@ fragment ep_1_out ep_1() {
TEST_F(
MslGeneratorImplTest,
Emit_FunctionDecoration_Called_By_EntryPoints_WithBuiltinGlobals_And_Params) {
Emit_FunctionDecoration_Called_By_EntryPoints_WithBuiltinGlobals_And_Params) { // NOLINT
ast::type::VoidType void_type;
ast::type::F32Type f32;
ast::type::VectorType vec4(&f32, 4);

View File

@ -15,6 +15,7 @@
#include "src/writer/msl/generator_impl.h"
#include <memory>
#include <utility>
#include "gtest/gtest.h"
#include "src/ast/function.h"

View File

@ -13,6 +13,7 @@
// limitations under the License.
#include "src/writer/msl/namer.h"
#include "gtest/gtest.h"
namespace tint {

View File

@ -13,6 +13,7 @@
#include "src/writer/spirv/builder.h"
#include <iostream>
#include <limits>
#include <sstream>
#include <utility>
@ -69,8 +70,6 @@
#include "src/ast/unary_op_expression.h"
#include "src/ast/variable_decl_statement.h"
#include <iostream>
namespace tint {
namespace writer {
namespace spirv {
@ -1866,8 +1865,8 @@ uint32_t Builder::GenerateTextureIntrinsic(ast::IdentifierExpression* ident,
auto* texture_type =
call->params()[0].get()->result_type()->UnwrapAll()->AsTexture();
// TODO: Remove the LOD param from textureLoad on storage textures when
// https://github.com/gpuweb/gpuweb/pull/1032 gets merged.
// TODO(dsinclair): Remove the LOD param from textureLoad on storage textures
// when https://github.com/gpuweb/gpuweb/pull/1032 gets merged.
if (ident->intrinsic() == ast::Intrinsic::kTextureLoad) {
std::vector<Operand> spirv_params = {
std::move(wgsl_params[0]), std::move(wgsl_params[1]),

View File

@ -74,7 +74,7 @@ TEST_P(FunctionDecoration_StageTest, Emit) {
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
auto preamble = b.entry_points();
ASSERT_TRUE(preamble.size() >= 1u);
ASSERT_GE(preamble.size(), 1u);
EXPECT_EQ(preamble[0].opcode(), spv::Op::OpEntryPoint);
ASSERT_GE(preamble[0].operands().size(), 3u);

View File

@ -16,6 +16,7 @@
#define SRC_WRITER_SPIRV_GENERATOR_H_
#include <memory>
#include <string>
#include <vector>
#include "src/ast/module.h"

View File

@ -67,7 +67,8 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_UInt) {
TEST_F(WgslGeneratorImplTest, EmitConstructor_Float) {
ast::type::F32Type f32;
// Use a number close to 1<<30 but whose decimal representation ends in 0.
auto lit = std::make_unique<ast::FloatLiteral>(&f32, float((1 << 30) - 4));
auto lit = std::make_unique<ast::FloatLiteral>(
&f32, static_cast<float>((1 << 30) - 4));
ast::ScalarConstructorExpression expr(std::move(lit));
GeneratorImpl g;

View File

@ -15,5 +15,6 @@
set -e # fail on error
./third_party/cpplint/cpplint/cpplint.py --root=. `find src -type f`
./third_party/cpplint/cpplint/cpplint.py --root=. `find samples -type f`
FILTER="-runtime/references"
./third_party/cpplint/cpplint/cpplint.py --root=. --filter="$FILTER" `find src -type f`
./third_party/cpplint/cpplint/cpplint.py --root=. --filter="$FILTER" `find samples -type f`