================
@@ -560,11 +560,23 @@ class LifetimeChecker {
FDef->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
return;
+ QualType ReturnType = FDef->getReturnType();
+ if (const auto *Ctor = dyn_cast<CXXConstructorDecl>(FDef))
+ ReturnType = AST.getTypeDeclType(cast<TypeDecl>(Ctor->getParent()));
+
+ bool ReturnTypeHasOrigins = FactMgr.getOriginMgr().hasOrigins(ReturnType);
+ if (getImplicitObjectParamLifetimeBoundAttr(FDef) && !ReturnTypeHasOrigins)
+ SemaHelper->reportInapplicableLifetimeboundReturnTy(
+ cast<CXXMethodDecl>(FDef));
+
for (const auto &PVD : FDef->parameters())
- if (PVD->hasAttr<LifetimeBoundAttr>() &&
- !FactMgr.getOriginMgr().hasOrigins(PVD->getType(),
- /*IntrinsicOnly=*/true))
- SemaHelper->reportInapplicableLifetimebound(PVD);
+ if (PVD->hasAttr<LifetimeBoundAttr>()) {
+ if (!FactMgr.getOriginMgr().hasOrigins(PVD->getType(),
+ /*IntrinsicOnly=*/true))
+ SemaHelper->reportInapplicableLifetimebound(PVD, PVD->getType());
+ if (!ReturnTypeHasOrigins && !isa<CXXConstructorDecl>(FDef))
----------------
Xazax-hun wrote:
I think it might be OK to warn for ctors as well, but maybe as a separate
warning group if we anticipate this to be not applicable for some scenarios.
https://github.com/llvm/llvm-project/pull/203767
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits