Override/virtual/final method names relevant to `path`: always the ones declared in the file itself -- this catches classes defined inline in a `.cpp` (e.g. the NativeTemplate implementations, whose `id()`/`name()` overrides live in the `.cpp`, not a header) -- unioned, for a `.cpp`, wit
(path, src_text: str, is_header: bool)
| 2383 | |
| 2384 | |
| 2385 | def _header_contract_names(path, src_text: str, is_header: bool) -> set: |
| 2386 | """Override/virtual/final method names relevant to `path`: always the ones |
| 2387 | declared in the file itself -- this catches classes defined inline in a |
| 2388 | `.cpp` (e.g. the NativeTemplate implementations, whose `id()`/`name()` |
| 2389 | overrides live in the `.cpp`, not a header) -- unioned, for a `.cpp`, with |
| 2390 | those in the paired `.h`/`.hpp`/`.hxx`. A trivial body on one of these is |
| 2391 | an interface contract, not dead code.""" |
| 2392 | names = _contract_names_from_text(src_text) |
| 2393 | if is_header: |
| 2394 | return names |
| 2395 | for suffix in (".h", ".hpp", ".hxx"): |
| 2396 | cand = path.with_suffix(suffix) |
| 2397 | if not cand.exists(): |
| 2398 | continue |
| 2399 | key = str(cand) |
| 2400 | cached = _header_contract_cache.get(key) |
| 2401 | if cached is None: |
| 2402 | try: |
| 2403 | text = cand.read_text(encoding="utf-8", errors="replace") |
| 2404 | except OSError: |
| 2405 | text = "" |
| 2406 | cached = _contract_names_from_text(text) |
| 2407 | _header_contract_cache[key] = cached |
| 2408 | names = names | cached |
| 2409 | break |
| 2410 | return names |
| 2411 | |
| 2412 | |
| 2413 | def _is_constant_return_expr(node, src: bytes) -> bool: |
no test coverage detected