================
@@ -51,7 +51,19 @@ class MissingOriginCollector
} // namespace
bool hasOrigins(QualType QT) {
- return QT->isPointerOrReferenceType() || isGslPointerType(QT);
+ if (QT->isPointerOrReferenceType() || isGslPointerType(QT))
+ return true;
+ const auto *RD = QT->getAsCXXRecordDecl();
+ if (!RD)
+ return false;
+ // TODO: Limit to lambdas for now. This will be extended to user-defined
+ // structs with pointer-like fields.
+ if (!RD->isLambda())
+ return false;
+ for (const auto *FD : RD->fields())
+ if (hasOrigins(FD->getType()))
----------------
Xazax-hun wrote:
Please add a test case that has reference captures like:
```
int i;
auto lambda = [&]() { return i; };
```
Here, we capture only an integer but capture it by reference, so the lambda
should not outlive the integer.
Do we get a reference field here?
https://github.com/llvm/llvm-project/pull/185216
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits