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

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 20 13:44:09 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) {
----------------
hokein wrote:

> From the usage it looks to be used only for GSL pointer analysis.

Yeah, that's right. Basically, it is the `!getDiagnostics().isIgnored(diag::warn_dangling_lifetime_pointer, SourceLocation());`.

>  IIUC, this option can even be completely removed from the parameters. We could just check whether the dangling-gsl warning is enabled or not in VisitGSLPointerArg and early exit if this is disabled.

Thanks, that's a good point. This will remove the flag in many places. Done.


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


More information about the cfe-commits mailing list