[clang] [clang] Catch missing format attributes (PR #70024)

Aaron Puchert via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 10 14:06:44 PST 2023


https://github.com/aaronpuchert commented:

Two additional checks that might be interesting:
* Look at the `FormatIdx` argument. Is it a `DeclRefExpr` referring to a `ParmVarDecl`, perhaps with some conversions? (There is probably going to be an `LValueToRValue` conversion at least. There are special `Ignore*` functions on `Expr` to unwrap that.) If it is, we should propagate the attribute, if not then not.
* For `FirstArg` it seems that GCC only warns when we call a `v*` function, or the called function has `FirstArg == 0`, probably because forwarding to a variadic function isn't really possible in C. It doesn't seem to check whether we're actually forwarding. What you've implemented here (deciding based on `ParentFuncDecl->isVariadic()`) seems like a reasonable heuristic. But it probably makes sense to additionally restrict based on the archetype or `FirstArg`. Or is that what you're doing with `Args[Attr->getFirstArg()]`?

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


More information about the cfe-commits mailing list