[cfe-commits] r94787 - /cfe/trunk/lib/Sema/SemaChecking.cpp
Ted Kremenek
kremenek at apple.com
Thu Jan 28 17:50:07 PST 2010
Author: kremenek
Date: Thu Jan 28 19:50:07 2010
New Revision: 94787
URL: http://llvm.org/viewvc/llvm-project?rev=94787&view=rev
Log:
Alternate format string checking: check for excess data arguments.
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=94787&r1=94786&r2=94787&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Jan 28 19:50:07 2010
@@ -1304,6 +1304,8 @@
IsObjCLiteral(isObjCLiteral), Beg(beg),
HasVAListArg(hasVAListArg),
TheCall(theCall), FormatIdx(formatIdx) {}
+
+ void DoneProcessing();
void HandleNullChar(const char *nullCharacter);
@@ -1434,6 +1436,14 @@
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 @@
HasVAListArg, TheCall, format_idx);
analyze_printf::ParseFormatString(H, Str, Str + StrLen);
+ H.DoneProcessing();
}
//===--- CHECK: Return Address of Stack Variable --------------------------===//
More information about the cfe-commits
mailing list