Added remaining objective-c library builtins (as in gcc) to
clang. // rdar://8735023


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121441 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/Builtins.def b/include/clang/Basic/Builtins.def
index f3e8b2b..bf8272f 100644
--- a/include/clang/Basic/Builtins.def
+++ b/include/clang/Basic/Builtins.def
@@ -569,8 +569,50 @@
 LIBBUILTIN(siglongjmp, "vSJi",    "fr",    "setjmp.h", ALL_LANGUAGES)
 //   id objc_msgSend(id, SEL, ...)
 LIBBUILTIN(objc_msgSend, "GGH.",   "f",     "objc/message.h", OBJC_LANG)
+
+// long double objc_msgSend_fpret(id self, SEL op, ...) 
+LIBBUILTIN(objc_msgSend_fpret, "LdGH.", "f", "objc/message.h", OBJC_LANG)
+// id objc_msgSend_stret (id, SEL, ...)
+LIBBUILTIN(objc_msgSend_stret, "GGH.", "f", "objc/message.h", OBJC_LANG)
+// id objc_msgSendSuper(struct objc_super *super, SEL op, ...)
+LIBBUILTIN(objc_msgSendSuper, "Gv*H.", "f", "objc/message.h", OBJC_LANG)
+// void objc_msgSendSuper_stret(struct objc_super *super, SEL op, ...)
+LIBBUILTIN(objc_msgSendSuper_stret, "vv*H.", "f", "objc/message.h", OBJC_LANG)
 //   id objc_getClass(const char *name)
 LIBBUILTIN(objc_getClass, "GcC*",   "f",     "objc/runtime.h", OBJC_LANG)
+//   id objc_getMetaClass(const char *name)
+LIBBUILTIN(objc_getMetaClass, "GcC*",   "f", "objc/runtime.h", OBJC_LANG)
+// void objc_enumerationMutation(id)
+LIBBUILTIN(objc_enumerationMutation, "vG", "f", "objc/runtime.h", OBJC_LANG)
+
+// id objc_read_weak(id *location)
+LIBBUILTIN(objc_read_weak, "GG*", "f", "/objc/objc-auto.h", OBJC_LANG)
+// id objc_assign_weak(id value, id *location)
+LIBBUILTIN(objc_assign_weak, "GGG*", "f", "/objc/objc-auto.h", OBJC_LANG)
+// id objc_assign_ivar(id value, id dest, ptrdiff_t offset)
+// FIXME. Darwin has ptrdiff_t typedef'ed to int.
+LIBBUILTIN(objc_assign_ivar, "GGGi", "f", "/objc/objc-auto.h", OBJC_LANG)
+// id objc_assign_global(id val, id *dest)
+LIBBUILTIN(objc_assign_global, "GGG*", "f", "/objc/objc-auto.h", OBJC_LANG)
+// id objc_assign_strongCast(id val, id *dest
+LIBBUILTIN(objc_assign_strongCast, "GGG*", "f", "/objc/objc-auto.h", OBJC_LANG)
+
+// id objc_exception_extract(void *localExceptionData)
+LIBBUILTIN(objc_exception_extract, "Gv*", "f", "/objc/objc-exception.h", OBJC_LANG)
+// void objc_exception_try_enter(void *localExceptionData)
+LIBBUILTIN(objc_exception_try_enter, "vv*", "f", "/objc/objc-exception.h", OBJC_LANG)
+// void objc_exception_try_exit(void *localExceptionData)
+LIBBUILTIN(objc_exception_try_exit, "vv*", "f", "/objc/objc-exception.h", OBJC_LANG)
+// int objc_exception_match(Class exceptionClass, id exception)
+LIBBUILTIN(objc_exception_match, "iGG", "f", "/objc/objc-exception.h", OBJC_LANG)
+// void objc_exception_throw(id exception)
+LIBBUILTIN(objc_exception_throw, "vG", "f", "/objc/objc-exception.h", OBJC_LANG)
+
+// int objc_sync_enter(id obj)
+LIBBUILTIN(objc_sync_enter, "iG", "f", "/objc/objc-sync.h", OBJC_LANG)
+// int objc_sync_exit(id obj)
+LIBBUILTIN(objc_sync_exit, "iG", "f", "/objc/objc-sync.h", OBJC_LANG)
+
 BUILTIN(__builtin_objc_memmove_collectable, "v*v*vC*z", "nF")
 
 // Builtin math library functions
diff --git a/test/SemaObjC/builtin_objc_getClass.m b/test/SemaObjC/builtin_objc_getClass.m
deleted file mode 100644
index de4713b..0000000
--- a/test/SemaObjC/builtin_objc_getClass.m
+++ /dev/null
@@ -1,4 +0,0 @@
-// RUN: %clang_cc1 %s -fsyntax-only -std=gnu99 -verify
-// rdar://8592641
-Class f0() { return objc_getClass("a"); } // expected-warning {{implicitly declaring C library function 'objc_getClass' with type 'id (const char *)'}} \
-					  // expected-note {{please include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_getClass'}}
diff --git a/test/SemaObjC/builtin_objc_lib_functions.m b/test/SemaObjC/builtin_objc_lib_functions.m
new file mode 100644
index 0000000..02b05b9
--- /dev/null
+++ b/test/SemaObjC/builtin_objc_lib_functions.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -x objective-c %s -fsyntax-only -verify
+// rdar://8592641
+Class f0() { return objc_getClass("a"); } // expected-warning {{implicitly declaring C library function 'objc_getClass' with type 'id (const char *)'}} \
+					  // expected-note {{please include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_getClass'}}
+
+// rdar://8735023
+Class f1() { return objc_getMetaClass("a"); } // expected-warning {{implicitly declaring C library function 'objc_getMetaClass' with type 'id (const char *)'}} \
+					  // expected-note {{please include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_getMetaClass'}}
+
+void f2(id val) { objc_enumerationMutation(val); } // expected-warning {{implicitly declaring C library function 'objc_enumerationMutation' with type 'void (id)'}} \
+						   // expected-note {{please include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_enumerationMutation'}}
+
+long double f3(id self, SEL op) { return objc_msgSend_fpret(self, op); } // expected-warning {{implicitly declaring C library function 'objc_msgSend_fpret' with type 'long double (id, SEL, ...)'}} \
+    // expected-note {{please include the header <objc/message.h> or explicitly provide a declaration for 'objc_msgSend_fpret'}}
+
+id f4(struct objc_super *super, SEL op) { // expected-warning {{declaration of 'struct objc_super' will not be visible outside of this function}}
+  return objc_msgSendSuper(super, op); // expected-warning {{implicitly declaring C library function 'objc_msgSendSuper' with type 'id (void *, SEL, ...)'}} \
+					// expected-note {{please include the header <objc/message.h> or explicitly provide a declaration for 'objc_msgSendSuper'}}
+}
+
+id f5(id val, id *dest) {
+  return objc_assign_strongCast(val, dest); // expected-warning {{implicitly declaring C library function 'objc_assign_strongCast' with type 'id (id, id *)'}} \
+					    // expected-note {{please include the header </objc/objc-auto.h> or explicitly provide a declaration for 'objc_assign_strongCast'}}
+}
+
+int f6(Class exceptionClass, id exception) {
+  return objc_exception_match(exceptionClass, exception); // expected-warning {{implicitly declaring C library function 'objc_exception_match' with type 'int (id, id)'}} \
+  							  // expected-note {{please include the header </objc/objc-exception.h> or explicitly provide a declaration for 'objc_exception_match'}}
+}