================ @@ -6849,6 +6849,73 @@ static void handleSwiftAsyncAttr(Sema &S, Decl *D, const ParsedAttr &AL) { checkSwiftAsyncErrorBlock(S, D, ErrorAttr, AsyncAttr); } +// Warn if parent function misses format attribute. Parent function misses +// format attribute if there is an argument format string forwarded to calling +// function with format attribute, parent function has a parameter which type +// is either string or pointer to char and parent function format attribute +// type does not match with calling function format attribute type. +void Sema::DiagnoseMissingFormatAttributes(const FunctionDecl *FDecl, + ArrayRef<const Expr *> Args, + SourceLocation Loc) { + assert(FDecl); + + // Check if function has format attribute with forwarded format string. + IdentifierInfo *AttrType; + if (!llvm::any_of( + FDecl->specific_attrs<FormatAttr>(), [&](const FormatAttr *Attr) { + if (!Args[Attr->getFirstArg()]->getReferencedDeclOfCallee()) ---------------- aaronpuchert wrote:
Do we need to do a bounds check before we access into the array or has this already been checked? Also, the attribute arguments start counting at 1, but array access starts at 0, so I would assume we're off by one here? And shouldn't we look up `Attr->getFormatIdx()` instead? The "first argument" can be 0, if the caller takes a `va_list` for example. https://github.com/llvm/llvm-project/pull/70024 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits