================
@@ -68,11 +71,35 @@ void LifetimeSafetyAnalysis::run() {
runLifetimeChecker(*LoanPropagation, *LiveOrigins, FactMgr, AC, Reporter);
}
+
+void collectLifetimeStats(AnalysisDeclContext &AC, OriginManager &OM,
+ LifetimeSafetyStats &Stats) {
+ if (!AC.getBody())
+ return;
+ Stmt *FunctionBody = AC.getBody();
+ OM.collectMissingOrigins(FunctionBody, Stats);
+}
} // namespace internal
+void printStats(const LifetimeSafetyStats &Stats) {
+ llvm::errs() << "\n*** LifetimeSafety Missing Origin Stats "
+ "(expression_type : count) :\n\n";
+ unsigned totalMissingOrigins = 0;
+ for (const auto &[expr, count] : Stats.MissingOriginCount) {
+ llvm::errs() << expr << " : " << count << '\n';
+ totalMissingOrigins += count;
+ }
+ llvm::errs() << "Total missing origins: " << totalMissingOrigins << "\n";
+ llvm::errs() << "\n****************************************\n";
+}
+
void runLifetimeSafetyAnalysis(AnalysisDeclContext &AC,
- LifetimeSafetyReporter *Reporter) {
- internal::LifetimeSafetyAnalysis Analysis(AC, Reporter);
- Analysis.run();
+ LifetimeSafetyReporter *Reporter,
+ LifetimeSafetyStats &Stats, bool CollectStats) {
+ std::unique_ptr<internal::LifetimeSafetyAnalysis> Analysis =
----------------
usx95 wrote:
Looks like we do not need to have this on heap (via unique_ptr). I think it can
stay the same as a stack var.
https://github.com/llvm/llvm-project/pull/166568
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits