summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/PrintfFormatString.cpp
diff options
context:
space:
mode:
authorErik Pilkington <erik.pilkington@gmail.com>2019-08-14 16:57:11 +0000
committerErik Pilkington <erik.pilkington@gmail.com>2019-08-14 16:57:11 +0000
commitaa3855694ff45fc51bd71774c8bb15738b83ef16 (patch)
treed81ec80eb23fb10bd84987eff11e64f0dd74cdbf /clang/lib/AST/PrintfFormatString.cpp
parent4ae5efbe662e58836ac3a4f26467780990ca0ac2 (diff)
downloadbcm5719-llvm-aa3855694ff45fc51bd71774c8bb15738b83ef16.tar.gz
bcm5719-llvm-aa3855694ff45fc51bd71774c8bb15738b83ef16.zip
[Sema][ObjC] Fix a -Wformat false positive with localizedStringForKey
Only honour format_arg attributes on -[NSBundle localizedStringForKey] when its argument has a format specifier in it, otherwise its likely to just be a key to fetch localized strings. Fixes rdar://23622446 Differential revision: https://reviews.llvm.org/D27165 llvm-svn: 368878
Diffstat (limited to 'clang/lib/AST/PrintfFormatString.cpp')
-rw-r--r--clang/lib/AST/PrintfFormatString.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/AST/PrintfFormatString.cpp b/clang/lib/AST/PrintfFormatString.cpp
index 68f78299a0f..bae60d46440 100644
--- a/clang/lib/AST/PrintfFormatString.cpp
+++ b/clang/lib/AST/PrintfFormatString.cpp
@@ -463,6 +463,23 @@ bool clang::analyze_format_string::ParseFormatStringHasSArg(const char *I,
return false;
}
+bool clang::analyze_format_string::parseFormatStringHasFormattingSpecifiers(
+ const char *Begin, const char *End, const LangOptions &LO,
+ const TargetInfo &Target) {
+ unsigned ArgIndex = 0;
+ // Keep looking for a formatting specifier until we have exhausted the string.
+ FormatStringHandler H;
+ while (Begin != End) {
+ const PrintfSpecifierResult &FSR =
+ ParsePrintfSpecifier(H, Begin, End, ArgIndex, LO, Target, false, false);
+ if (FSR.shouldStop())
+ break;
+ if (FSR.hasValue())
+ return true;
+ }
+ return false;
+}
+
//===----------------------------------------------------------------------===//
// Methods on PrintfSpecifier.
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud