blob: c627e03c42e7c28d4e89448c539e898d5790e5d5 [file] [log] [blame]
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +01001#!/usr/bin/env python
Anthony Barbier2fe7d1c2017-09-15 13:07:36 +01002#FIXME: Remove this file before the release
3
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +01004import os
5import re
6import sys
7
8def get_list_includes():
Anthony Barbierd598bfd2017-12-21 16:54:31 +00009 return "include/linux include . 3rdparty/include kernels computer_vision".split()
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010010
11def get_list_flags( filename, arch):
12 assert arch in ["armv7", "aarch64"]
13 flags = ["-std=c++11"]
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010014 flags.append("-DARM_COMPUTE_CPP_SCHEDULER=1")
Georgios Pinitas30f02152017-09-27 11:20:48 +010015 flags.append("-DARM_COMPUTE_CL")
Anthony Barbier7068f992017-10-26 15:23:08 +010016 flags.append("-DARM_COMPUTE_GC")
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010017 if arch == "aarch64":
Ioan-Cristian Szabo33fd07b2017-10-26 15:42:24 +010018 flags.append("-DARM_COMPUTE_AARCH64_V8_2")
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010019 return flags
20
21def filter_files( list_files ):
22 to_check = []
23 for f in list_files:
24 if os.path.splitext(f)[1] != ".cpp":
25 continue
26 if "computer_vision" in f:
27 continue
28 if "openvx-arm_compute" in f:
29 continue
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010030 # Skip OMPScheduler as it causes problems in clang
31 if "OMPScheduler.cpp" in f:
32 continue
33 to_check.append(f)
34 return to_check
35
36def filter_clang_tidy_lines( lines ):
37 out = []
38 print_context=False
39 for i in range(0, len(lines)):
40 line = lines[i]
41
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +010042 if "/assembly/" in line:
43 continue
44
Pablo Tello89519332017-11-17 11:52:36 +000045 if "/winograd/" in line:
46 continue
47
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010048 if "error:" in line:
49 if (("Utils.cpp" in line and "'arm_compute_version.embed' file not found" in line) or
50 ("cl2.hpp" in line and "cast from pointer to smaller type 'cl_context_properties' (aka 'int') loses information" in line) or
51 ("arm_fp16.h" in line) or
52 ("omp.h" in line) or
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +010053 ("cast from pointer to smaller type 'uintptr_t' (aka 'unsigned int') loses information" in line) or
54 ("cast from pointer to smaller type 'std::uintptr_t' (aka 'unsigned int') loses information" in line) or
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010055 ("NEMath.inl" in line and "statement expression not allowed at file scope" in line) or
Anthony Barbier2a07e182017-08-04 18:20:27 +010056 ("Utils.h" in line and "no member named 'unmap' in 'arm_compute::Tensor'" in line) or
57 ("Utils.h" in line and "no member named 'map' in 'arm_compute::Tensor'" in line) or
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010058 "3rdparty" in line):
59 print_context=False
60 continue
61
62 out.append(line)
63 print_context=True
64 elif "warning:" in line:
65 if ("uninitialized record type: '__ret'" in line or
66 "local variable '__bound_functor' is still referred to by the global variable '__once_callable'" in line or
Georgios Pinitas3faea252017-10-30 14:13:50 +000067 (any(f in line for f in ["Error.cpp","Error.h"]) and "thrown exception type is not nothrow copy constructible" in line) or
68 (any(f in line for f in ["Error.cpp","Error.h"]) and "uninitialized record type: 'args'" in line) or
69 (any(f in line for f in ["Error.cpp","Error.h"]) and "do not call c-style vararg functions" in line) or
70 (any(f in line for f in ["Error.cpp","Error.h"]) and "do not define a C-style variadic function" in line) or
Georgios Pinitas84b51ad2017-11-07 13:24:57 +000071 ("TensorAllocator.cpp" in line and "warning: pointer parameter 'ptr' can be pointer to const" in line) or
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010072 ("NEMinMaxLocationKernel.cpp" in line and "move constructors should be marked noexcept" in line) or
73 ("NEMinMaxLocationKernel.cpp" in line and "move assignment operators should be marked noexcept" in line) or
Georgios Pinitas30f02152017-09-27 11:20:48 +010074 ("CLMinMaxLocationKernel.cpp" in line and "Forming reference to null pointer" in line) or
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010075 ("PMUCounter.cpp" in line and "consider replacing 'long long' with 'int64'" in line) or
76 ("Validation.cpp" in line and "parameter 'classified_labels' is unused" in line) or
77 ("Validation.cpp" in line and "parameter 'expected_labels' is unused" in line) or
78 ("Reference.cpp" in line and "parameter 'rois' is unused" in line) or
79 ("Reference.cpp" in line and "parameter 'shapes' is unused" in line) or
80 ("Reference.cpp" in line and re.search(r"parameter '[^']+' is unused", line)) or
81 ("ReferenceCPP.cpp" in line and "parameter 'rois' is unused" in line) or
82 ("ReferenceCPP.cpp" in line and "parameter 'srcs' is unused" in line) or
83 ("ReferenceCPP.cpp" in line and re.search(r"parameter '[^']+' is unused", line)) or
84 ("NEGEMMMatrixMultiplyKernel.cpp" in line and "do not use C-style cast to convert between unrelated types" in line) or
85 ("NEPoolingLayerKernel.cpp" in line and "do not use C-style cast to convert between unrelated types" in line) or
86 ("NESoftmaxLayerKernel.cpp" in line and "do not use C-style cast to convert between unrelated types" in line) or
Georgios Pinitas30f02152017-09-27 11:20:48 +010087 ("GraphUtils.cpp" in line and "consider replacing 'unsigned long' with 'uint32'" in line) or
Anthony Barbier2a07e182017-08-04 18:20:27 +010088 ("GraphUtils.cpp" in line and "consider replacing 'unsigned long' with 'uint64'" in line) or
Georgios Pinitas6f669f02017-09-26 12:32:57 +010089 ("ConvolutionLayer.cpp" in line and "move assignment operators should be marked noexcept" in line) or
90 ("ConvolutionLayer.cpp" in line and "move constructors should be marked noexcept" in line) or
Georgios Pinitasbaf174e2017-09-08 19:47:30 +010091 ("parameter 'memory_manager' is unused" in line) or
Georgios Pinitas658039b2017-09-15 16:30:50 +010092 ("parameter 'memory_manager' is copied for each invocation but only used as a const reference" in line) or
Pablo Tellodaaa1fa2017-10-25 11:40:50 +010093 ("DeconvolutionLayer.cpp" in line and "casting (double + 0.5) to integer leads to incorrect rounding; consider using lround" in line) or
Pablo Tello3d4968a2017-12-04 15:03:35 +000094 ("NEWinogradLayerKernel.cpp" in line and "use '= default' to define a trivial destructor" in line) or
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010095 "3rdparty" in line):
96 print_context=False
97 continue
98
99 if "do not use C-style cast to convert between unrelated types" in line:
100 if i + 1 < len(lines) and "vgetq_lane_f16" in lines[i + 1]:
101 print_context=False
102 continue
103
104 if "use 'using' instead of 'typedef'" in line:
105 if i + 1 < len(lines) and "BOOST_FIXTURE_TEST_SUITE" in lines[i + 1]:
106 print_context=False
107 continue
108
109 if "do not call c-style vararg functions" in line:
110 if (i + 1 < len(lines) and
111 ("BOOST_TEST" in lines[i + 1] or
112 "BOOST_FAIL" in lines[i + 1] or
113 "BOOST_CHECK_THROW" in lines[i + 1] or
Georgios Pinitas3faea252017-10-30 14:13:50 +0000114 "ARM_COMPUTE_RETURN_ON" in lines[i + 1] or
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +0100115 "syscall" in lines[i + 1])):
116 print_context=False
117 continue
118
119 out.append(line)
120 print_context=True
Georgios Pinitas30f02152017-09-27 11:20:48 +0100121 elif (("CLMinMaxLocationKernel.cpp" in line and "'?' condition is false" in line) or
122 ("CLMinMaxLocationKernel.cpp" in line and "Assuming the condition is false" in line) or
123 ("CLMinMaxLocationKernel.cpp" in line and "Assuming pointer value is null" in line) or
124 ("CLMinMaxLocationKernel.cpp" in line and "Forming reference to null pointer" in line)):
125 print_context=False
126 continue
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +0100127 elif print_context:
128 out.append(line)
129
130 return out
131
132if __name__ == "__main__":
133 if len(sys.argv) != 2:
134 print("usage: {} CLANG-TIDY_OUTPUT_FILE".format(sys.argv[0]))
135 sys.exit(1)
136
137 errors = []
138 with open(sys.argv[1], mode="r") as clang_tidy_file:
139 lines = clang_tidy_file.readlines()
140 errors = filter_clang_tidy_lines(lines)
141 print "\n".join(errors)
142
143 sys.exit(0 if len(errors) == 0 else 1)