aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorJean-Daniel Dupas <devlists@shadowlab.org>2012-01-30 19:46:17 +0000
committerJean-Daniel Dupas <devlists@shadowlab.org>2012-01-30 19:46:17 +0000
commitce3aa395240207fd1cfa11342fd4b9fd46d6b025 (patch)
treefb740556564b03f630cf3f2fdb970e214b8bc2c7 /lib/Sema/SemaChecking.cpp
parent304e6f1495f4796ba5f93e8db2fa9e925a68dae8 (diff)
Disable "non literal format string" for NSString that result from a macro expansion.
This is to prevent diagnostic when using NSLocalizedString or CFCopyLocalizedString macros which are usually used in place of NS and CF strings literals. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149268 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index b31a5b8a84..7a852aefad 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -1586,6 +1586,13 @@ void Sema::CheckFormatArguments(Expr **Args, unsigned NumArgs,
format_idx, firstDataArg, Type))
return; // Literal format string found, check done!
+ // Do not emit diag when the string param is a macro expansion and the
+ // format is either NSString or CFString. This is a hack to prevent
+ // diag when using the NSLocalizedString and CFCopyLocalizedString macros
+ // which are usually used in place of NS and CF string literals.
+ if (Type == FST_NSString && Args[format_idx]->getLocStart().isMacroID())
+ return;
+
// If there are no arguments specified, warn with -Wformat-security, otherwise
// warn only with -Wformat-nonliteral.
if (NumArgs == format_idx+1)