blob: b811847ba81b05ef1cd3d3dd5b390ce70e2bc9c2 [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():
9 return "include . 3rdparty/include kernels computer_vision".split()
10
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 Barbier3dfbdeb2017-09-12 16:04:45 +010016 if arch == "aarch64":
Ioan-Cristian Szabo33fd07b2017-10-26 15:42:24 +010017 flags.append("-DARM_COMPUTE_AARCH64_V8_2")
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010018 return flags
19
20def filter_files( list_files ):
21 to_check = []
22 for f in list_files:
23 if os.path.splitext(f)[1] != ".cpp":
24 continue
25 if "computer_vision" in f:
26 continue
27 if "openvx-arm_compute" in f:
28 continue
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010029 # Skip OMPScheduler as it causes problems in clang
30 if "OMPScheduler.cpp" in f:
31 continue
32 to_check.append(f)
33 return to_check
34
35def filter_clang_tidy_lines( lines ):
36 out = []
37 print_context=False
38 for i in range(0, len(lines)):
39 line = lines[i]
40
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +010041 if "/assembly/" in line:
42 continue
43
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010044 if "error:" in line:
45 if (("Utils.cpp" in line and "'arm_compute_version.embed' file not found" in line) or
46 ("cl2.hpp" in line and "cast from pointer to smaller type 'cl_context_properties' (aka 'int') loses information" in line) or
47 ("arm_fp16.h" in line) or
48 ("omp.h" in line) or
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +010049 ("cast from pointer to smaller type 'uintptr_t' (aka 'unsigned int') loses information" in line) or
50 ("cast from pointer to smaller type 'std::uintptr_t' (aka 'unsigned int') loses information" in line) or
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010051 ("NEMath.inl" in line and "statement expression not allowed at file scope" in line) or
Anthony Barbier2a07e182017-08-04 18:20:27 +010052 ("Utils.h" in line and "no member named 'unmap' in 'arm_compute::Tensor'" in line) or
53 ("Utils.h" in line and "no member named 'map' in 'arm_compute::Tensor'" in line) or
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010054 "3rdparty" in line):
55 print_context=False
56 continue
57
58 out.append(line)
59 print_context=True
60 elif "warning:" in line:
61 if ("uninitialized record type: '__ret'" in line or
62 "local variable '__bound_functor' is still referred to by the global variable '__once_callable'" in line or
63 ("Error.cpp" in line and "thrown exception type is not nothrow copy constructible" in line) or
64 ("Error.cpp" in line and "uninitialized record type: 'args'" in line) or
65 ("Error.cpp" in line and "do not call c-style vararg functions" in line) or
66 ("Error.cpp" in line and "do not define a C-style variadic function" in line) or
67 ("NEMinMaxLocationKernel.cpp" in line and "move constructors should be marked noexcept" in line) or
68 ("NEMinMaxLocationKernel.cpp" in line and "move assignment operators should be marked noexcept" in line) or
Georgios Pinitas30f02152017-09-27 11:20:48 +010069 ("CLMinMaxLocationKernel.cpp" in line and "Forming reference to null pointer" in line) or
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010070 ("PMUCounter.cpp" in line and "consider replacing 'long long' with 'int64'" in line) or
71 ("Validation.cpp" in line and "parameter 'classified_labels' is unused" in line) or
72 ("Validation.cpp" in line and "parameter 'expected_labels' is unused" in line) or
73 ("Reference.cpp" in line and "parameter 'rois' is unused" in line) or
74 ("Reference.cpp" in line and "parameter 'shapes' is unused" in line) or
75 ("Reference.cpp" in line and re.search(r"parameter '[^']+' is unused", line)) or
76 ("ReferenceCPP.cpp" in line and "parameter 'rois' is unused" in line) or
77 ("ReferenceCPP.cpp" in line and "parameter 'srcs' is unused" in line) or
78 ("ReferenceCPP.cpp" in line and re.search(r"parameter '[^']+' is unused", line)) or
79 ("NEGEMMMatrixMultiplyKernel.cpp" in line and "do not use C-style cast to convert between unrelated types" in line) or
80 ("NEPoolingLayerKernel.cpp" in line and "do not use C-style cast to convert between unrelated types" in line) or
81 ("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 +010082 ("GraphUtils.cpp" in line and "consider replacing 'unsigned long' with 'uint32'" in line) or
Anthony Barbier2a07e182017-08-04 18:20:27 +010083 ("GraphUtils.cpp" in line and "consider replacing 'unsigned long' with 'uint64'" in line) or
Georgios Pinitas6f669f02017-09-26 12:32:57 +010084 ("ConvolutionLayer.cpp" in line and "move assignment operators should be marked noexcept" in line) or
85 ("ConvolutionLayer.cpp" in line and "move constructors should be marked noexcept" in line) or
Georgios Pinitasbaf174e2017-09-08 19:47:30 +010086 ("parameter 'memory_manager' is unused" in line) or
Georgios Pinitas658039b2017-09-15 16:30:50 +010087 ("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 +010088 ("DeconvolutionLayer.cpp" in line and "casting (double + 0.5) to integer leads to incorrect rounding; consider using lround" in line) or
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010089 "3rdparty" in line):
90 print_context=False
91 continue
92
93 if "do not use C-style cast to convert between unrelated types" in line:
94 if i + 1 < len(lines) and "vgetq_lane_f16" in lines[i + 1]:
95 print_context=False
96 continue
97
98 if "use 'using' instead of 'typedef'" in line:
99 if i + 1 < len(lines) and "BOOST_FIXTURE_TEST_SUITE" in lines[i + 1]:
100 print_context=False
101 continue
102
103 if "do not call c-style vararg functions" in line:
104 if (i + 1 < len(lines) and
105 ("BOOST_TEST" in lines[i + 1] or
106 "BOOST_FAIL" in lines[i + 1] or
107 "BOOST_CHECK_THROW" in lines[i + 1] or
108 "syscall" in lines[i + 1])):
109 print_context=False
110 continue
111
112 out.append(line)
113 print_context=True
Georgios Pinitas30f02152017-09-27 11:20:48 +0100114 elif (("CLMinMaxLocationKernel.cpp" in line and "'?' condition is false" in line) or
115 ("CLMinMaxLocationKernel.cpp" in line and "Assuming the condition is false" in line) or
116 ("CLMinMaxLocationKernel.cpp" in line and "Assuming pointer value is null" in line) or
117 ("CLMinMaxLocationKernel.cpp" in line and "Forming reference to null pointer" in line)):
118 print_context=False
119 continue
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +0100120 elif print_context:
121 out.append(line)
122
123 return out
124
125if __name__ == "__main__":
126 if len(sys.argv) != 2:
127 print("usage: {} CLANG-TIDY_OUTPUT_FILE".format(sys.argv[0]))
128 sys.exit(1)
129
130 errors = []
131 with open(sys.argv[1], mode="r") as clang_tidy_file:
132 lines = clang_tidy_file.readlines()
133 errors = filter_clang_tidy_lines(lines)
134 print "\n".join(errors)
135
136 sys.exit(0 if len(errors) == 0 else 1)