]> granicus.if.org Git - clang/commitdiff
Restore patch reversed in r118475. Fixes
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 9 Nov 2010 21:38:20 +0000 (21:38 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 9 Nov 2010 21:38:20 +0000 (21:38 +0000)
// rdar://8632525

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118634 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Builtins.def
lib/AST/ASTContext.cpp
lib/Sema/SemaLookup.cpp
lib/Sema/builtin_objc_msgSend.c [new file with mode: 0644]
test/CodeGenObjC/implicit-objc_msgSend.m
test/SemaObjC/builtin_objc_msgSend.m [new file with mode: 0644]

index eca73774f0c981d1243193b1be12f1b043afead1..1e8b6513d4fc3b92f77b927b5320662eacd23ade 100644 (file)
@@ -29,6 +29,8 @@
 //  d -> double
 //  z -> size_t
 //  F -> constant CFString
+//  G -> id
+//  H -> SEL
 //  a -> __builtin_va_list
 //  A -> "reference" to __builtin_va_list
 //  V -> Vector, following num elements and a base type.
@@ -559,11 +561,8 @@ LIBBUILTIN(_exit, "vi",           "fr",    "unistd.h")
 // POSIX setjmp.h
 LIBBUILTIN(_longjmp, "vJi",       "fr",    "setjmp.h")
 LIBBUILTIN(siglongjmp, "vSJi",    "fr",    "setjmp.h")
-
-// FIXME: This type isn't very correct, it should be
-//   id objc_msgSend(id, SEL)
-// but we need new type letters for that.
-LIBBUILTIN(objc_msgSend, "v*.",   "f",     "objc/message.h")
+//   id objc_msgSend(id, SEL, ...)
+LIBBUILTIN(objc_msgSend, "GGH.",   "f",     "objc/message.h")
 BUILTIN(__builtin_objc_memmove_collectable, "v*v*vC*z", "nF")
 
 // Builtin math library functions
index 0f449835412eacff18a2e985c0b51cf075b8ff42..c9c7e5c2af8632472f5f5800b2c8e63718c1b23a 100644 (file)
@@ -5384,6 +5384,12 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context,
   case 'F':
     Type = Context.getCFConstantStringType();
     break;
+  case 'G':
+    Type = Context.getObjCIdType();
+    break;
+  case 'H':
+    Type = Context.getObjCSelType();
+    break;
   case 'a':
     Type = Context.getBuiltinVaListType();
     assert(!Type.isNull() && "builtin va list type not initialized!");
index 65e8659f5ff852054899d4165aed60a0be76afe4..29b45df63b7f4cfa4a1fd38b85cf1cf37ffb2527 100644 (file)
@@ -484,6 +484,11 @@ static bool LookupBuiltin(Sema &S, LookupResult &R) {
         if (S.getLangOptions().CPlusPlus &&
             S.Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
           return false;
+        // When not in Objective-C mode, there is no builtin 'id' type.
+        // We won't have pre-defined library functions which use this type.
+        if (!S.getLangOptions().ObjC1 &&
+            S.Context.BuiltinInfo.GetTypeString(BuiltinID)[0] == 'G')
+          return false;
 
         NamedDecl *D = S.LazilyCreateBuiltin((IdentifierInfo *)II, BuiltinID,
                                              S.TUScope, R.isForRedeclaration(),
diff --git a/lib/Sema/builtin_objc_msgSend.c b/lib/Sema/builtin_objc_msgSend.c
new file mode 100644 (file)
index 0000000..357a5bc
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// rdar://8632525
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+    Class isa;
+} *id;
+
+
+typedef struct objc_selector *SEL;
+extern id objc_msgSend(id self, SEL op, ...);
+
index a21e869229a78ae06b4addb35c6199901d818808..322f82e920a0c0c75dd6a84ac7479676a13bd364 100644 (file)
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-llvm -o %t %s
-// RUN: grep -F 'declare i8* @objc_msgSend(...)' %t
+// RUN: grep -F 'declare i8* @objc_msgSend(i8*, i8*, ...)' %t
 
 typedef struct objc_selector *SEL;
 id f0(id x, SEL s) {
diff --git a/test/SemaObjC/builtin_objc_msgSend.m b/test/SemaObjC/builtin_objc_msgSend.m
new file mode 100644 (file)
index 0000000..bf17225
--- /dev/null
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// rdar://8632525
+extern id objc_msgSend(id self, SEL op, ...);