Skip to content

Add GenContext field initializers and SourceFileScope RAII guard#202

Merged
ASDAlexander77 merged 1 commit into
mainfrom
refactor/gencontext-init-sourcefile-scope
Jul 11, 2026
Merged

Add GenContext field initializers and SourceFileScope RAII guard#202
ASDAlexander77 merged 1 commit into
mainfrom
refactor/gencontext-init-sourcefile-scope

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

Implements items A1 (partially) and A2 from docs/MLIRGen-refactoring-review.md:

  • A1 — GenContext default member initializers. GenContext() = default; left ~15 bools and raw pointers indeterminate; every current instance happens to be value-initialized or copied, but a plain GenContext ctx; would compile and produce garbage codegen flags. All scalar/pointer fields now have = false / = nullptr initializers. (The ownership half of A1 — cleanUps/cleanUpOps/passResult/state raw-pointer lifetime — is intentionally left for a dedicated PR.)
  • A2 — SourceFileScope RAII guard. Replaces the 9 hand-rolled MLIRValueGuard vgSourceFile / vgFileName + assignment pairs (3 include/import-loading sites, 6 generic-instantiation sites) with a single class composed of two MLIRValueGuards using the save-and-set constructor from Refactor theModule handling in MLIRGenImpl #201. A converting constructor handles the include-site variant that interns the UTF-8 file name. Also removes a stray ;; at one of the sites.

Net −17 lines; no behavior change.

Test plan

  • tslang rebuilt cleanly (vs2026 debug)
  • Smoke test covering all six generic-instantiation SourceFileScope sites (generic function, generic class, generic interface specialization) JIT-runs with expected output 5 21 7 x
  • Prior smoke test for the Refactor theModule handling in MLIRGenImpl #201 paths still outputs 42 15 42 3 1
  • MLIRGenTests.exe: 12/12 pass

🤖 Generated with Claude Code

- Default member initializers on all GenContext scalar/pointer fields;
  a plain "GenContext ctx;" no longer produces indeterminate codegen
  flags (review doc item A1)
- SourceFileScope replaces the 9 hand-rolled sourceFile/mainSourceFileName
  guard pairs, using the MLIRValueGuard save-and-set constructor
  (review doc item A2)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ASDAlexander77 ASDAlexander77 merged commit 102ef9d into main Jul 11, 2026
2 checks passed
@ASDAlexander77 ASDAlexander77 deleted the refactor/gencontext-init-sourcefile-scope branch July 11, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant