================
@@ -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))
----------------
NeKon69 wrote:

Yeah, this will be pretty noisy; parameters could still escape to fields even 
if the current object doesn't have origins. I'll use the same `experimental` 
format for this probably.

https://github.com/llvm/llvm-project/pull/203767
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to