[clang] [LifetimeSafety] Add missing origins stats for lifetime analysis (PR #166568)

via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 28 09:39:49 PST 2025


DEBADRIBASAK wrote:

@Xazax-hun @usx95 I do not think it is feasible to add the `StmtClassName` and `QualType` as keys without converting them to strings.

1. I tried using a DenseMap with `QualType` as the keys, but that is not allowed since QualType does not have tombstone.
2. I was planning to use the `StmtClass` as an index in an integer array of size `Stmt::lastStmtConstant+1`, and use `StmtClassInfo` array of `StmtClassNameTable` objects for getting their names while printing. But `StmtClassInfo` is a static array inside `Stmt.cpp` file and we cannot use it in other files.

I used two string maps for now:

```
*** LifetimeSafety Missing Origin per QualType: (QualType : count) :

basic_string<char> : 3
basic_string_view<char> : 1
class std::basic_string<char> : 1
char * : 12
const_iterator : 1
const value_type : 3
std::string_view : 27


*** LifetimeSafety Missing Origin per StmtClassName: (StmtClassName : count) :

CXXOperatorCallExpr : 6
BinaryOperator : 3
CXXMemberCallExpr : 2
UnaryOperator : 1
DeclRefExpr : 36

Total missing origins: 48
```

https://github.com/llvm/llvm-project/pull/166568


More information about the cfe-commits mailing list