## Diamond Recursion Scan — CLEAN

**Scan date:** 2026-03-29
**Pattern:** Recursive cycle/dependency check without visited set (CWE-407 diamond recursion, O(2^D))

### Files examined

- `lib/Sema/TypeCheckCircularity.cpp` — infinite-size type check
- `lib/Sema/TypeCheckDecl.cpp` — declaration type checking

### Findings

**TypeCheckCircularity.cpp:** Uses `llvm::DenseMap<CanType, TrackingInfo> TrackingMap` as a global visited set for the circularity check. The `TrackingMap.insert()` + `isBeingExpanded()` flags prevent re-entry on any previously seen type. Clean O(N) traversal.

**TypeCheckDecl.cpp:** `canSkipCircularityCheck` is a fast early-exit predicate, not a recursive traversal.

### Verdict: CLEAN — no diamond recursion CWE-407 found
