[clang] [LifetimeSafety] Add missing origins stats for lifetime analysis (PR #166568)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 20 07:29:46 PST 2025
================
@@ -39,6 +46,17 @@ OriginID OriginManager::get(const Expr &E) {
auto It = ExprToOriginID.find(&E);
if (It != ExprToOriginID.end())
return It->second;
+
+ // if the expression has no specific origin, increment the missing origin
+ // counter.
+ std::string ExprStr(E.getStmtClassName());
+ ExprStr = ExprStr + "<" + E.getType().getAsString() + ">";
+ auto CountIt = ExprTypeToMissingOriginCount.find(ExprStr);
+ if (CountIt == ExprTypeToMissingOriginCount.end()) {
+ ExprTypeToMissingOriginCount[ExprStr] = 1;
+ } else {
+ CountIt->second++;
+ }
----------------
DEBADRIBASAK wrote:
Thank you for the feedback. I will incorporate the changes. But I have one query regarding this statement:
> We do this collection at the end of the analysis
Currently we create the origin if it is not available in the map inside `OriginMgr`. If we perform the missing origin count at the end of the analysis it will never show any missing origin.
https://github.com/llvm/llvm-project/pull/166568
More information about the cfe-commits
mailing list