[PATCH] D23820: Do not warn about format strings that are indexed string literals.
Meike Baumgärtner via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 12 18:41:13 PDT 2016
meikeb marked 6 inline comments as done.
meikeb added a comment.
Thanks for taking the time and doing these great reviews! Really appreciated!
================
Comment at: lib/Sema/SemaChecking.cpp:4143-4150
@@ -4049,3 +4142,10 @@
if (StrE) {
- CheckFormatString(S, StrE, E, Args, HasVAListArg, format_idx,
+ if (Offset.isNegative() || Offset > StrE->getLength()) {
+ // TODO: It would be better to have an explicit warning for out of
+ // bounds literals.
+ return SLCT_NotALiteral;
+ }
+ FormatStringLiteral FStr =
+ FormatStringLiteral(StrE, Offset.sextOrTrunc(64).getSExtValue());
+ CheckFormatString(S, &FStr, E, Args, HasVAListArg, format_idx,
firstDataArg, Type, InFunctionCall, CallType,
----------------
The = case is part of a different warning. It's checked in CheckFormatString.
https://reviews.llvm.org/D23820
More information about the cfe-commits
mailing list