aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaDecl.cpp7
-rw-r--r--test/SemaObjC/format-strings-objc.m6
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 2b38718db9..2ee9e84a61 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -7974,6 +7974,13 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) {
"printf", 2,
Name->isStr("vasprintf") ? 0 : 3));
}
+
+ if (Name->isStr("__CFStringMakeConstantString")) {
+ // We already have a __builtin___CFStringMakeConstantString,
+ // but builds that use -fno-constant-cfstrings don't go through that.
+ if (!FD->getAttr<FormatArgAttr>())
+ FD->addAttr(::new (Context) FormatArgAttr(FD->getLocation(), Context, 1));
+ }
}
TypedefDecl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, QualType T,
diff --git a/test/SemaObjC/format-strings-objc.m b/test/SemaObjC/format-strings-objc.m
index 840694ac79..7faa995002 100644
--- a/test/SemaObjC/format-strings-objc.m
+++ b/test/SemaObjC/format-strings-objc.m
@@ -34,9 +34,9 @@ extern void CFStringCreateWithFormat(CFStringRef format, ...) __attribute__((for
#define CFSTR(cStr) ((CFStringRef) __builtin___CFStringMakeConstantString ("" cStr ""))
// This function is used instead of the builtin if -fno-constant-cfstrings.
-// The definition on Mac OS X is NOT annotated with format_arg as of 10.7,
-// but if it were, we want the same checking behavior as with the builtin.
-extern CFStringRef __CFStringMakeConstantString(const char *) __attribute__((format_arg(1)));
+// The definition on Mac OS X is NOT annotated with format_arg as of 10.8,
+// but clang will implicitly add the attribute if it's not written.
+extern CFStringRef __CFStringMakeConstantString(const char *);
int printf(const char * restrict, ...) ;