summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2016-10-24 09:42:34 +0000
committerAlex Lorenz <arphaman@gmail.com>2016-10-24 09:42:34 +0000
commitd90071429979aa23c7d493320aec56c552fc13ea (patch)
treee92d0feda86d3f4b76340710f404bb66ad48fa20 /clang/lib/Sema
parentbba497fb65020b172e445cf175ec6789018fa419 (diff)
downloadbcm5719-llvm-d90071429979aa23c7d493320aec56c552fc13ea.tar.gz
bcm5719-llvm-d90071429979aa23c7d493320aec56c552fc13ea.zip
[Sema] Formatting warnings should see through Objective-C message sends
This commit improves the '-Wformat' warnings by ensuring that the formatting checker can see through Objective-C message sends when we are calling an Objective-C method with an appropriate format_arg attribute. rdar://23622446 Differential Revision: https://reviews.llvm.org/D25820 llvm-svn: 284961
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 501f93ed629..fd8e19876b9 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -4479,6 +4479,20 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef<const Expr *> Args,
return SLCT_NotALiteral;
}
+ case Stmt::ObjCMessageExprClass: {
+ const auto *ME = cast<ObjCMessageExpr>(E);
+ if (const auto *ND = ME->getMethodDecl()) {
+ if (const auto *FA = ND->getAttr<FormatArgAttr>()) {
+ unsigned ArgIndex = FA->getFormatIdx();
+ const Expr *Arg = ME->getArg(ArgIndex - 1);
+ return checkFormatStringExpr(
+ S, Arg, Args, HasVAListArg, format_idx, firstDataArg, Type,
+ CallType, InFunctionCall, CheckedVarArgs, UncoveredArg, Offset);
+ }
+ }
+
+ return SLCT_NotALiteral;
+ }
case Stmt::ObjCStringLiteralClass:
case Stmt::StringLiteralClass: {
const StringLiteral *StrE = nullptr;
OpenPOWER on IntegriCloud