================
@@ -3460,8 +3460,10 @@ void Sema::checkCall(NamedDecl *FDecl, const 
FunctionProtoType *Proto,
     }
   }
 
-  if (FD)
+  if (FD) {
     diagnoseArgDependentDiagnoseIfAttrs(FD, ThisArg, Args, Loc);
+    DetectMissingFormatAttributes(FD, Args, Loc);
----------------
aaronpuchert wrote:

Can we put this into the block up there with the comment "Printf and scanf 
checking"? We care about the same case: calling a function with a `FormatAttr`. 
Up there is a loop going over these attributes. Why don't we add this call to 
the loop, processing a single attribute at a time?

The reason is to avoid adding complexity in the common case of no such 
attribute. Up there we already have the check, so we're not adding anything.

And I don't think we lose anything. If anything, this should make the check 
simpler.
* Callees with multiple attributes are probably rare, but in that case we could 
still forward multiple format strings as @apple-fcloutier pointed out.
* If we treat these attributes independently and suggest contradictory 
attributes, this is probably an issue anyway.

Although in theory I don't see a reason why this is contradictory at all, at 
least without argument checking: it would simply constrain the format string to 
strings accepted by multiple formatting languages.

Or, as @apple-fcloutier suggested, just put it into `CheckFormatArguments`.

https://github.com/llvm/llvm-project/pull/105479
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to