diff options
author | David Blaikie <dblaikie@gmail.com> | 2012-02-10 21:07:25 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2012-02-10 21:07:25 +0000 |
commit | a73cdcbc1dc1ed98c54556c6adcd2b12301759cc (patch) | |
tree | ad5e3355a9fcad3a9c617ae4390a02a177828a5c /lib/Sema/SemaChecking.cpp | |
parent | ae9329570ba16e48ffdfe3d55349b53fd893a711 (diff) |
Support all null pointer literals in format strings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150276 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index be326880d5..cf0469592f 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -1369,6 +1369,13 @@ bool Sema::SemaCheckStringLiteral(const Expr *E, Expr **Args, E = E->IgnoreParenCasts(); + if (E->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull)) + // Technically -Wformat-nonliteral does not warn about this case. + // The behavior of printf and friends in this case is implementation + // dependent. Ideally if the format string cannot be null then + // it should have a 'nonnull' attribute in the function prototype. + return true; + switch (E->getStmtClass()) { case Stmt::BinaryConditionalOperatorClass: case Stmt::ConditionalOperatorClass: { @@ -1381,14 +1388,6 @@ bool Sema::SemaCheckStringLiteral(const Expr *E, Expr **Args, inFunctionCall); } - case Stmt::GNUNullExprClass: - case Stmt::IntegerLiteralClass: - // Technically -Wformat-nonliteral does not warn about this case. - // The behavior of printf and friends in this case is implementation - // dependent. Ideally if the format string cannot be null then - // it should have a 'nonnull' attribute in the function prototype. - return true; - case Stmt::ImplicitCastExprClass: { E = cast<ImplicitCastExpr>(E)->getSubExpr(); goto tryAgain; |