Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
Isabella Gottardi | b797fa2 | 2017-06-23 15:02:11 +0100 | [diff] [blame] | 3 | import re |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 4 | import sys |
| 5 | |
| 6 | if __name__ == "__main__": |
| 7 | if len(sys.argv) != 2: |
| 8 | print("usage: {} CLANG-TIDY_OUTPUT_FILE".format(sys.argv[0])) |
| 9 | sys.exit(1) |
| 10 | |
| 11 | failed = False |
| 12 | |
| 13 | with open(sys.argv[1], mode="r") as clang_tidy_file: |
| 14 | lines = clang_tidy_file.readlines() |
| 15 | |
| 16 | for i in range(0, len(lines)): |
| 17 | line = lines[i] |
| 18 | |
| 19 | if "error:" in line: |
| 20 | if (("Utils.cpp" in line and "'arm_compute_version.embed' file not found" in line) or |
| 21 | ("cl2.hpp" in line and "cast from pointer to smaller type 'cl_context_properties' (aka 'int') loses information" in line) or |
Pablo Tello | 383deec | 2017-06-23 10:40:05 +0100 | [diff] [blame] | 22 | ("arm_fp16.h" in line) or |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 23 | ("memory" in line and "cast from pointer to smaller type 'uintptr_t' (aka 'unsigned int') loses information" in line) or |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 24 | ("NEMath.inl" in line and "statement expression not allowed at file scope" in line) or |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 25 | "3rdparty" in line): |
| 26 | continue |
| 27 | |
| 28 | failed = True |
| 29 | print(line) |
| 30 | elif "warning:" in line: |
| 31 | if ("uninitialized record type: '__ret'" in line or |
| 32 | "local variable '__bound_functor' is still referred to by the global variable '__once_callable'" in line or |
| 33 | ("Error.cpp" in line and "thrown exception type is not nothrow copy constructible" in line) or |
| 34 | ("Error.cpp" in line and "uninitialized record type: 'args'" in line) or |
| 35 | ("Error.cpp" in line and "do not call c-style vararg functions" in line) or |
| 36 | ("Error.cpp" in line and "do not define a C-style variadic function" in line) or |
| 37 | ("NEMinMaxLocationKernel.cpp" in line and "move constructors should be marked noexcept" in line) or |
| 38 | ("NEMinMaxLocationKernel.cpp" in line and "move assignment operators should be marked noexcept" in line) or |
| 39 | ("PMUCounter.cpp" in line and "consider replacing 'long long' with 'int64'" in line) or |
Pablo Tello | 383deec | 2017-06-23 10:40:05 +0100 | [diff] [blame] | 40 | ("Validation.cpp" in line and "parameter 'classified_labels' is unused" in line) or |
| 41 | ("Validation.cpp" in line and "parameter 'expected_labels' is unused" in line) or |
Georgios Pinitas | 7b7858d | 2017-06-21 16:44:24 +0100 | [diff] [blame] | 42 | ("Reference.cpp" in line and "parameter 'rois' is unused" in line) or |
Georgios Pinitas | ac4e873 | 2017-07-05 17:02:25 +0100 | [diff] [blame] | 43 | ("Reference.cpp" in line and "parameter 'shapes' is unused" in line) or |
Isabella Gottardi | b797fa2 | 2017-06-23 15:02:11 +0100 | [diff] [blame] | 44 | ("Reference.cpp" in line and re.search(r"parameter '[^']+' is unused", line)) or |
Georgios Pinitas | 7b7858d | 2017-06-21 16:44:24 +0100 | [diff] [blame] | 45 | ("ReferenceCPP.cpp" in line and "parameter 'rois' is unused" in line) or |
Georgios Pinitas | ac4e873 | 2017-07-05 17:02:25 +0100 | [diff] [blame] | 46 | ("ReferenceCPP.cpp" in line and "parameter 'srcs' is unused" in line) or |
Isabella Gottardi | b797fa2 | 2017-06-23 15:02:11 +0100 | [diff] [blame] | 47 | ("ReferenceCPP.cpp" in line and re.search(r"parameter '[^']+' is unused", line)) or |
Pablo Tello | 221f381 | 2017-06-28 17:27:56 +0100 | [diff] [blame] | 48 | ("NEGEMMMatrixMultiplyKernel.cpp" in line and "do not use C-style cast to convert between unrelated types" in line) or |
Pablo Tello | 0c34fe2 | 2017-06-26 17:17:42 +0100 | [diff] [blame] | 49 | ("NEPoolingLayerKernel.cpp" in line and "do not use C-style cast to convert between unrelated types" in line) or |
Pablo Tello | b49a715 | 2017-07-11 16:31:35 +0100 | [diff] [blame] | 50 | ("NESoftmaxLayerKernel.cpp" in line and "do not use C-style cast to convert between unrelated types" in line) or |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 51 | "3rdparty" in line): |
| 52 | continue |
| 53 | |
| 54 | if "do not use C-style cast to convert between unrelated types" in line: |
| 55 | if i + 1 < len(lines) and "vgetq_lane_f16" in lines[i + 1]: |
| 56 | continue |
| 57 | |
| 58 | if "use 'using' instead of 'typedef'" in line: |
| 59 | if i + 1 < len(lines) and "BOOST_FIXTURE_TEST_SUITE" in lines[i + 1]: |
| 60 | continue |
| 61 | |
| 62 | if "do not call c-style vararg functions" in line: |
| 63 | if (i + 1 < len(lines) and |
| 64 | ("BOOST_TEST" in lines[i + 1] or |
| 65 | "BOOST_FAIL" in lines[i + 1] or |
| 66 | "BOOST_CHECK_THROW" in lines[i + 1] or |
| 67 | "syscall" in lines[i + 1])): |
| 68 | continue |
| 69 | |
Moritz Pflanzer | 94450f1 | 2017-06-30 12:48:43 +0100 | [diff] [blame] | 70 | if "use '= default' to define a trivial default constructor" in line: |
| 71 | if i + 1 < len(lines) and "BENCHMARK" in lines[i + 1]: |
| 72 | continue |
| 73 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 74 | failed = True |
| 75 | print(line) |
| 76 | |
| 77 | sys.exit(0 if not failed else 1) |