From ba8bda05fefd3bb2f1ef201784b685f715bdde29 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 9 Nov 2010 21:38:20 +0000 Subject: [PATCH] Restore patch reversed in r118475. Fixes // rdar://8632525 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118634 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/Builtins.def | 9 ++++----- lib/AST/ASTContext.cpp | 6 ++++++ lib/Sema/SemaLookup.cpp | 5 +++++ lib/Sema/builtin_objc_msgSend.c | 12 ++++++++++++ test/CodeGenObjC/implicit-objc_msgSend.m | 2 +- test/SemaObjC/builtin_objc_msgSend.m | 3 +++ 6 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 lib/Sema/builtin_objc_msgSend.c create mode 100644 test/SemaObjC/builtin_objc_msgSend.m diff --git a/include/clang/Basic/Builtins.def b/include/clang/Basic/Builtins.def index eca73774f0..1e8b6513d4 100644 --- a/include/clang/Basic/Builtins.def +++ b/include/clang/Basic/Builtins.def @@ -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 diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 0f44983541..c9c7e5c2af 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -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!"); diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 65e8659f5f..29b45df63b 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -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 index 0000000000..357a5bc26e --- /dev/null +++ b/lib/Sema/builtin_objc_msgSend.c @@ -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, ...); + diff --git a/test/CodeGenObjC/implicit-objc_msgSend.m b/test/CodeGenObjC/implicit-objc_msgSend.m index a21e869229..322f82e920 100644 --- a/test/CodeGenObjC/implicit-objc_msgSend.m +++ b/test/CodeGenObjC/implicit-objc_msgSend.m @@ -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 index 0000000000..bf17225a04 --- /dev/null +++ b/test/SemaObjC/builtin_objc_msgSend.m @@ -0,0 +1,3 @@ +// RUN: %clang_cc1 %s -fsyntax-only -verify +// rdar://8632525 +extern id objc_msgSend(id self, SEL op, ...); -- 2.40.0