diff options
| author | Alex Lorenz <arphaman@gmail.com> | 2016-10-24 09:42:34 +0000 |
|---|---|---|
| committer | Alex Lorenz <arphaman@gmail.com> | 2016-10-24 09:42:34 +0000 |
| commit | d90071429979aa23c7d493320aec56c552fc13ea (patch) | |
| tree | e92d0feda86d3f4b76340710f404bb66ad48fa20 /clang/lib/Sema | |
| parent | bba497fb65020b172e445cf175ec6789018fa419 (diff) | |
| download | bcm5719-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.cpp | 14 |
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; |

