diff options
author | dan sinclair <dj2@everburning.com> | 2018-11-22 16:57:29 -0500 |
---|---|---|
committer | David Neto <dneto@google.com> | 2018-11-22 16:57:29 -0500 |
commit | da74d350d628dca19c9ac2b6c057e518203eb3f3 (patch) | |
tree | af761aa698eb184bfd861edb06ba0ed7edcf9045 | |
parent | fcef06cabdfb1cb5c13001ebae8bb5e2b14681bf (diff) | |
download | amber-da74d350d628dca19c9ac2b6c057e518203eb3f3.tar.gz |
Add cpplint (#90)
Add cpplint
50 files changed, 317 insertions, 184 deletions
@@ -1,4 +1,5 @@ out +third_party/cpplint third_party/glslang third_party/googletest third_party/shaderc diff --git a/CPPLINT.cfg b/CPPLINT.cfg new file mode 100644 index 0000000..48172ca --- /dev/null +++ b/CPPLINT.cfg @@ -0,0 +1,2 @@ +set noparent +headers=h,hpp @@ -4,14 +4,18 @@ vars = { 'google_git': 'https://github.com/google', 'khronos_git': 'https://github.com/KhronosGroup', + 'cpplint_revision': '9f41862c0efa7681e2147910d39629c73a2b2702', 'glslang_revision': 'd2a7b07a64811bb4a734bd66ef4e0b4c7d7fe1af', 'googletest_revision': 'd5932506d6eed73ac80b9bcc47ed723c8c74eb1e', 'shaderc_revision': '75441559fdb99856be9c02c0abd9c8e23b405033', 'spirv_headers_revision': '7cb43009d543e90698dd300eb26dfd6d9a9bb100', - 'spirv_tools_revision': 'b0c143c8eb23ea68fc815882b891a13814e9663b', + 'spirv_tools_revision': '78c951b3f69974d0a31c95174446985da1244c4d', } deps = { + 'third_party/cpplint': vars['google_git'] + '/styleguide.git@' + + vars['cpplint_revision'], + 'third_party/googletest': vars['google_git'] + '/googletest.git@' + vars['googletest_revision'], diff --git a/include/amber/amber.h b/include/amber/amber.h index 52338a4..343a564 100644 --- a/include/amber/amber.h +++ b/include/amber/amber.h @@ -15,10 +15,10 @@ #ifndef AMBER_AMBER_H_ #define AMBER_AMBER_H_ -#include "amber/result.h" - #include <string> +#include "amber/result.h" + namespace amber { enum class EngineType : uint8_t { diff --git a/include/amber/result.h b/include/amber/result.h index ec57289..d74156d 100644 --- a/include/amber/result.h +++ b/include/amber/result.h @@ -23,7 +23,7 @@ namespace amber { class Result { public: Result(); - Result(const std::string& err); + explicit Result(const std::string& err); Result(const Result&); ~Result(); diff --git a/kokoro/check-format/build.sh b/kokoro/check-format/build.sh index 05b24a9..9c104f0 100644 --- a/kokoro/check-format/build.sh +++ b/kokoro/check-format/build.sh @@ -19,6 +19,19 @@ set -x # display commands BUILD_ROOT=$PWD SRC=$PWD/github/amber +cd $SRC +./tools/git-sync-deps + +echo $(date): Check copyright... +./tools/copyright.py --check; +echo $(date): check completed. + +echo $(date): Linting... +./tools/run-lint.sh; +echo $(date): check complete. + +# Check format adds a bunch of stuff to the repo so do that check last. + # Get clang-format-5.0.0. # Once kokoro upgrades the Ubuntu VMs, we can use 'apt-get install clang-format' curl -L http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz -o clang-llvm.tar.xz @@ -31,10 +44,3 @@ curl -L http://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/clang-form echo $(date): Check formatting... ./tools/check_code_format.sh; echo $(date): check completed. - -# Remove the formatter -rm tools/clang-format-diff.py - -echo $(date): Check copyright... -./tools/copyright.py --check; -echo $(date): check completed. diff --git a/samples/amber.cc b/samples/amber.cc index b03a3da..1ad9941 100644 --- a/samples/amber.cc +++ b/samples/amber.cc @@ -28,7 +28,7 @@ struct Options { std::string image_filename; std::string buffer_filename; - long buffer_binding_index = 0; + int64_t buffer_binding_index = 0; bool parse_only = false; bool show_help = false; bool show_version_info = false; @@ -72,9 +72,10 @@ bool ParseArgs(const std::vector<std::string>& args, Options* opts) { std::cerr << "Missing value for -B argument." << std::endl; return false; } - opts->buffer_binding_index = strtol(args[i].c_str(), nullptr, 10); + opts->buffer_binding_index = + static_cast<int64_t>(strtol(args[i].c_str(), nullptr, 10)); - if (opts->buffer_binding_index < 0) { + if (opts->buffer_binding_index < 0U) { std::cerr << "Invalid value for -B, must be 0 or greater." << std::endl; return false; } @@ -124,7 +125,7 @@ std::string ReadFile(const std::string& input_file) { } fseek(file, 0, SEEK_END); - long tell_file_size = ftell(file); + uint64_t tell_file_size = static_cast<uint64_t>(ftell(file)); if (tell_file_size <= 0) { std::cerr << "Input file of incorrect size: " << input_file << std::endl; return {}; diff --git a/src/amber_impl.cc b/src/amber_impl.cc index 93e61a7..f73a60f 100644 --- a/src/amber_impl.cc +++ b/src/amber_impl.cc @@ -14,6 +14,9 @@ #include "src/amber_impl.h" +#include <memory> +#include <string> + #include "src/amberscript/executor.h" #include "src/amberscript/parser.h" #include "src/engine.h" diff --git a/src/amber_impl.h b/src/amber_impl.h index 5b962a8..26b100a 100644 --- a/src/amber_impl.h +++ b/src/amber_impl.h @@ -15,6 +15,8 @@ #ifndef SRC_AMBER_IMPL_H_ #define SRC_AMBER_IMPL_H_ +#include <string> + #include "amber/amber.h" #include "amber/result.h" diff --git a/src/amberscript/parser.cc b/src/amberscript/parser.cc index 07a201b..68a6752 100644 --- a/src/amberscript/parser.cc +++ b/src/amberscript/parser.cc @@ -16,6 +16,8 @@ #include <cassert> #include <limits> +#include <utility> +#include <vector> #include "src/make_unique.h" #include "src/tokenizer.h" diff --git a/src/amberscript/parser_test.cc b/src/amberscript/parser_test.cc index c697718..276ac4b 100644 --- a/src/amberscript/parser_test.cc +++ b/src/amberscript/parser_test.cc @@ -12,8 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/amberscript/parser.h" +#include <vector> + #include "gtest/gtest.h" +#include "src/amberscript/parser.h" namespace amber { namespace amberscript { @@ -140,13 +142,14 @@ TEST_P(AmberScriptParserShaderPassThroughTest, ShaderPassThroughWithoutVertex) { "allowed", r.Error()); } -INSTANTIATE_TEST_CASE_P(AmberScriptParserShaderPassThroughTests, - AmberScriptParserShaderPassThroughTest, - testing::Values(NameData{"fragment"}, - NameData{"geometry"}, - NameData{"tessellation_evaluation"}, - NameData{"tessellation_control"}, - NameData{"compute"}), ); +INSTANTIATE_TEST_CASE_P( + AmberScriptParserShaderPassThroughTests, + AmberScriptParserShaderPassThroughTest, + testing::Values(NameData{"fragment"}, + NameData{"geometry"}, + NameData{"tessellation_evaluation"}, + NameData{"tessellation_control"}, + NameData{"compute"}), ); // NOLINT(whitespace/parens) TEST_F(AmberScriptParserTest, ShaderPassThroughUnknownShaderType) { std::string in = "SHADER UNKNOWN my_shader PASSTHROUGH"; @@ -326,7 +329,9 @@ INSTANTIATE_TEST_CASE_P( ShaderType::kTessellationEvaluation}, ShaderTypeData{"tessellation_control", ShaderType::kTessellationControl}, - ShaderTypeData{"compute", ShaderType::kCompute}), ); + ShaderTypeData{ + "compute", + ShaderType::kCompute}), ); // NOLINT(whitespace/parens) using AmberScriptParserShaderFormatTest = testing::TestWithParam<ShaderFormatData>; @@ -358,9 +363,12 @@ TEST_P(AmberScriptParserShaderFormatTest, ShaderFormats) { INSTANTIATE_TEST_CASE_P( AmberScriptParserTestsShaderFormat, AmberScriptParserShaderFormatTest, - testing::Values(ShaderFormatData{"GLSL", ShaderFormat::kGlsl}, - ShaderFormatData{"SPIRV-ASM", ShaderFormat::kSpirvAsm}, - ShaderFormatData{"SPIRV-HEX", ShaderFormat::kSpirvHex}), ); + testing::Values( + ShaderFormatData{"GLSL", ShaderFormat::kGlsl}, + ShaderFormatData{"SPIRV-ASM", ShaderFormat::kSpirvAsm}, + ShaderFormatData{ + "SPIRV-HEX", + ShaderFormat::kSpirvHex}), ); // NOLINT(whitespace/parens) TEST_F(AmberScriptParserTest, DuplicateShaderName) { std::string in = R"( @@ -629,13 +637,15 @@ END)"; INSTANTIATE_TEST_CASE_P( AmberScriptParserPipelineAttachTests, AmberScriptParserPipelineAttachTest, - testing::Values(ShaderTypeData{"vertex", ShaderType::kVertex}, - ShaderTypeData{"fragment", ShaderType::kFragment}, - ShaderTypeData{"geometry", ShaderType::kGeometry}, - ShaderTypeData{"tessellation_evaluation", - ShaderType::kTessellationEvaluation}, - ShaderTypeData{"tessellation_control", - ShaderType::kTessellationControl}), ); + testing::Values( + ShaderTypeData{"vertex", ShaderType::kVertex}, + ShaderTypeData{"fragment", ShaderType::kFragment}, + ShaderTypeData{"geometry", ShaderType::kGeometry}, + ShaderTypeData{"tessellation_evaluation", + ShaderType::kTessellationEvaluation}, + ShaderTypeData{ + "tessellation_control", + ShaderType::kTessellationControl}), ); // NOLINT(whitespace/parens) TEST_F(AmberScriptParserTest, PipelineEntryPoint) { std::string in = R"( @@ -1598,7 +1608,9 @@ INSTANTIATE_TEST_CASE_P( BufferTypeData{"index", BufferType::kIndex}, BufferTypeData{"sampled", BufferType::kSampled}, BufferTypeData{"color", BufferType::kColor}, - BufferTypeData{"depth", BufferType::kDepth}), ); + BufferTypeData{ + "depth", + BufferType::kDepth}), ); // NOLINT(whitespace/parens) using AmberScriptParserBufferDataTypeTest = testing::TestWithParam<BufferData>; TEST_P(AmberScriptParserBufferDataTypeTest, BufferTypes) { @@ -1639,7 +1651,8 @@ INSTANTIATE_TEST_CASE_P( BufferData{"vec4<uint32>", DataType::kUint32, 4, 1}, BufferData{"mat2x4<int32>", DataType::kInt32, 2, 4}, BufferData{"mat3x3<float>", DataType::kFloat, 3, 3}, - BufferData{"mat4x2<uint16>", DataType::kUint16, 4, 2}), ); + BufferData{"mat4x2<uint16>", DataType::kUint16, 4, + 2}), ); // NOLINT(whitespace/parens) using AmberScriptParserBufferDataTypeInvalidTest = testing::TestWithParam<NameData>; @@ -1654,31 +1667,32 @@ TEST_P(AmberScriptParserBufferDataTypeInvalidTest, BufferTypes) { ASSERT_FALSE(r.IsSuccess()) << test_data.name; EXPECT_EQ("1: invalid data_type provided", r.Error()) << test_data.name; } -INSTANTIATE_TEST_CASE_P(AmberScriptParserBufferDataTypeInvalidTest, - AmberScriptParserBufferDataTypeInvalidTest, - testing::Values(NameData{"int17"}, - NameData{"uintt0"}, - NameData{"vec7<uint8>"}, - NameData{"vec27<uint8>"}, - NameData{"vec2<vec2<float>>"}, - NameData{"vec2<mat2x2<float>>"}, - NameData{"vec2float>"}, - NameData{"vec2<uint32"}, - NameData{"vec2<uint4>"}, - NameData{"vec2<>"}, - NameData{"vec2"}, - NameData{"mat1x1<double>"}, - NameData{"mat5x2<double>"}, - NameData{"mat2x5<double>"}, - NameData{"mat22x22<double>"}, - NameData{"matx5<double>"}, - NameData{"mat2<double>"}, - NameData{"mat2x<double>"}, - NameData{"mat2x2<vec4<float>>"}, - NameData{"mat2x2<mat3x3<double>>"}, - NameData{"mat2x2<unit7>"}, - NameData{"mat2x2"}, - NameData{"mat2x2<>"}), ); +INSTANTIATE_TEST_CASE_P( + AmberScriptParserBufferDataTypeInvalidTest, + AmberScriptParserBufferDataTypeInvalidTest, + testing::Values(NameData{"int17"}, + NameData{"uintt0"}, + NameData{"vec7<uint8>"}, + NameData{"vec27<uint8>"}, + NameData{"vec2<vec2<float>>"}, + NameData{"vec2<mat2x2<float>>"}, + NameData{"vec2float>"}, + NameData{"vec2<uint32"}, + NameData{"vec2<uint4>"}, + NameData{"vec2<>"}, + NameData{"vec2"}, + NameData{"mat1x1<double>"}, + NameData{"mat5x2<double>"}, + NameData{"mat2x5<double>"}, + NameData{"mat22x22<double>"}, + NameData{"matx5<double>"}, + NameData{"mat2<double>"}, + NameData{"mat2x<double>"}, + NameData{"mat2x2<vec4<float>>"}, + NameData{"mat2x2<mat3x3<double>>"}, + NameData{"mat2x2<unit7>"}, + NameData{"mat2x2"}, + NameData{"mat2x2<>"}), ); // NOLINT(whitespace/parens) } // namespace amberscript } // namespace amber diff --git a/src/amberscript/pipeline.h b/src/amberscript/pipeline.h index 3bf5d68..99a1198 100644 --- a/src/amberscript/pipeline.h +++ b/src/amberscript/pipeline.h @@ -30,7 +30,7 @@ class Pipeline { public: class ShaderInfo { public: - ShaderInfo(const Shader*); + explicit ShaderInfo(const Shader*); ShaderInfo(const ShaderInfo&); ~ShaderInfo(); @@ -52,7 +52,7 @@ class Pipeline { std::string entry_point_; }; - Pipeline(PipelineType type); + explicit Pipeline(PipelineType type); ~Pipeline(); PipelineType GetType() const { return pipeline_type_; } diff --git a/src/amberscript/pipeline_test.cc b/src/amberscript/pipeline_test.cc index 4d6f366..b0866f1 100644 --- a/src/amberscript/pipeline_test.cc +++ b/src/amberscript/pipeline_test.cc @@ -97,11 +97,13 @@ TEST_P(AmberScriptPipelineComputePipelineTest, INSTANTIATE_TEST_CASE_P( AmberScriptPipelineComputePipelineTests, AmberScriptPipelineComputePipelineTest, - testing::Values(ShaderTypeData{ShaderType::kVertex}, - ShaderTypeData{ShaderType::kFragment}, - ShaderTypeData{ShaderType::kGeometry}, - ShaderTypeData{ShaderType::kTessellationEvaluation}, - ShaderTypeData{ShaderType::kTessellationControl}), ); + testing::Values( + ShaderTypeData{ShaderType::kVertex}, + ShaderTypeData{ShaderType::kFragment}, + ShaderTypeData{ShaderType::kGeometry}, + ShaderTypeData{ShaderType::kTessellationEvaluation}, + ShaderTypeData{ + ShaderType::kTessellationControl}), ); // NOLINT(whitespace/parens) TEST_F(AmberScriptPipelineTest, SettingComputeShaderToGraphicsPipeline) { Shader c(ShaderType::kCompute); diff --git a/src/amberscript/script.h b/src/amberscript/script.h index 5ddcc0a..fd394a1 100644 --- a/src/amberscript/script.h +++ b/src/amberscript/script.h @@ -17,6 +17,8 @@ #include <map> #include <memory> +#include <string> +#include <utility> #include <vector> #include "src/amberscript/pipeline.h" diff --git a/src/amberscript/script_test.cc b/src/amberscript/script_test.cc index f1a168e..e117ccd 100644 --- a/src/amberscript/script_test.cc +++ b/src/amberscript/script_test.cc @@ -12,9 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/amberscript/script.h" +#include <utility> + #include "gtest/gtest.h" #include "src/amberscript/pipeline.h" +#include "src/amberscript/script.h" #include "src/amberscript/shader.h" #include "src/buffer.h" #include "src/make_unique.h" diff --git a/src/amberscript/shader.h b/src/amberscript/shader.h index eb6e1a2..0d17f21 100644 --- a/src/amberscript/shader.h +++ b/src/amberscript/shader.h @@ -24,7 +24,7 @@ namespace amberscript { class Shader { public: - Shader(ShaderType type); + explicit Shader(ShaderType type); ~Shader(); ShaderType GetType() const { return shader_type_; } diff --git a/src/buffer.h b/src/buffer.h index 8ba89e4..4b8dd6d 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -17,6 +17,7 @@ #include <cstdint> #include <string> +#include <utility> #include <vector> #include "src/buffer_data.h" @@ -64,4 +65,4 @@ class Buffer { } // namespace amber -#endif // SRC_AMBERSCRIPT_BUFFER_H_ +#endif // SRC_BUFFER_H_ diff --git a/src/buffer_test.cc b/src/buffer_test.cc index cc8cd17..dedcaba 100644 --- a/src/buffer_test.cc +++ b/src/buffer_test.cc @@ -12,8 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/buffer.h" +#include <utility> + #include "gtest/gtest.h" +#include "src/buffer.h" namespace amber { diff --git a/src/command.h b/src/command.h index 7186b62..b2e8540 100644 --- a/src/command.h +++ b/src/command.h @@ -17,6 +17,7 @@ #include <cstdint> #include <string> +#include <utility> #include <vector> #include "src/command_data.h" @@ -93,14 +94,14 @@ class Command { ToleranceCommand* AsTolerance(); protected: - Command(Type type); + explicit Command(Type type); Type command_type_; }; class DrawRectCommand : public Command { public: - DrawRectCommand(PipelineData data); + explicit DrawRectCommand(PipelineData data); ~DrawRectCommand() override; const PipelineData* GetPipelineData() const { return &data_; } @@ -135,7 +136,7 @@ class DrawRectCommand : public Command { class DrawArraysCommand : public Command { public: - DrawArraysCommand(PipelineData data); + explicit DrawArraysCommand(PipelineData data); ~DrawArraysCommand() override; const PipelineData* GetPipelineData() const { return &data_; } @@ -170,7 +171,7 @@ class DrawArraysCommand : public Command { class ComputeCommand : public Command { public: - ComputeCommand(PipelineData data); + explicit ComputeCommand(PipelineData data); ~ComputeCommand() override; const PipelineData* GetPipelineData() const { return &data_; } @@ -301,7 +302,7 @@ class BufferCommand : public Command { kPushConstant, }; - BufferCommand(BufferType type); + explicit BufferCommand(BufferType type); ~BufferCommand() override; bool IsSSBO() const { return buffer_type_ == BufferType::kSSBO; } diff --git a/src/command_data.cc b/src/command_data.cc index 6037907..80083e1 100644 --- a/src/command_data.cc +++ b/src/command_data.cc @@ -17,7 +17,7 @@ namespace amber { Topology NameToTopology(const std::string& name) { - const static struct { + static const struct { const char* name; Topology val; } topologies[] = { diff --git a/src/dawn/engine_dawn.cc b/src/dawn/engine_dawn.cc index d51aa04..6277e57 100644 --- a/src/dawn/engine_dawn.cc +++ b/src/dawn/engine_dawn.cc @@ -15,6 +15,7 @@ #include "src/dawn/engine_dawn.h" #include <utility> +#include <vector> #include "dawn/dawncpp.h" #include "src/dawn/device_metal.h" diff --git a/src/dawn/engine_dawn.h b/src/dawn/engine_dawn.h index 4bdc816..67d71e5 100644 --- a/src/dawn/engine_dawn.h +++ b/src/dawn/engine_dawn.h @@ -16,6 +16,8 @@ #define SRC_DAWN_ENGINE_DAWN_H_ #include <unordered_map> +#include <vector> + #include "dawn/dawncpp.h" #include "src/cast_hash.h" #include "src/command.h" diff --git a/src/dawn/pipeline_info.h b/src/dawn/pipeline_info.h index 9ff14ec..0509224 100644 --- a/src/dawn/pipeline_info.h +++ b/src/dawn/pipeline_info.h @@ -64,7 +64,7 @@ class ComputePipelineInfo { : compute_shader_(comp) {} // Returns true if this render pipeline is configured at all. - bool IsConfigured() const { return bool(compute_shader_); } + bool IsConfigured() const { return static_cast<bool>(compute_shader_); } private: ::dawn::ShaderModule compute_shader_; diff --git a/src/engine.h b/src/engine.h index 4c2677b..8519083 100644 --- a/src/engine.h +++ b/src/engine.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef ENGINE_H_ -#define ENGINE_H_ +#ifndef SRC_ENGINE_H_ +#define SRC_ENGINE_H_ #include <memory> #include <vector> @@ -115,4 +115,4 @@ class Engine { } // namespace amber -#endif // ENGINE_H_ +#endif // SRC_ENGINE_H_ diff --git a/src/pipeline_data.h b/src/pipeline_data.h index 6e5b9da..1a265b8 100644 --- a/src/pipeline_data.h +++ b/src/pipeline_data.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_PIPELINE_H_ -#define SRC_PIPELINE_H_ +#ifndef SRC_PIPELINE_DATA_H_ +#define SRC_PIPELINE_DATA_H_ #include <limits> @@ -214,4 +214,4 @@ class PipelineData { } // namespace amber -#endif // SRC_PIPELINE_H_ +#endif // SRC_PIPELINE_DATA_H_ diff --git a/src/script.h b/src/script.h index 4680014..2d91329 100644 --- a/src/script.h +++ b/src/script.h @@ -31,7 +31,7 @@ class Script { } protected: - Script(ScriptType); + explicit Script(ScriptType); private: ScriptType script_type_; diff --git a/src/shader_compiler.cc b/src/shader_compiler.cc index a5294c7..77e8e75 100644 --- a/src/shader_compiler.cc +++ b/src/shader_compiler.cc @@ -17,6 +17,8 @@ #include <algorithm> #include <cstdlib> #include <iterator> +#include <string> +#include <utility> #include "spirv-tools/libspirv.hpp" #include "spirv-tools/linker.hpp" @@ -97,7 +99,7 @@ Result ShaderCompiler::ParseHex(const std::string& data, uint32_t tmp = 0; while (used < data.length()) { char* new_pos = nullptr; - long v = std::strtol(str, &new_pos, 16); + uint64_t v = static_cast<uint64_t>(std::strtol(str, &new_pos, 16)); ++converted; diff --git a/src/shader_compiler.h b/src/shader_compiler.h index 4fd32a6..ec4848a 100644 --- a/src/shader_compiler.h +++ b/src/shader_compiler.h @@ -15,7 +15,8 @@ #ifndef SRC_SHADER_COMPILER_H_ #define SRC_SHADER_COMPILER_H_ -#include <tuple> +#include <string> +#include <utility> #include <vector> #include "amber/result.h" diff --git a/src/shader_compiler_test.cc b/src/shader_compiler_test.cc index 5465331..c65a152 100644 --- a/src/shader_compiler_test.cc +++ b/src/shader_compiler_test.cc @@ -12,8 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/shader_compiler.h" +#include <string> + #include "gtest/gtest.h" +#include "src/shader_compiler.h" #include "src/vkscript/section_parser.h" // For the passthrough vertex shader namespace amber { diff --git a/src/tokenizer.h b/src/tokenizer.h index ee458bd..6b1329b 100644 --- a/src/tokenizer.h +++ b/src/tokenizer.h @@ -34,7 +34,7 @@ enum class TokenType : uint8_t { class Token { public: - Token(TokenType type); + explicit Token(TokenType type); ~Token(); bool IsHex() const { return type_ == TokenType::kHex; } @@ -90,7 +90,7 @@ class Token { class Tokenizer { public: - Tokenizer(const std::string& data); + explicit Tokenizer(const std::string& data); ~Tokenizer(); std::unique_ptr<Token> NextToken(); diff --git a/src/tokenizer_test.cc b/src/tokenizer_test.cc index c57a583..7f35fc0 100644 --- a/src/tokenizer_test.cc +++ b/src/tokenizer_test.cc @@ -12,8 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tokenizer.h" +#include <limits> + #include "gtest/gtest.h" +#include "src/tokenizer.h" namespace amber { diff --git a/src/vkscript/command_parser.cc b/src/vkscript/command_parser.cc index dd012fe..c6885b4 100644 --- a/src/vkscript/command_parser.cc +++ b/src/vkscript/command_parser.cc @@ -17,6 +17,9 @@ #include <algorithm> #include <cassert> #include <cctype> +#include <limits> +#include <string> +#include <utility> #include "src/command_data.h" #include "src/make_unique.h" diff --git a/src/vkscript/command_parser.h b/src/vkscript/command_parser.h index 2ded530..1164aa4 100644 --- a/src/vkscript/command_parser.h +++ b/src/vkscript/command_parser.h @@ -16,6 +16,8 @@ #define SRC_VKSCRIPT_COMMAND_PARSER_H_ #include <memory> +#include <string> +#include <utility> #include <vector> #include "amber/result.h" diff --git a/src/vkscript/command_parser_test.cc b/src/vkscript/command_parser_test.cc index 6841d3d..8ab8e30 100644 --- a/src/vkscript/command_parser_test.cc +++ b/src/vkscript/command_parser_test.cc @@ -807,7 +807,8 @@ TEST_P(CommandParserProbeTest, ProbeRect) { INSTANTIATE_TEST_CASE_P(ProbeTests, CommandParserProbeTest, - testing::Values(false, true), ); + testing::Values(false, + true), ); // NOLINT(whitespace/parens) TEST_F(CommandParserTest, ProbeAllRGB) { std::string data = "probe all rgb 0.2 0.3 0.4"; @@ -1136,8 +1137,10 @@ INSTANTIATE_TEST_CASE_P( Topology::kTriangleListWithAdjacency}, TopologyTestData{"VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP", Topology::kTriangleStrip}, - TopologyTestData{"VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY", - Topology::kTriangleStripWithAdjacency}), ); + TopologyTestData{ + "VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY", + Topology:: + kTriangleStripWithAdjacency}), ); // NOLINT(whitespace/parens) struct PipelineDataInvalidTest { const char* name; @@ -1207,7 +1210,8 @@ INSTANTIATE_TEST_CASE_P( PipelineDataInvalidTest{"polygonMode", "VK_POLYGON_MODE_POINT"}, PipelineDataInvalidTest{"cullMode", "VK_CULL_MODE_BACK_BIT"}, PipelineDataInvalidTest{"frontFace", "VK_FRONT_FACE_COUNTER_CLOCKWISE"}, - PipelineDataInvalidTest{"logicOp", "VK_LOGIC_OP_NO_OP"}), ); + PipelineDataInvalidTest{ + "logicOp", "VK_LOGIC_OP_NO_OP"}), ); // NOLINT(whitespace/parens) TEST_F(CommandParserTest, BooleanTrue) { struct { @@ -1475,18 +1479,20 @@ TEST_P(CommandParserBooleanTests, ExtraParam) { r.Error()); } -INSTANTIATE_TEST_CASE_P(BooleanTests, - CommandParserBooleanTests, - testing::Values(BooleanTest{"primitiveRestartEnable"}, - BooleanTest{"depthClampEnable"}, - BooleanTest{"rasterizerDiscardEnable"}, - BooleanTest{"depthBiasEnable"}, - BooleanTest{"logicOpEnable"}, - BooleanTest{"blendEnable"}, - BooleanTest{"depthTestEnable"}, - BooleanTest{"depthWriteEnable"}, - BooleanTest{"depthBoundsTestEnable"}, - BooleanTest{"stencilTestEnable"}), ); +INSTANTIATE_TEST_CASE_P( + BooleanTests, + CommandParserBooleanTests, + testing::Values(BooleanTest{"primitiveRestartEnable"}, + BooleanTest{"depthClampEnable"}, + BooleanTest{"rasterizerDiscardEnable"}, + BooleanTest{"depthBiasEnable"}, + BooleanTest{"logicOpEnable"}, + BooleanTest{"blendEnable"}, + BooleanTest{"depthTestEnable"}, + BooleanTest{"depthWriteEnable"}, + BooleanTest{"depthBoundsTestEnable"}, + BooleanTest{ + "stencilTestEnable"}), ); // NOLINT(whitespace/parens) struct PolygonModeTestData { const char* name; @@ -1512,7 +1518,9 @@ INSTANTIATE_TEST_CASE_P( testing::Values( PolygonModeTestData{"VK_POLYGON_MODE_FILL", PolygonMode::kFill}, PolygonModeTestData{"VK_POLYGON_MODE_LINE", PolygonMode::kLine}, - PolygonModeTestData{"VK_POLYGON_MODE_POINT", PolygonMode::kPoint}), ); + PolygonModeTestData{ + "VK_POLYGON_MODE_POINT", + PolygonMode::kPoint}), ); // NOLINT(whitespace/parens) struct CullModeTestData { const char* name; @@ -1543,8 +1551,9 @@ INSTANTIATE_TEST_CASE_P( CullMode::kFrontAndBack}, CullModeTestData{"VK_CULL_MODE_FRONT_BIT | VK_CULL_MODE_BACK_BIT", CullMode::kFrontAndBack}, - CullModeTestData{"VK_CULL_MODE_FRONT_AND_BACK", - CullMode::kFrontAndBack}), ); + CullModeTestData{ + "VK_CULL_MODE_FRONT_AND_BACK", + CullMode::kFrontAndBack}), ); // NOLINT(whitespace/parens) struct FrontFaceTestData { const char* name; @@ -1567,10 +1576,12 @@ TEST_P(CommandDataPipelineFrontFaceParser, FrontFace) { INSTANTIATE_TEST_CASE_P( FrontFaceTests, CommandDataPipelineFrontFaceParser, - testing::Values(FrontFaceTestData{"VK_FRONT_FACE_COUNTER_CLOCKWISE", - FrontFace::kCounterClockwise}, - FrontFaceTestData{"VK_FRONT_FACE_CLOCKWISE", - FrontFace::kClockwise}), ); + testing::Values( + FrontFaceTestData{"VK_FRONT_FACE_COUNTER_CLOCKWISE", + FrontFace::kCounterClockwise}, + FrontFaceTestData{ + "VK_FRONT_FACE_CLOCKWISE", + FrontFace::kClockwise}), ); // NOLINT(whitespace/parens) struct LogicOpTestData { const char* name; @@ -1609,7 +1620,8 @@ INSTANTIATE_TEST_CASE_P( LogicOpTestData{"VK_LOGIC_OP_COPY_INVERTED", LogicOp::kCopyInverted}, LogicOpTestData{"VK_LOGIC_OP_OR_INVERTED", LogicOp::kOrInverted}, LogicOpTestData{"VK_LOGIC_OP_NAND", LogicOp::kNand}, - LogicOpTestData{"VK_LOGIC_OP_SET", LogicOp::kSet}), ); + LogicOpTestData{"VK_LOGIC_OP_SET", + LogicOp::kSet}), ); // NOLINT(whitespace/parens) TEST_F(CommandParserTest, DepthBiasConstantFactor) { std::string data = "depthBiasConstantFactor 3.4"; @@ -1706,14 +1718,16 @@ TEST_P(CommandParserFloatTests, ExtraParam) { r.Error()); } -INSTANTIATE_TEST_CASE_P(FloatTests, - CommandParserFloatTests, - testing::Values(FloatTest{"depthBiasConstantFactor"}, - FloatTest{"lineWidth"}, - FloatTest{"depthBiasClamp"}, - FloatTest{"depthBiasSlopeFactor"}, - FloatTest{"minDepthBounds"}, - FloatTest{"maxDepthBounds"}), ); +INSTANTIATE_TEST_CASE_P( + FloatTests, + CommandParserFloatTests, + testing::Values(FloatTest{"depthBiasConstantFactor"}, + FloatTest{"lineWidth"}, + FloatTest{"depthBiasClamp"}, + FloatTest{"depthBiasSlopeFactor"}, + FloatTest{"minDepthBounds"}, + FloatTest{ + "maxDepthBounds"}), ); // NOLINT(whitespace/parens) TEST_F(CommandParserTest, SrcColorBlendFactor) { std::string data = "srcColorBlendFactor VK_BLEND_FACTOR_DST_COLOR"; @@ -1803,8 +1817,9 @@ INSTANTIATE_TEST_CASE_P( BlendFactorData{"VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR", BlendFactor::kOneMinusSrc1Color}, BlendFactorData{"VK_BLEND_FACTOR_SRC1_ALPHA", BlendFactor::kSrc1Alpha}, - BlendFactorData{"VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA", - BlendFactor::kOneMinusSrc1Alpha}), ); + BlendFactorData{ + "VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA", + BlendFactor::kOneMinusSrc1Alpha}), ); // NOLINT(whitespace/parens) TEST_F(CommandParserTest, BlendFactorParsingInvalid) { CommandParser cp; @@ -1855,13 +1870,15 @@ TEST_P(CommandParserBlendFactorTests, ExtraParam) { r.Error()); } -INSTANTIATE_TEST_CASE_P(BlendFactorTests, - CommandParserBlendFactorTests, - testing::Values(BlendFactorTest{"srcColorBlendFactor"}, - BlendFactorTest{"dstColorBlendFactor"}, - BlendFactorTest{"srcAlphaBlendFactor"}, - BlendFactorTest{ - "dstAlphaBlendFactor"}), ); +INSTANTIATE_TEST_CASE_P( + BlendFactorTests, + CommandParserBlendFactorTests, + testing::Values( + BlendFactorTest{"srcColorBlendFactor"}, + BlendFactorTest{"dstColorBlendFactor"}, + BlendFactorTest{"srcAlphaBlendFactor"}, + BlendFactorTest{ + "dstAlphaBlendFactor"}), ); // NOLINT(whitespace/parens) TEST_F(CommandParserTest, ColorBlendOp) { std::string data = "colorBlendOp VK_BLEND_OP_XOR_EXT"; @@ -1929,7 +1946,8 @@ INSTANTIATE_TEST_CASE_P( BlendOpData{"VK_BLEND_OP_SOFTLIGHT_EXT", BlendOp::kSoftLight}, BlendOpData{"VK_BLEND_OP_DIFFERENCE_EXT", BlendOp::kDifference}, BlendOpData{"VK_BLEND_OP_EXCLUSION_EXT", BlendOp::kExclusion}, - BlendOpData{"VK_BLEND_OP_INVERT_EXT", BlendOp::kInvert}), ); + BlendOpData{"VK_BLEND_OP_INVERT_EXT", + BlendOp::kInvert}), ); // NOLINT(whitespace/parens) INSTANTIATE_TEST_CASE_P( BlendOpParsingTests2, @@ -1957,7 +1975,8 @@ INSTANTIATE_TEST_CASE_P( BlendOpData{"VK_BLEND_OP_INVERT_OVG_EXT", BlendOp::kInvertOvg}, BlendOpData{"VK_BLEND_OP_RED_EXT", BlendOp::kRed}, BlendOpData{"VK_BLEND_OP_GREEN_EXT", BlendOp::kGreen}, - BlendOpData{"VK_BLEND_OP_BLUE_EXT", BlendOp::kBlue}), ); + BlendOpData{"VK_BLEND_OP_BLUE_EXT", + BlendOp::kBlue}), ); // NOLINT(whitespace/parens) TEST_F(CommandParserTest, BlendOpParsingInvalid) { CommandParser cp; @@ -2008,10 +2027,12 @@ TEST_P(CommandParserBlendOpTests, ExtraParam) { r.Error()); } -INSTANTIATE_TEST_CASE_P(BlendOpTests, - CommandParserBlendOpTests, - testing::Values(BlendOpTest{"colorBlendOp"}, - BlendOpTest{"alphaBlendOp"}), ); +INSTANTIATE_TEST_CASE_P( + BlendOpTests, + CommandParserBlendOpTests, + testing::Values(BlendOpTest{"colorBlendOp"}, + BlendOpTest{ + "alphaBlendOp"}), ); // NOLINT(whitespace/parens) TEST_F(CommandParserTest, DepthCompareOp) { std::string data = "depthCompareOp VK_COMPARE_OP_EQUAL"; @@ -2070,7 +2091,8 @@ INSTANTIATE_TEST_CASE_P( CompareOpData{"VK_COMPARE_OP_NOT_EQUAL", CompareOp::kNotEqual}, CompareOpData{"VK_COMPARE_OP_GREATER_OR_EQUAL", CompareOp::kGreaterOrEqual}, - CompareOpData{"VK_COMPARE_OP_ALWAYS", CompareOp::kAlways}), ); + CompareOpData{"VK_COMPARE_OP_ALWAYS", + CompareOp::kAlways}), ); // NOLINT(whitespace/parens) TEST_F(CommandParserTest, CompareOpParsingInvalid) { CommandParser cp; @@ -2122,11 +2144,13 @@ TEST_P(CommandParserCompareOpTests, ExtraParam) { r.Error()); } -INSTANTIATE_TEST_CASE_P(CompareOpTests, - CommandParserCompareOpTests, - testing::Values(CompareOpTest{"depthCompareOp"}, - CompareOpTest{"front.compareOp"}, - CompareOpTest{"back.compareOp"}), ); +INSTANTIATE_TEST_CASE_P( + CompareOpTests, + CommandParserCompareOpTests, + testing::Values(CompareOpTest{"depthCompareOp"}, + CompareOpTest{"front.compareOp"}, + CompareOpTest{ + "back.compareOp"}), ); // NOLINT(whitespace/parens) TEST_F(CommandParserTest, FrontFailOp) { std::string data = "front.failOp VK_STENCIL_OP_REPLACE"; @@ -2203,18 +2227,20 @@ TEST_P(CommandParserStencilOpParsing, Parse) { INSTANTIATE_TEST_CASE_P( CompareOpParsingTests, CommandParserStencilOpParsing, - testing::Values(StencilOpData{"VK_STENCIL_OP_KEEP", StencilOp::kKeep}, - StencilOpData{"VK_STENCIL_OP_ZERO", StencilOp::kZero}, - StencilOpData{"VK_STENCIL_OP_REPLACE", StencilOp::kReplace}, - StencilOpData{"VK_STENCIL_OP_INCREMENT_AND_CLAMP", - StencilOp::kIncrementAndClamp}, - StencilOpData{"VK_STENCIL_OP_DECREMENT_AND_CLAMP", - StencilOp::kDecrementAndClamp}, - StencilOpData{"VK_STENCIL_OP_INVERT", StencilOp::kInvert}, - StencilOpData{"VK_STENCIL_OP_INCREMENT_AND_WRAP", - StencilOp::kIncrementAndWrap}, - StencilOpData{"VK_STENCIL_OP_DECREMENT_AND_WRAP", - StencilOp::kDecrementAndWrap}), ); + testing::Values( + StencilOpData{"VK_STENCIL_OP_KEEP", StencilOp::kKeep}, + StencilOpData{"VK_STENCIL_OP_ZERO", StencilOp::kZero}, + StencilOpData{"VK_STENCIL_OP_REPLACE", StencilOp::kReplace}, + StencilOpData{"VK_STENCIL_OP_INCREMENT_AND_CLAMP", + StencilOp::kIncrementAndClamp}, + StencilOpData{"VK_STENCIL_OP_DECREMENT_AND_CLAMP", + StencilOp::kDecrementAndClamp}, + StencilOpData{"VK_STENCIL_OP_INVERT", StencilOp::kInvert}, + StencilOpData{"VK_STENCIL_OP_INCREMENT_AND_WRAP", + StencilOp::kIncrementAndWrap}, + StencilOpData{ + "VK_STENCIL_OP_DECREMENT_AND_WRAP", + StencilOp::kDecrementAndWrap}), ); // NOLINT(whitespace/parens) TEST_F(CommandParserTest, StencilOpParsingInvalid) { CommandParser cp; @@ -2266,14 +2292,16 @@ TEST_P(CommandParserStencilOpTests, ExtraParam) { r.Error()); } -INSTANTIATE_TEST_CASE_P(StencilOpTests, - CommandParserStencilOpTests, - testing::Values(StencilOpTest{"front.passOp"}, - StencilOpTest{"front.failOp"}, - StencilOpTest{"front.depthFailOp"}, - StencilOpTest{"back.passOp"}, - StencilOpTest{"back.failOp"}, - StencilOpTest{"back.depthFailOp"}), ); +INSTANTIATE_TEST_CASE_P( + StencilOpTests, + CommandParserStencilOpTests, + testing::Values(StencilOpTest{"front.passOp"}, + StencilOpTest{"front.failOp"}, + StencilOpTest{"front.depthFailOp"}, + StencilOpTest{"back.passOp"}, + StencilOpTest{"back.failOp"}, + StencilOpTest{ + "back.depthFailOp"}), ); // NOLINT(whitespace/parens) TEST_F(CommandParserTest, FrontCompareMask) { std::string data = "front.compareMask 123"; @@ -2368,10 +2396,12 @@ TEST_P(CommandParserReferenceTests, FrontReferenceInvalidParameters) { r.Error()); } -INSTANTIATE_TEST_CASE_P(ReferenceTest, - CommandParserReferenceTests, - testing::Values(ReferenceData{"front.reference"}, - ReferenceData{"back.reference"}), ); +INSTANTIATE_TEST_CASE_P( + ReferenceTest, + CommandParserReferenceTests, + testing::Values(ReferenceData{"front.reference"}, + ReferenceData{ + "back.reference"}), ); // NOLINT(whitespace/parens) struct ColorMaskData { const char* input; @@ -2400,10 +2430,10 @@ INSTANTIATE_TEST_CASE_P( ColorMaskData{"VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | " "VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT", kColorMaskR | kColorMaskG | kColorMaskB | kColorMaskA}, - ColorMaskData{ - "VK_COLOR_COMPONENT_A_BIT | VK_COLOR_COMPONENT_B_BIT | " - "VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT", - kColorMaskR | kColorMaskG | kColorMaskB | kColorMaskA}), ); + ColorMaskData{"VK_COLOR_COMPONENT_A_BIT | VK_COLOR_COMPONENT_B_BIT | " + "VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT", + kColorMaskR | kColorMaskG | kColorMaskB | + kColorMaskA}), ); // NOLINT(whitespace/parens) TEST_F(CommandParserTest, ColorWriteMaskInvalid) { std::string data = "colorWriteMask INVALID"; @@ -3474,7 +3504,9 @@ INSTANTIATE_TEST_CASE_P( ComparatorTest{"<", ProbeSSBOCommand::Comparator::kLess}, ComparatorTest{"<=", ProbeSSBOCommand::Comparator::kLessOrEqual}, ComparatorTest{">", ProbeSSBOCommand::Comparator::kGreater}, - ComparatorTest{">=", ProbeSSBOCommand::Comparator::kGreaterOrEqual}), ); + ComparatorTest{">=", + ProbeSSBOCommand::Comparator:: + kGreaterOrEqual}), ); // NOLINT(whitespace/parens) TEST_F(CommandParserTest, ComparatorInvalid) { CommandParser cp; diff --git a/src/vkscript/datum_type_parser.h b/src/vkscript/datum_type_parser.h index 4689e33..16369b6 100644 --- a/src/vkscript/datum_type_parser.h +++ b/src/vkscript/datum_type_parser.h @@ -15,6 +15,8 @@ #ifndef SRC_VKSCRIPT_DATUM_TYPE_PARSER_H_ #define SRC_VKSCRIPT_DATUM_TYPE_PARSER_H_ +#include <string> + #include "amber/result.h" #include "src/datum_type.h" diff --git a/src/vkscript/datum_type_parser_test.cc b/src/vkscript/datum_type_parser_test.cc index 27b6f50..34b44a6 100644 --- a/src/vkscript/datum_type_parser_test.cc +++ b/src/vkscript/datum_type_parser_test.cc @@ -85,7 +85,8 @@ INSTANTIATE_TEST_CASE_P( DatumTypeData{"u8vec2", DataType::kUint8, 1, 2}, DatumTypeData{"u8vec3", DataType::kUint8, 1, 3}, DatumTypeData{"u8vec4", DataType::kUint8, 1, 4}, - DatumTypeData{"i16vec2", DataType::kInt16, 1, 2}), ); + DatumTypeData{"i16vec2", DataType::kInt16, 1, + 2}), ); // NOLINT(whitespace/parens) INSTANTIATE_TEST_CASE_P( DatumTypeParserTest2, @@ -124,7 +125,8 @@ INSTANTIATE_TEST_CASE_P( DatumTypeData{"dmat4", DataType::kDouble, 4, 4}, DatumTypeData{"dmat4x2", DataType::kDouble, 4, 2}, DatumTypeData{"dmat4x3", DataType::kDouble, 4, 3}, - DatumTypeData{"dmat4x4", DataType::kDouble, 4, 4}), ); + DatumTypeData{"dmat4x4", DataType::kDouble, 4, + 4}), ); // NOLINT(whitespace/parens) } // namespace vkscript } // namespace amber diff --git a/src/vkscript/executor_test.cc b/src/vkscript/executor_test.cc index 065600c..0aaed38 100644 --- a/src/vkscript/executor_test.cc +++ b/src/vkscript/executor_test.cc @@ -12,10 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/vkscript/executor.h" +#include <memory> +#include <string> +#include <vector> + #include "gtest/gtest.h" #include "src/engine.h" #include "src/make_unique.h" +#include "src/vkscript/executor.h" #include "src/vkscript/parser.h" namespace amber { diff --git a/src/vkscript/format_parser.cc b/src/vkscript/format_parser.cc index 57da26a..7830c37 100644 --- a/src/vkscript/format_parser.cc +++ b/src/vkscript/format_parser.cc @@ -150,7 +150,7 @@ void FormatParser::ProcessChunk(Format* fmt, const std::string& data) { char* next_str; const char* str = data.c_str() + cur_pos; - long val = std::strtol(str, &next_str, 10); + uint64_t val = static_cast<uint64_t>(std::strtol(str, &next_str, 10)); AddPiece(type, static_cast<uint8_t>(val)); cur_pos += static_cast<size_t>(next_str - str); diff --git a/src/vkscript/format_parser.h b/src/vkscript/format_parser.h index 327ade3..7cef303 100644 --- a/src/vkscript/format_parser.h +++ b/src/vkscript/format_parser.h @@ -17,6 +17,7 @@ #include <memory> #include <string> +#include <vector> #include "src/format.h" diff --git a/src/vkscript/format_parser_test.cc b/src/vkscript/format_parser_test.cc index d5bee85..5f97493 100644 --- a/src/vkscript/format_parser_test.cc +++ b/src/vkscript/format_parser_test.cc @@ -1192,7 +1192,7 @@ TEST_F(FormatParserTest, Formats) { EXPECT_EQ(fmt.components[i].num_bits, comps[i].num_bits) << fmt.name; } } -} +} // NOLINT(readability/fn_size) TEST_F(FormatParserTest, InvalidFormat) { FormatParser parser; diff --git a/src/vkscript/nodes.cc b/src/vkscript/nodes.cc index eb09e7c..3fa63f6 100644 --- a/src/vkscript/nodes.cc +++ b/src/vkscript/nodes.cc @@ -15,6 +15,7 @@ #include "src/vkscript/nodes.h" #include <cassert> +#include <utility> namespace amber { namespace vkscript { diff --git a/src/vkscript/nodes.h b/src/vkscript/nodes.h index 4036c39..0630546 100644 --- a/src/vkscript/nodes.h +++ b/src/vkscript/nodes.h @@ -17,6 +17,7 @@ #include <cstdint> #include <memory> +#include <string> #include <vector> #include "src/buffer.h" @@ -52,7 +53,7 @@ class Node { VertexDataNode* AsVertexData(); protected: - Node(NodeType type); + explicit Node(NodeType type); private: NodeType node_type_; @@ -75,7 +76,7 @@ class RequireNode : public Node { public: class Requirement { public: - Requirement(Feature feature); + explicit Requirement(Feature feature); Requirement(Feature feature, std::unique_ptr<Format> format); Requirement(Feature feature, uint32_t value); Requirement(Requirement&&); @@ -110,7 +111,7 @@ class RequireNode : public Node { class IndicesNode : public Node { public: - IndicesNode(std::unique_ptr<Buffer> buffer); + explicit IndicesNode(std::unique_ptr<Buffer> buffer); ~IndicesNode() override; const std::vector<Value>& Indices() const { return buffer_->GetData(); } @@ -147,7 +148,7 @@ class VertexDataNode : public Node { class TestNode : public Node { public: - TestNode(std::vector<std::unique_ptr<Command>> cmds); + explicit TestNode(std::vector<std::unique_ptr<Command>> cmds); ~TestNode() override; const std::vector<std::unique_ptr<Command>>& GetCommands() const { diff --git a/src/vkscript/parser.cc b/src/vkscript/parser.cc index e273a2d..91358d1 100644 --- a/src/vkscript/parser.cc +++ b/src/vkscript/parser.cc @@ -17,6 +17,9 @@ #include <algorithm> #include <cassert> #include <limits> +#include <tuple> +#include <utility> +#include <vector> #include "src/make_unique.h" #include "src/shader_compiler.h" diff --git a/src/vkscript/parser_test.cc b/src/vkscript/parser_test.cc index 5d98b43..f7acbc6 100644 --- a/src/vkscript/parser_test.cc +++ b/src/vkscript/parser_test.cc @@ -12,11 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/vkscript/parser.h" +#include <vector> + #include "gtest/gtest.h" #include "src/feature.h" #include "src/format.h" #include "src/vkscript/nodes.h" +#include "src/vkscript/parser.h" namespace amber { namespace vkscript { diff --git a/src/vkscript/script.cc b/src/vkscript/script.cc index 0b459ff..79a5ca2 100644 --- a/src/vkscript/script.cc +++ b/src/vkscript/script.cc @@ -14,6 +14,8 @@ #include "src/vkscript/script.h" +#include <utility> + #include "src/make_unique.h" #include "src/vkscript/nodes.h" diff --git a/src/vulkan/engine_vulkan.h b/src/vulkan/engine_vulkan.h index 68a5836..36c1423 100644 --- a/src/vulkan/engine_vulkan.h +++ b/src/vulkan/engine_vulkan.h @@ -17,6 +17,7 @@ #include <memory> #include <unordered_map> +#include <vector> #include "src/cast_hash.h" #include "src/engine.h" diff --git a/src/vulkan/frame_buffer.cc b/src/vulkan/frame_buffer.cc index cab353f..1d95cbc 100644 --- a/src/vulkan/frame_buffer.cc +++ b/src/vulkan/frame_buffer.cc @@ -16,6 +16,7 @@ #include <cassert> #include <limits> +#include <vector> #include "src/make_unique.h" diff --git a/src/vulkan/frame_buffer.h b/src/vulkan/frame_buffer.h index a262ede..461813a 100644 --- a/src/vulkan/frame_buffer.h +++ b/src/vulkan/frame_buffer.h @@ -15,6 +15,8 @@ #ifndef SRC_VULKAN_FRAME_BUFFER_H_ #define SRC_VULKAN_FRAME_BUFFER_H_ +#include <memory> + #include "src/vulkan/image.h" namespace amber { diff --git a/tools/clang-format-diff.py b/tools/clang-format-diff.py deleted file mode 100644 index e69de29..0000000 --- a/tools/clang-format-diff.py +++ /dev/null diff --git a/tools/run-lint.sh b/tools/run-lint.sh new file mode 100755 index 0000000..6664d64 --- /dev/null +++ b/tools/run-lint.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Copyright 2018 The Amber Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e # fail on error + +./third_party/cpplint/cpplint/cpplint.py `find . -type f -regextype awk -regex "./(src|samples).*"` +./third_party/cpplint/cpplint/cpplint.py --root include `find ./include -type f` |