Compute Library
 21.02
clang_tidy_rules Namespace Reference

Functions

def get_list_includes ()
 
def get_list_flags (filename, arch)
 
def filter_files (list_files)
 
def filter_clang_tidy_lines (lines)
 

Variables

list errors = []
 
 mode
 
 lines = clang_tidy_file.readlines()
 

Function Documentation

◆ filter_clang_tidy_lines()

def clang_tidy_rules.filter_clang_tidy_lines (   lines)

Definition at line 40 of file clang_tidy_rules.py.

References arm_compute::test::validation::reference.range().

40 def filter_clang_tidy_lines( lines ):
41  out = []
42  print_context=False
43  for i in range(0, len(lines)):
44  line = lines[i]
45 
46  if "/arm_conv/" in line:
47  continue
48 
49  if "/arm_gemm/" in line:
50  continue
51 
52  if "/convolution/" in line:
53  continue
54 
55  if "/validate_examples/" in line:
56  continue
57 
58  if "error:" in line:
59  if (("Version.cpp" in line and "arm_compute_version.embed" in line and "file not found" in line) or
60  ("arm_fp16.h" in line) or
61  ("omp.h" in line) or
62  ("cast from pointer to smaller type 'uintptr_t' (aka 'unsigned int') loses information" in line) or
63  ("cast from pointer to smaller type 'cl_context_properties' (aka 'int') loses information" in line) or
64  ("cast from pointer to smaller type 'std::uintptr_t' (aka 'unsigned int') loses information" in line) or
65  ("NEMath.inl" in line and "statement expression not allowed at file scope" in line) or
66  ("Utils.h" in line and "no member named 'unmap' in 'arm_compute::Tensor'" in line) or
67  ("Utils.h" in line and "no member named 'map' in 'arm_compute::Tensor'" in line) or
68  ("CPUUtils.cpp" in line and "'asm/hwcap.h' file not found" in line) or
69  ("'arm_compute_version.embed' file not found" in line) ):
70  print_context=False
71  continue
72 
73  out.append(line)
74  print_context=True
75  elif "warning:" in line:
76  if ("uninitialized record type: '__ret'" in line or
77  "local variable '__bound_functor' is still referred to by the global variable '__once_callable'" in line or
78  "assigning newly created 'gsl::owner<>'" in line or
79  "calling legacy resource function without passing a 'gsl::owner<>'" in line or
80  "deleting a pointer through a type that is not marked 'gsl::owner<>'" in line or
81  (any(f in line for f in ["Error.cpp","Error.h"]) and "thrown exception type is not nothrow copy constructible" in line) or
82  (any(f in line for f in ["Error.cpp","Error.h"]) and "uninitialized record type: 'args'" in line) or
83  (any(f in line for f in ["Error.cpp","Error.h"]) and "do not call c-style vararg functions" in line) or
84  (any(f in line for f in ["Error.cpp","Error.h"]) and "do not define a C-style variadic function" in line) or
85  ("TensorAllocator.cpp" in line and "warning: pointer parameter 'ptr' can be pointer to const" in line) or
86  ("TensorAllocator.cpp" in line and "warning: do not declare C-style arrays" in line) or
87  ("RawTensor.cpp" in line and "warning: pointer parameter 'ptr' can be pointer to const" in line) or
88  ("RawTensor.cpp" in line and "warning: do not declare C-style arrays" in line) or
89  ("GCBufferAllocator.cpp" in line and "warning: initializing non-owner" in line) or
90  ("NEMinMaxLocationKernel.cpp" in line and "move constructors should be marked noexcept" in line) or
91  ("NEMinMaxLocationKernel.cpp" in line and "move assignment operators should be marked noexcept" in line) or
92  ("CLMinMaxLocationKernel.cpp" in line and "Forming reference to null pointer" in line) or
93  ("PMUCounter.cpp" in line and "consider replacing 'long long' with 'int64'" in line) or
94  ("Validation.cpp" in line and "parameter 'classified_labels' is unused" in line) or
95  ("Validation.cpp" in line and "parameter 'expected_labels' is unused" in line) or
96  ("Reference.cpp" in line and "parameter 'rois' is unused" in line) or
97  ("Reference.cpp" in line and "parameter 'shapes' is unused" in line) or
98  ("Reference.cpp" in line and re.search(r"parameter '[^']+' is unused", line)) or
99  ("ReferenceCPP.cpp" in line and "parameter 'rois' is unused" in line) or
100  ("ReferenceCPP.cpp" in line and "parameter 'srcs' is unused" in line) or
101  ("ReferenceCPP.cpp" in line and re.search(r"parameter '[^']+' is unused", line)) or
102  ("NEGEMMMatrixMultiplyKernel.cpp" in line and "do not use C-style cast to convert between unrelated types" in line) or
103  ("NEPoolingLayerKernel.cpp" in line and "do not use C-style cast to convert between unrelated types" in line) or
104  ("NESoftmaxLayerKernel.cpp" in line and "macro argument should be enclosed in parentheses" in line) or
105  ("GraphUtils.cpp" in line and "consider replacing 'unsigned long' with 'uint32'" in line) or
106  ("GraphUtils.cpp" in line and "consider replacing 'unsigned long' with 'uint64'" in line) or
107  ("ConvolutionLayer.cpp" in line and "move assignment operators should be marked noexcept" in line) or
108  ("ConvolutionLayer.cpp" in line and "move constructors should be marked noexcept" in line) or
109  ("parameter 'memory_manager' is unused" in line) or
110  ("parameter 'memory_manager' is copied for each invocation but only used as a const reference" in line) or
111  ("DeconvolutionLayer.cpp" in line and "casting (double + 0.5) to integer leads to incorrect rounding; consider using lround" in line) or
112  ("NEWinogradLayerKernel.cpp" in line and "use '= default' to define a trivial destructor" in line) or
113  ("NEGEMMLowpMatrixMultiplyCore.cpp" in line and "constructor does not initialize these fields" in line) or
114  ("NEGEMMLowpAssemblyMatrixMultiplyCore" in line and "constructor does not initialize these fields" in line) or
115  ("NEDepthwiseConvolutionLayerNativeKernel" in line and re.search(r"parameter '[^']+' is unused", line)) or
116  ("NEDepthwiseConvolutionAssemblyDispatch" in line and re.search(r"parameter '[^']+' is unused", line)) or
117  ("CPUUtils.cpp" in line and "consider replacing 'unsigned long' with 'uint64'" in line) or
118  ("CPUUtils.cpp" in line and "parameter 'cpusv' is unused" in line) or
119  ("CPUUtils.cpp" in line and "warning: uninitialized record type" in line) or
120  ("GCKernelLibrary.cpp" in line and "warning: do not declare C-style arrays" in line) or
121  ("Utils.h" in line and "warning: Use of zero-allocated memory" in line) or
122  ("NEDepthwiseConvolutionLayerNativeKernel.cpp" in line and "misc-non-private-member-variables-in-classes" in line) or # This is to prevent false positive, should be reassessed with the newer clang-tidy
123  ("NEDepthwiseConvolutionLayerNativeKernel.cpp" in line and "cppcoreguidelines-pro-type-member-init" in line)): # This is to prevent false positive, should be reassessed with the newer clang-tidy
124  print_context=False
125  continue
126 
127  if "do not use C-style cast to convert between unrelated types" in line:
128  if i + 1 < len(lines) and "vgetq_lane_f16" in lines[i + 1]:
129  print_context=False
130  continue
131 
132  if "use 'using' instead of 'typedef'" in line:
133  if i + 1 < len(lines) and "BOOST_FIXTURE_TEST_SUITE" in lines[i + 1]:
134  print_context=False
135  continue
136 
137  if "do not call c-style vararg functions" in line:
138  if (i + 1 < len(lines) and
139  ("BOOST_TEST" in lines[i + 1] or
140  "BOOST_FAIL" in lines[i + 1] or
141  "BOOST_CHECK_THROW" in lines[i + 1] or
142  "ARM_COMPUTE_ERROR_VAR" in lines[i + 1] or
143  "ARM_COMPUTE_RETURN_ON" in lines[i + 1] or
144  "syscall" in lines[i + 1])):
145  print_context=False
146  continue
147 
148  out.append(line)
149  print_context=True
150  elif (("CLMinMaxLocationKernel.cpp" in line and "'?' condition is false" in line) or
151  ("CLMinMaxLocationKernel.cpp" in line and "Assuming the condition is false" in line) or
152  ("CLMinMaxLocationKernel.cpp" in line and "Assuming pointer value is null" in line) or
153  ("CLMinMaxLocationKernel.cpp" in line and "Forming reference to null pointer" in line)):
154  print_context=False
155  continue
156  elif print_context:
157  out.append(line)
158 
159  return out
160 
def filter_clang_tidy_lines(lines)
SimpleTensor< T > range(SimpleTensor< T > &dst, float start, const size_t num_of_elements, float step)
Definition: Range.cpp:50

