MCPcopy Create free account
hub / github.com/FastLED/FastLED / run_clang_query

Function run_clang_query

ci/tools/add_fl_noexcept.py:52–118  ·  view source on GitHub ↗

Run clang-query to find all functions missing noexcept in scope. Returns list of (filepath, line_number) tuples.

(scope: str)

Source from the content-addressed store, hash-verified

50
51
52def run_clang_query(scope: str) -> list[tuple[str, int]]:
53 """Run clang-query to find all functions missing noexcept in scope.
54
55 Returns list of (filepath, line_number) tuples.
56 """
57 # Pick translation unit based on scope
58 if "platforms" in scope:
59 tu = "ci/tools/_noexcept_check_platforms_tu.cpp"
60 else:
61 tu = "src/fl/build/fl.system+.cpp"
62
63 # Build the file matching regex from scope
64 scope_regex = scope.replace("/", ".")
65 query = (
66 f"set output diag\n"
67 f"match functionDecl("
68 f"unless(isNoThrow()), "
69 f"unless(isDeleted()), "
70 f"unless(isDefaulted()), "
71 f"unless(isImplicit()), "
72 f'isExpansionInFileMatching(".*{scope_regex}.*"))'
73 )
74
75 compiler_args = [
76 "-std=c++17",
77 "-Isrc",
78 "-Isrc/platforms/stub",
79 "-DSTUB_PLATFORM",
80 "-DARDUINO=10808",
81 "-DFASTLED_USE_STUB_ARDUINO",
82 "-DFASTLED_STUB_IMPL",
83 "-DFASTLED_TESTING",
84 "-DFASTLED_NO_AUTO_NAMESPACE",
85 "-fno-exceptions",
86 # Make FL_NOEXCEPT expand to noexcept under stub mode
87 "-DFL_NOEXCEPT=noexcept",
88 ]
89
90 if not CLANG_QUERY.exists():
91 print(f"ERROR: clang-query not found at {CLANG_QUERY}")
92 sys.exit(1)
93
94 result = subprocess.run(
95 [str(CLANG_QUERY), tu, "--"] + compiler_args,
96 input=query,
97 capture_output=True,
98 text=True,
99 cwd=str(PROJECT_ROOT),
100 timeout=300,
101 )
102
103 output = result.stdout + result.stderr
104
105 # Parse "file:line:col: note: "root" binds here" lines
106 pattern = re.compile(r"(src[\\/]\S+):(\d+):\d+: note: .root. binds here")
107 hits: list[tuple[str, int]] = []
108 seen: set[tuple[str, int]] = set()
109

Callers 1

mainFunction · 0.85

Calls 6

compileMethod · 0.80
printFunction · 0.50
setClass · 0.50
runMethod · 0.45
addMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected