-
Notifications
You must be signed in to change notification settings - Fork 0
Analyzer Modules Architecture
Hugo edited this page Feb 26, 2026
·
1 revision
This page describes the module split around StackUsageAnalyzer that keeps orchestration concerns separate from pass logic and reporting.
- Reduce coupling between CLI/app orchestration and LLVM analysis details.
- Keep module responsibilities narrow and independently testable.
- Preserve existing behavior while improving maintainability.
Role:
- Coordinator for module-level analysis execution.
- Orders preparation, pass execution, and diagnostic emission.
Pattern:
- Facade over lower-level analyzer services.
Role:
- Builds prepared module context (
PreparedModule). - Computes stack metadata, filtered call graph, and recursion state.
Pattern:
- Application service with deterministic derivation logic.
Role:
- Resolves source file/line/column from LLVM debug metadata.
- Provides fallback logic for
alloca/debug intrinsics.
Pattern:
- Stateless domain service.
Role:
- Converts analysis findings to final
Diagnosticobjects. - Centralizes severity, rule IDs, message formatting, and CWE enrichment.
Pattern:
- Adapter between analysis-domain findings and report-domain output.
Role:
- Classifies findings in statically unreachable code paths.
Pattern:
- Isolated policy module.
- Input loading compiles/parses sources into an LLVM module.
-
ModulePreparationServicederives reusable analysis context. - Analysis modules compute findings.
-
Reachabilityannotates/filter findings where needed. -
LocationResolvermaps findings to source coordinates. -
DiagnosticEmitteremits final diagnostics for human/JSON/SARIF outputs.
- Better testability: each module has a narrow API and predictable inputs.
- Clear evolution path: adding checks does not require touching CLI/app orchestration.
- Lower regression risk: location/rule formatting logic is centralized.
Fine-grained unit tests:
test/unit/analyzer_module_unit_tests.cpp
Covered modules:
LocationResolverReachabilityModulePreparationService
Build target:
-
stack_usage_analyzer_unit_tests(enable with-DBUILD_ANALYZER_UNIT_TESTS=ON)