Commit 10aff10b authored by Paul's avatar Paul
Browse files

Fix some tidy checks

parent 0de83695
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
project(rtglib) project(rtglib)
find_package(ROCM REQUIRED)
add_compile_options(-std=c++14) add_compile_options(-std=c++14)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(EnableCompilerWarnings) include(EnableCompilerWarnings)
include(ROCMClangTidy)
rocm_enable_clang_tidy(
CHECKS
*
-cert-env33-c
-android-cloexec-fopen
-cert-msc50-cpp
-clang-analyzer-alpha.core.CastToStruct
-clang-analyzer-optin.performance.Padding
-clang-diagnostic-deprecated-declarations
-clang-diagnostic-extern-c-compat
-clang-diagnostic-unused-command-line-argument
-cppcoreguidelines-pro-bounds-array-to-pointer-decay
-cppcoreguidelines-pro-bounds-constant-array-index
-cppcoreguidelines-pro-bounds-pointer-arithmetic
-cppcoreguidelines-pro-type-member-init
-cppcoreguidelines-pro-type-reinterpret-cast
-cppcoreguidelines-pro-type-union-access
-cppcoreguidelines-pro-type-vararg
-cppcoreguidelines-special-member-functions
-fuchsia-*
-google-explicit-constructor
-google-readability-braces-around-statements
-google-readability-todo
-google-runtime-int
-google-runtime-references
-hicpp-braces-around-statements
-hicpp-explicit-conversions
-hicpp-no-array-decay
-hicpp-special-member-functions
-hicpp-use-emplace
-hicpp-use-equals-default
-hicpp-use-override
-llvm-header-guard
-llvm-include-order
-misc-macro-parentheses
-misc-misplaced-const
-misc-misplaced-widening-cast
-modernize-pass-by-value
-modernize-use-default-member-init
-modernize-use-emplace
-modernize-use-equals-default
-modernize-use-transparent-functors
-performance-unnecessary-value-param
-readability-braces-around-statements
-readability-else-after-return
-readability-implicit-bool-cast
-readability-implicit-bool-conversion
-readability-misleading-indentation
-readability-named-parameter
${CLANG_TIDY_CHECKS}
ERRORS
*
-readability-inconsistent-declaration-parameter-name
HEADER_FILTER
".*hpp"
EXTRA_ARGS
-DRTG_USE_CLANG_TIDY
ANALYZE_TEMPORARY_DTORS ON
)
include(ROCMCppCheck)
rocm_enable_cppcheck(
CHECKS
all
SUPPRESS
ConfigurationNotChecked
unmatchedSuppression
unusedFunction
noExplicitConstructor
passedByValue
unusedStructMember
FORCE
SOURCES
include/
src/
test/
INCLUDE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
add_library(rtg add_library(rtg
src/program.cpp src/program.cpp
src/shape.cpp src/shape.cpp
) )
rocm_clang_tidy_check(rtg)
target_include_directories(rtg PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>) target_include_directories(rtg PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
add_subdirectory(onnx) add_subdirectory(onnx)
......
...@@ -13,12 +13,12 @@ struct instruction ...@@ -13,12 +13,12 @@ struct instruction
instruction() {} instruction() {}
instruction(operand o, shape r, std::vector<instruction*> args) instruction(operand o, shape r, std::vector<instruction*> args)
: op(std::move(o)), result(std::move(r)), arguments(std::move(args)), lit() : op(std::move(o)), result(std::move(r)), arguments(std::move(args))
{ {
} }
instruction(literal l) instruction(literal l)
: op(builtin::literal{}), result(l.get_shape()), arguments(), lit(std::move(l)) : op(builtin::literal{}), result(l.get_shape()), lit(std::move(l))
{ {
} }
......
...@@ -10,7 +10,7 @@ namespace rtg { ...@@ -10,7 +10,7 @@ namespace rtg {
struct literal : raw_data<literal> struct literal : raw_data<literal>
{ {
literal() : buffer(), shape_() {} literal() {}
template <class T> template <class T>
literal(T x) : buffer(sizeof(T), 0), shape_(shape::get_type<T>{}) literal(T x) : buffer(sizeof(T), 0), shape_(shape::get_type<T>{})
......
...@@ -95,19 +95,19 @@ struct operand ...@@ -95,19 +95,19 @@ struct operand
{ {
} }
virtual std::shared_ptr<handle_base_type_> clone() const std::shared_ptr<handle_base_type_> clone() const override
{ {
return std::make_shared<handle_type_>(value_); return std::make_shared<handle_type_>(value_);
} }
virtual std::string name() const { return value_.name(); } std::string name() const override { return value_.name(); }
virtual shape compute_shape(std::vector<shape> input) const shape compute_shape(std::vector<shape> input) const override
{ {
return value_.compute_shape(std::move(input)); return value_.compute_shape(std::move(input));
} }
virtual argument compute(std::vector<argument> input) const argument compute(std::vector<argument> input) const override
{ {
return value_.compute(std::move(input)); return value_.compute(std::move(input));
} }
......
...@@ -115,7 +115,7 @@ struct shape ...@@ -115,7 +115,7 @@ struct shape
RTG_SHAPE_VISIT_TYPES(RTG_SHAPE_VISITOR_CASE) RTG_SHAPE_VISIT_TYPES(RTG_SHAPE_VISITOR_CASE)
#undef RTG_SHAPE_VISITOR_CASE #undef RTG_SHAPE_VISITOR_CASE
} }
assert(true); throw std::runtime_error("Unknown type");
} }
private: private:
......
...@@ -11,12 +11,12 @@ namespace rtg { ...@@ -11,12 +11,12 @@ namespace rtg {
template <class T> template <class T>
struct tensor_view struct tensor_view
{ {
tensor_view() : data_(nullptr), shape_() {} tensor_view() : data_(nullptr) {}
tensor_view(shape s, T* d) : data_(d), shape_(s) {} tensor_view(shape s, T* d) : data_(d), shape_(s) {}
const shape& get_shape() const { return this->shape_; } const shape& get_shape() const { return this->shape_; }
bool empty() const { return data_ == nullptr || shape_.lens().size() == 0; } bool empty() const { return data_ == nullptr || shape_.lens().empty(); }
std::size_t size() const { return shape_.elements(); } std::size_t size() const { return shape_.elements(); }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
namespace rtg { namespace rtg {
shape::shape() : type_(float_type), lens_(), strides_(), packed_(false) {} shape::shape() : type_(float_type), packed_(false) {}
shape::shape(type_t t) : type_(t), lens_({1}), strides_({1}), packed_(true) {} shape::shape(type_t t) : type_(t), lens_({1}), strides_({1}), packed_(true) {}
shape::shape(type_t t, std::vector<std::size_t> l) : type_(t), lens_(std::move(l)), packed_(true) shape::shape(type_t t, std::vector<std::size_t> l) : type_(t), lens_(std::move(l)), packed_(true)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment