================
@@ -1085,28 +1085,44 @@ void FactsGenerator::handleFunctionCall(const Expr
*Call,
flow(CallList, getOriginsList(*Args[0]), /*Kill=*/true);
return;
}
- auto IsArgLifetimeBound = [FD, &Args](unsigned I) -> bool {
+ auto GetLifetimeBoundInfo =
+ [FD](unsigned I) -> std::optional<LifetimeBoundInfo> {
const ParmVarDecl *PVD = nullptr;
if (const auto *Method = dyn_cast<CXXMethodDecl>(FD);
Method && Method->isInstance() && !isa<CXXConstructorDecl>(FD)) {
if (I == 0)
// For the 'this' argument, the attribute is on the method itself.
- return implicitObjectParamIsLifetimeBound(Method) ||
- shouldTrackImplicitObjectArg(
- *Args[0], Method, /*RunningUnderLifetimeSafety=*/true);
+ return implicitObjectParamIsLifetimeBound(Method)
+ ? std::optional<LifetimeBoundInfo>(
+ LifetimeBoundInfo{/*Param=*/nullptr,
+ /*IsImplicitObject=*/true})
+ : std::nullopt;
if ((I - 1) < Method->getNumParams())
// For explicit arguments, find the corresponding parameter
// declaration.
PVD = Method->getParamDecl(I - 1);
+ } else if (I < FD->getNumParams()) {
+ // For free functions or static methods.
+ PVD = FD->getParamDecl(I);
+ }
+ if (PVD && PVD->hasAttr<clang::LifetimeBoundAttr>())
+ return LifetimeBoundInfo{PVD, /*IsImplicitObject=*/false};
+ return std::nullopt;
+ };
+ auto IsArgLifetimeBound = [FD, &Args, &GetLifetimeBoundInfo](unsigned I) {
+ if (GetLifetimeBoundInfo(I))
+ return true;
+ if (const auto *Method = dyn_cast<CXXMethodDecl>(FD);
+ Method && Method->isInstance() && !isa<CXXConstructorDecl>(FD)) {
+ if (I == 0)
+ return shouldTrackImplicitObjectArg(
+ *Args[0], Method, /*RunningUnderLifetimeSafety=*/true);
} else if (I == 0 && shouldTrackFirstArgument(FD)) {
return true;
} else if (I == 1 && shouldTrackSecondArgument(FD)) {
return true;
----------------
NeKon69 wrote:
nit: you can omit all braces here
https://github.com/llvm/llvm-project/pull/206337
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits