| name | regjit-code-review |
| description | Use when reviewing RegJIT code changes for quality, correctness, and PCRE/RE2 compatibility |
| metadata | {"author":"acekingke"} |
RegJIT Code Review
Overview
Systematically review code changes in RegJIT for quality, correctness, and adherence to regex engine compatibility standards (PCRE, std::regex, RE2).
When to Use
- After writing significant code changes
- Before committing new features or fixes
- When reviewing anchor/quantifier behavior changes
- When modifying LLVM IR generation
- Before merging branches
Review Checklist
1. Scope & Context (5 min)
2. Functionality (15 min)
Key checks for RegJIT:
- Anchor semantics:
^ and $ match at correct positions only
- Zero-width assertions:
^, $, \b, \B behave as zero-width
- Quantifier precedence: applied to correct elements
- Search loop: attempts match at every offset (0 to strlen inclusive)
3. Code Quality (10 min)
RegJIT specific:
- BasicBlock naming is descriptive
- PHI node usage correct for loops
- No dead code blocks
- SSA form maintained
4. Architecture (10 min)
5. Testing (5 min)
6. Documentation (5 min)
Common RegJIT Issues to Watch
LLVM-Specific
Anchor/Quantifier
C++ Quality
Code Review Process
- Read the diff - understand changes at high level
- Check logic - trace through critical paths
- Verify tests - ensure coverage is adequate
- Look for issues - use common issues checklist
- Document findings - note specific file:line references
- Provide feedback - be specific and actionable
Example Review
## Code Review: anchor quantifier search loop
### Files
✅ src/regjit.cpp - Core matcher with search loop
✅ tests/test_anchor_quant_edge.cpp - Comprehensive test coverage
✅ AGENTS.md - Documentation updated
✅ Makefile - Test target added
### Functionality
✅ Search loop attempts match at every offset
✅ Zero-width anchor semantics preserved
✅ PCRE/RE2 compatible for ^*, $+, \b*, etc
✅ Edge cases handled (empty string, end of string)
### Code Quality
✅ Variable names descriptive (LoopCheckBB, TrySuccess)
✅ Comments explain search loop purpose
✅ IR structure clean and correct
✅ No compiler warnings
### Architecture
✅ Follows existing patterns
✅ LLVM integration proper
✅ No regressions in other features
### Testing
✅ 15 edge case tests added
✅ All existing tests pass
✅ Verified against PCRE behavior
### Result
✅ APPROVED - High quality implementation with excellent compatibility
Red Flags
| Flag | Severity | Action |
|---|
| Search loop removed/modified | 🔴 Critical | Ask why, verify PCRE compat |
| Anchor behavior changed | 🔴 Critical | Must verify with PCRE/RE2 |
| New zero-width code | 🟡 High | Check isZeroWidth() logic |
| LLVM IR dead code | 🟡 High | Remove or explain |
| Quantifier modification | 🟡 High | Verify greedy/non-greedy |
| Missing test for feature | 🟠 Medium | Request tests added |
| AGENTS.md not updated | 🟠 Medium | Minor, can update later |
| Code comments unclear | 🟢 Low | Ask for clarification |
Questions to Ask
- Why did you choose this approach? - Understand design intent
- What edge cases could break this? - Uncover missing handling
- How does this compare to PCRE? - Verify compatibility
- What tests verify this works? - Ensure coverage
- Will this impact performance? - Check optimization
- Is this the simplest solution? - Prefer clarity over cleverness
Success Criteria
Quick Reference
make clean && make test_all
./test_anchor_quant_edge
./test_anchor
./test_charclass
git diff src/regjit.cpp
make 2>&1 | grep -i warning
Converted and distributed by TomeVault — claim your Tome and manage your conversions.