[llvm-branch-commits] [clang] [LifetimeSafety] Track per-field origins for record types (PR #195603)
Gábor Horváth via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jun 1 01:25:41 PDT 2026
================
@@ -112,16 +122,29 @@ bool OriginManager::hasOrigins(QualType QT) const {
// stored lambda's origins.
if (isStdCallableWrapperType(RD))
return true;
- // TODO: Limit to lambdas for now. This will be extended to user-defined
- // structs with pointer-like fields.
- if (!RD->isLambda())
+ // A lambda has origins when any capture has a tracked type; the lambda
+ // itself is tracked as a single origin.
+ if (RD->isLambda()) {
+ for (const auto *FD : RD->fields())
+ if (hasOrigins(FD->getType()))
+ return true;
+ return false;
+ }
+ // TODO: Unions are not tracked.
+ if (RD->isUnion())
return false;
for (const auto *FD : RD->fields())
- if (hasOrigins(FD->getType()))
+ if (FD->getAccess() == AS_public && hasOrigins(FD->getType()))
----------------
Xazax-hun wrote:
Here as well, I wonder if we want to permit private and protected field when they are actually accessible (analyzing a method).
https://github.com/llvm/llvm-project/pull/195603
More information about the llvm-branch-commits
mailing list