Skip to content

Conversation

usx95
Copy link
Contributor

@usx95 usx95 commented Oct 8, 2025

TL;DR

Restructure the C++ Lifetime Safety Analysis into a modular, component-based architecture with clear separation of concerns.

What changed?

This PR reorganizes the C++ Lifetime Safety Analysis code by:

  1. Breaking up the monolithic LifetimeSafety.cpp (1500+ lines) into multiple smaller, focused files
  2. Creating a dedicated LifetimeSafety directory with a clean component structure
  3. Introducing header files for each component with proper documentation
  4. Moving existing code into the appropriate component files:
    • Checker.h/cpp: Core lifetime checking logic
    • Dataflow.h: Generic dataflow analysis framework
    • Facts.h: Lifetime-relevant events and fact management
    • FactsGenerator.h/cpp: AST traversal for fact generation
    • LiveOrigins.h/cpp: Backward dataflow analysis for origin liveness
    • LoanPropagation.h/cpp: Forward dataflow analysis for loan tracking
    • Loans.h: Loan and access path definitions
    • Origins.h: Origin management
    • Reporter.h: Interface for reporting lifetime violations
    • Utils.h: Common utilities for the analysis

The code functionality remains the same, but is now better organized with clearer interfaces between components.

Why make this change?

This restructuring improves maintainability and extensibility of the lifetime safety analysis by:

  1. Making the code more modular and easier to understand
  2. Providing clear separation between different analysis components
  3. Establishing well-defined interfaces between components
  4. Making it easier to extend or modify individual parts of the analysis
  5. Improving documentation with dedicated header files for each component
  6. Preparing the codebase for future enhancements to the lifetime safety model

Copy link
Contributor Author

usx95 commented Oct 8, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

github-actions bot commented Oct 8, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@usx95 usx95 force-pushed the users/usx95/10-08-_lifetimesafety_refactor_the_analysis_into_smaller_files branch 5 times, most recently from 663d9c3 to 76f9e5c Compare October 8, 2025 19:46
@usx95 usx95 force-pushed the users/usx95/10-08-_lifetimesafety_refactor_the_analysis_into_smaller_files branch 2 times, most recently from f31d078 to 1aeea3f Compare October 8, 2025 21:27
Apply changes from code browser
@usx95 usx95 force-pushed the users/usx95/10-08-_lifetimesafety_refactor_the_analysis_into_smaller_files branch from 1aeea3f to 98bb91d Compare October 8, 2025 21:29
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