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

Aaron Puchert via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 24 18:31:18 PDT 2023


================
@@ -435,6 +435,86 @@ bool Sema::ConstantFoldAttrArgs(const AttributeCommonInfo &CI,
   return true;
 }
 
+// Warn if parent function does not have builtin function format attribute.
+void Sema::DiagnoseMissingFormatAttributes(NamedDecl *FDecl,
+                                           SourceLocation Loc) {
+  if (!FDecl)
+    return;
+
+  auto *FD = dyn_cast_or_null<FunctionDecl>(FDecl);
+  if (!FD)
+    return;
----------------
aaronpuchert wrote:

Unless I'm missing something, the only caller is already passing a non-null `FunctionDecl`.
```suggestion
void Sema::DiagnoseMissingFormatAttributes(FunctionDecl *FD,
                                           SourceLocation Loc) {
```

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


More information about the cfe-commits mailing list