Run clang-query and return filtered missing-FL_NOEXCEPT hits.
(
clang_query: list[str], tu: str, file_regex: str
)
| 244 | |
| 245 | |
| 246 | def _run_clang_query( |
| 247 | clang_query: list[str], tu: str, file_regex: str |
| 248 | ) -> list[NoexceptHit]: |
| 249 | """Run clang-query and return filtered missing-FL_NOEXCEPT hits.""" |
| 250 | result = subprocess.run( |
| 251 | [*clang_query, tu, "--", *_COMPILER_ARGS], |
| 252 | input=build_query(file_regex), |
| 253 | capture_output=True, |
| 254 | text=True, |
| 255 | cwd=str(PROJECT_ROOT), |
| 256 | timeout=300, |
| 257 | ) |
| 258 | output = result.stdout + result.stderr |
| 259 | if result.returncode != 0: |
| 260 | raise NoexceptCheckError(output.strip() or "clang-query failed") |
| 261 | if ( |
| 262 | "Error parsing argument" in output |
| 263 | or "Error parsing matcher" in output |
| 264 | or "Matcher not found" in output |
| 265 | ): |
| 266 | raise NoexceptCheckError(output.strip()) |
| 267 | |
| 268 | hits: list[NoexceptHit] = [] |
| 269 | seen: set[tuple[str, int]] = set() |
| 270 | for match in _MATCH_OUTPUT_RE.finditer(output): |
| 271 | filepath = match.group(1).replace("\\", "/") |
| 272 | line_num = int(match.group(2)) |
| 273 | key = (filepath, line_num) |
| 274 | if key in seen: |
| 275 | continue |
| 276 | seen.add(key) |
| 277 | |
| 278 | line_text, signature = _read_source_signature(filepath, line_num) |
| 279 | if _signature_is_exempt(signature): |
| 280 | continue |
| 281 | hits.append( |
| 282 | NoexceptHit( |
| 283 | path=filepath, |
| 284 | line=line_num, |
| 285 | line_text=line_text, |
| 286 | signature=signature, |
| 287 | ) |
| 288 | ) |
| 289 | return hits |
| 290 | |
| 291 | |
| 292 | def find_missing_noexcept(scope: str = "all") -> list[NoexceptHit]: |
no test coverage detected