From 94ad274c249527f82387413ad0876e7571bbf926 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Mon, 8 Nov 2010 22:53:18 +0000 Subject: [PATCH] Provide a precise builtin declaration for objc_msgSend to avoid a bogus warning. Fixes //rdar: //8632525 llvm-svn: 118451 --- clang/include/clang/Basic/Builtins.def | 7 +++---- clang/lib/AST/ASTContext.cpp | 6 ++++++ clang/test/CodeGenObjC/implicit-objc_msgSend.m | 2 +- clang/test/SemaObjC/builtin_objc_msgSend.m | 3 +++ 4 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 clang/test/SemaObjC/builtin_objc_msgSend.m diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def index eca73774f0c9..28a507840986 100644 --- a/clang/include/clang/Basic/Builtins.def +++ b/clang/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") +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/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index b2451a2d867d..26e53ca57a69 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/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/clang/test/CodeGenObjC/implicit-objc_msgSend.m b/clang/test/CodeGenObjC/implicit-objc_msgSend.m index a21e869229a7..322f82e920a0 100644 --- a/clang/test/CodeGenObjC/implicit-objc_msgSend.m +++ b/clang/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/clang/test/SemaObjC/builtin_objc_msgSend.m b/clang/test/SemaObjC/builtin_objc_msgSend.m new file mode 100644 index 000000000000..7530d904f4af --- /dev/null +++ b/clang/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, ...);