◆ filter_files()

def clang_tidy_rules.filter_files (   list_files)

Definition at line 26 of file clang_tidy_rules.py.

26 def filter_files( list_files ):
27  to_check = []
28  for f in list_files:
29  if os.path.splitext(f)[1] != ".cpp":
30  continue
31  # Skip OMPScheduler as it causes problems in clang
32  if (("OMPScheduler.cpp" in f) or
33  ("CLTracePoint.cpp" in f) or
34  ("NETracePoint.cpp" in f) or
35  ("TracePoint.cpp" in f)):
36  continue
37  to_check.append(f)
38  return to_check
39 
def filter_files(list_files)

◆ get_list_flags()

def clang_tidy_rules.get_list_flags (   filename,
  arch 
)

Definition at line 16 of file clang_tidy_rules.py.

16 def get_list_flags( filename, arch):
17  assert arch in ["armv7", "aarch64"]
18  flags = ["-std=c++14"]
19  flags.append("-DARM_COMPUTE_CPP_SCHEDULER=1")
20  flags.append("-DARM_COMPUTE_CL")
21  flags.append("-DARM_COMPUTE_GC")
22  if arch == "aarch64":
23  flags.append("-DARM_COMPUTE_AARCH64_V8_2")
24  return flags
25 
def get_list_flags(filename, arch)

◆ get_list_includes()

def clang_tidy_rules.get_list_includes ( )

Definition at line 6 of file clang_tidy_rules.py.

7  return "arm_compute/core/NEON/kernels/assembly " \
8  "arm_compute/core/NEON/kernels/convolution/common " \
9  "arm_compute/core/NEON/kernels/convolution/depthwise " \
10  "arm_compute/core/NEON/kernels/convolution/winograd " \
11  "src/core/NEON/kernels/assembly " \
12  "src/core/NEON/kernels/convolution/winograd " \
13  "include/linux include " \
14  ". ".split()
15 

Variable Documentation

◆ errors

def errors = []

Definition at line 166 of file clang_tidy_rules.py.

◆ lines

lines = clang_tidy_file.readlines()

Definition at line 168 of file clang_tidy_rules.py.

◆ mode