diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-02-27 17:58:43 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-02-27 17:58:43 +0000 |
commit | 3d692df4b9c58895f9843b03543ec57447c93679 (patch) | |
tree | e046ee17045f5b98b10431dd36af45c622741ab9 /lib/Sema/SemaChecking.cpp | |
parent | b2fb6de9070fea9abc56c8e8d5469066e964cefe (diff) |
When checking printf-arguments for functions with '__attribute__ ((format (printf, X, Y)))'
set HasVAListArg to true when 'Y' is 0 (i.e., ignore the data arguments).
This fixes <rdar://problem/6623513>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65642 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 3e6bd5a2ef..b0d6901953 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -143,12 +143,14 @@ Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall) { // Printf checking. if (const FormatAttr *Format = FDecl->getAttr<FormatAttr>()) { if (Format->getType() == "printf") { - bool HasVAListArg = false; - if (const FunctionProtoType *Proto - = FDecl->getType()->getAsFunctionProtoType()) + bool HasVAListArg = Format->getFirstArg() == 0; + if (!HasVAListArg) { + if (const FunctionProtoType *Proto + = FDecl->getType()->getAsFunctionProtoType()) HasVAListArg = !Proto->isVariadic(); + } CheckPrintfArguments(TheCall, HasVAListArg, Format->getFormatIdx() - 1, - Format->getFirstArg() - 1); + HasVAListArg ? 0 : Format->getFirstArg() - 1); } } |