blob: 61ada49149ad47766a972b8e97786517414c0b45 [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"]
14 if "tests/validation_old" in filename:
15 flags.append("-DBOOST")
16 flags.append("-DARM_COMPUTE_CPP_SCHEDULER=1")
17 if arch == "aarch64":
18 flags.append("-DARM_COMPUTE_CL")
19 flags.append("-DARM_COMPUTE_ENABLE_FP16")
20 return flags
21
22def filter_files( list_files ):
23 to_check = []
24 for f in list_files:
25 if os.path.splitext(f)[1] != ".cpp":
26 continue
27 if "computer_vision" in f:
28 continue
29 if "openvx-arm_compute" in f:
30 continue
31 if "tests/validation_old" in f:
32 continue
33 # Skip OMPScheduler as it causes problems in clang
34 if "OMPScheduler.cpp" in f:
35 continue
36 to_check.append(f)
37 return to_check
38
39def filter_clang_tidy_lines( lines ):
40 out = []
41 print_context=False
42 for i in range(0, len(lines)):
43 line = lines[i]
44
45 if "error:" in line:
46 if (("Utils.cpp" in line and "'arm_compute_version.embed' file not found" in line) or
47 ("cl2.hpp" in line and "cast from pointer to smaller type 'cl_context_properties' (aka 'int') loses information" in line) or
48 ("arm_fp16.h" in line) or
49 ("omp.h" in line) or
50 ("memory" in line and "cast from pointer to smaller type 'uintptr_t' (aka 'unsigned int') loses information" in line) or
51 ("NEMath.inl" in line and "statement expression not allowed at file scope" in line) or
52 "3rdparty" in line):
53 print_context=False
54 continue
55
56 out.append(line)
57 print_context=True
58 elif "warning:" in line:
59 if ("uninitialized record type: '__ret'" in line or
60 "local variable '__bound_functor' is still referred to by the global variable '__once_callable'" in line or
61 ("Error.cpp" in line and "thrown exception type is not nothrow copy constructible" in line) or
62 ("Error.cpp" in line and "uninitialized record type: 'args'" in line) or
63 ("Error.cpp" in line and "do not call c-style vararg functions" in line) or
64 ("Error.cpp" in line and "do not define a C-style variadic function" in line) or
65 ("NEMinMaxLocationKernel.cpp" in line and "move constructors should be marked noexcept" in line) or
66 ("NEMinMaxLocationKernel.cpp" in line and "move assignment operators should be marked noexcept" in line) or
67 ("PMUCounter.cpp" in line and "consider replacing 'long long' with 'int64'" in line) or
68 ("Validation.cpp" in line and "parameter 'classified_labels' is unused" in line) or
69 ("Validation.cpp" in line and "parameter 'expected_labels' is unused" in line) or
70 ("Reference.cpp" in line and "parameter 'rois' is unused" in line) or
71 ("Reference.cpp" in line and "parameter 'shapes' is unused" in line) or
72 ("Reference.cpp" in line and re.search(r"parameter '[^']+' is unused", line)) or
73 ("ReferenceCPP.cpp" in line and "parameter 'rois' is unused" in line) or
74 ("ReferenceCPP.cpp" in line and "parameter 'srcs' is unused" in line) or
75 ("ReferenceCPP.cpp" in line and re.search(r"parameter '[^']+' is unused", line)) or
76 ("NEGEMMMatrixMultiplyKernel.cpp" in line and "do not use C-style cast to convert between unrelated types" in line) or
77 ("NEPoolingLayerKernel.cpp" in line and "do not use C-style cast to convert between unrelated types" in line) or
78 ("NESoftmaxLayerKernel.cpp" in line and "do not use C-style cast to convert between unrelated types" in line) or
Georgios Pinitasbaf174e2017-09-08 19:47:30 +010079 ("parameter 'memory_manager' is unused" in line) or
Anthony Barbier3dfbdeb2017-09-12 16:04:45 +010080 "3rdparty" in line):
81 print_context=False
82 continue
83
84 if "do not use C-style cast to convert between unrelated types" in line:
85 if i + 1 < len(lines) and "vgetq_lane_f16" in lines[i + 1]:
86 print_context=False
87 continue
88
89 if "use 'using' instead of 'typedef'" in line:
90 if i + 1 < len(lines) and "BOOST_FIXTURE_TEST_SUITE" in lines[i + 1]:
91 print_context=False
92 continue
93
94 if "do not call c-style vararg functions" in line:
95 if (i + 1 < len(lines) and
96 ("BOOST_TEST" in lines[i + 1] or
97 "BOOST_FAIL" in lines[i + 1] or
98 "BOOST_CHECK_THROW" in lines[i + 1] or
99 "syscall" in lines[i + 1])):
100 print_context=False
101 continue
102
103 out.append(line)
104 print_context=True
105 elif print_context:
106 out.append(line)
107
108 return out
109
110if __name__ == "__main__":
111 if len(sys.argv) != 2:
112 print("usage: {} CLANG-TIDY_OUTPUT_FILE".format(sys.argv[0]))
113 sys.exit(1)
114
115 errors = []
116 with open(sys.argv[1], mode="r") as clang_tidy_file:
117 lines = clang_tidy_file.readlines()
118 errors = filter_clang_tidy_lines(lines)
119 print "\n".join(errors)
120
121 sys.exit(0 if len(errors) == 0 else 1)