[clang] [clang] Merge lifetimebound and GSL code paths for lifetime analysis (PR #104906)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 20 03:17:31 PDT 2024


================
@@ -478,13 +449,32 @@ static void visitLifetimeBoundArguments(IndirectLocalPath &Path, Expr *Call,
       CheckCoroObjArg = false;
     if (implicitObjectParamIsLifetimeBound(Callee) || CheckCoroObjArg)
       VisitLifetimeBoundArg(Callee, ObjectArg);
+    else if (EnableLifetimeWarnings) {
+      if (auto *CME = dyn_cast<CXXMethodDecl>(Callee);
+          CME && shouldTrackImplicitObjectArg(CME))
+        VisitGSLPointerArg(Callee, ObjectArg,
+                        !Callee->getReturnType()->isReferenceType());
+    }
   }
 
   for (unsigned I = 0,
                 N = std::min<unsigned>(Callee->getNumParams(), Args.size());
        I != N; ++I) {
     if (CheckCoroCall || Callee->getParamDecl(I)->hasAttr<LifetimeBoundAttr>())
       VisitLifetimeBoundArg(Callee->getParamDecl(I), Args[I]);
+    else if (EnableLifetimeWarnings) {
+      if (I == 0) {
----------------
Xazax-hun wrote:

Nit: maybe `EnableLifetimeWarnings && I == 0` to reduce the indentation?

https://github.com/llvm/llvm-project/pull/104906


More information about the cfe-commits mailing list