java-topology/tools/tickets/defects/swift-0001.md
russell@unturf.com db29a08762 undefect. CWE-407 — 92 sites, 42 ecosystems
B&W print-friendly diagrams + tinkerpop-0001 + wave-3 proof sections.
Squash of 94 local commits onto remote master.
2026-03-26 19:48:18 -04:00

1.1 KiB

id repo severity status created
swift-0001 swift LOW NOT-WORTH-FIXING 2026-03-23

Defect

File: lib/Sema/RewriteContext.cpp:454 Pattern: assert-only visited check, debug builds only Complexity: O(n) Language: C++

Description

The rewrite context in Swift's semantic analysis uses a linear scan to verify that a node has not been visited twice, but this check exists only within an assert() macro and is therefore compiled out in release builds. In debug builds, the O(n) scan is performed per node visit for sanity checking, slowing down debug-mode compilation for large files. There is no correctness impact in production builds.

Fix

Replace: linear scan inside assert(...) With: assert(visitedSet.insert(node).second) Data structure change: visited: SmallVector → visitedSet: llvm::SmallPtrSet

Work required

  • Patch in defects/swift/patch/
  • Unit test — asserts exact operation counts before/after (in defects/swift/unit/)
  • Integration test (in defects/swift/integration/)
  • Benchmark — before/after on V=100,200,400,800 (in defects/swift/bench/)
  • White paper section