Alternate format string checking: check for excess data arguments.

llvm-svn: 94787
This commit is contained in:
Ted Kremenek 2010-01-29 01:50:07 +00:00
parent 180ef09371
commit 019d224d91
1 changed files with 11 additions and 0 deletions

View File

@ -1304,6 +1304,8 @@ public:
IsObjCLiteral(isObjCLiteral), Beg(beg),
HasVAListArg(hasVAListArg),
TheCall(theCall), FormatIdx(formatIdx) {}
void DoneProcessing();
void HandleNullChar(const char *nullCharacter);
@ -1434,6 +1436,14 @@ CheckPrintfHandler::HandleFormatSpecifier(const analyze_printf::FormatSpecifier
return true;
}
void CheckPrintfHandler::DoneProcessing() {
// Does the number of data arguments exceed the number of
// format conversions in the format string?
if (!HasVAListArg && NumConversions < NumDataArgs)
S.Diag(getDataArg(NumConversions+1)->getLocStart(),
diag::warn_printf_too_many_data_args)
<< getFormatRange();
}
void
Sema::AlternateCheckPrintfString(const StringLiteral *FExpr,
@ -1467,6 +1477,7 @@ Sema::AlternateCheckPrintfString(const StringLiteral *FExpr,
HasVAListArg, TheCall, format_idx);
analyze_printf::ParseFormatString(H, Str, Str + StrLen);
H.DoneProcessing();
}
//===--- CHECK: Return Address of Stack Variable --------------------------===//