[cfe-commits] r171492 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/Basic/Builtins.def lib/AST/ASTContext.cpp lib/Sema/SemaDecl.cpp test/SemaObjC/builtin_objc_lib_functions.m test/SemaObjC/builtin_objc_msgSend.m

Fariborz Jahanian fjahanian at apple.com
Fri Jan 4 10:45:40 PST 2013


Author: fjahanian
Date: Fri Jan  4 12:45:40 2013
New Revision: 171492

URL: http://llvm.org/viewvc/llvm-project?rev=171492&view=rev
Log:
Fix up various builtin declaration of objc_msgSend families
to match those foung in objc.h an avoid spurious warnings. 
// rdar://12489098

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/include/clang/Basic/Builtins.def
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaObjC/builtin_objc_lib_functions.m
    cfe/trunk/test/SemaObjC/builtin_objc_msgSend.m

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=171492&r1=171491&r2=171492&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Fri Jan  4 12:45:40 2013
@@ -233,6 +233,8 @@
   QualType ObjCConstantStringType;
   mutable RecordDecl *CFConstantStringTypeDecl;
   
+  mutable QualType ObjCSuperType;
+  
   QualType ObjCNSStringType;
 
   /// \brief The typedef declaration for the Objective-C "instancetype" type.
@@ -1115,7 +1117,11 @@
 
   /// \brief Return the C structure type used to represent constant CFStrings.
   QualType getCFConstantStringType() const;
-
+  
+  /// \brief Returns the C struct type for objc_super
+  QualType getObjCSuperType() const;
+  void setObjCSuperType(QualType ST) { ObjCSuperType = ST; }
+  
   /// Get the structure type used to representation CFStrings, or NULL
   /// if it hasn't yet been built.
   QualType getRawCFConstantStringType() const {

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=171492&r1=171491&r2=171492&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Fri Jan  4 12:45:40 2013
@@ -31,6 +31,7 @@
 //  F -> constant CFString
 //  G -> id
 //  H -> SEL
+//  M -> struct objc_super
 //  a -> __builtin_va_list
 //  A -> "reference" to __builtin_va_list
 //  V -> Vector, followed by the number of elements and the base type.
@@ -760,17 +761,16 @@
 LIBBUILTIN(strlcat, "zc*cC*z",    "f",     "string.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)
 // _Complex long double objc_msgSend_fp2ret(id self, SEL op, ...)
 LIBBUILTIN(objc_msgSend_fp2ret, "XLdGH.", "f", "objc/message.h", OBJC_LANG)
-// id objc_msgSend_stret (id, SEL, ...)
-LIBBUILTIN(objc_msgSend_stret, "GGH.", "f", "objc/message.h", OBJC_LANG)
+// void objc_msgSend_stret (id, SEL, ...)
+LIBBUILTIN(objc_msgSend_stret, "vGH.", "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)
+LIBBUILTIN(objc_msgSendSuper, "GM*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)
+LIBBUILTIN(objc_msgSendSuper_stret, "vM*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)

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=171492&r1=171491&r2=171492&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Jan  4 12:45:40 2013
@@ -633,7 +633,7 @@
     Comments(SM), CommentsLoaded(false),
     CommentCommandTraits(BumpAlloc),
     LastSDM(0, 0),
-    UniqueBlockByRefTypeID(0) 
+    UniqueBlockByRefTypeID(0)
 {
   if (size_reserve > 0) Types.reserve(size_reserve);
   TUDecl = TranslationUnitDecl::Create(*this);
@@ -889,6 +889,8 @@
                        SignedCharTy : BoolTy);
   
   ObjCConstantStringType = QualType();
+  
+  ObjCSuperType = QualType();
 
   // void * type
   VoidPtrTy = getPointerType(VoidTy);
@@ -4294,6 +4296,16 @@
   return getTagDeclType(CFConstantStringTypeDecl);
 }
 
+QualType ASTContext::getObjCSuperType() const {
+  if (ObjCSuperType.isNull()) {
+    RecordDecl *ObjCSuperTypeDecl  =
+      CreateRecordDecl(*this, TTK_Struct, TUDecl, &Idents.get("objc_super"));
+    TUDecl->addDecl(ObjCSuperTypeDecl);
+    ObjCSuperType = getTagDeclType(ObjCSuperTypeDecl);
+  }
+  return ObjCSuperType;
+}
+
 void ASTContext::setCFConstantStringType(QualType T) {
   const RecordType *Rec = T->getAs<RecordType>();
   assert(Rec && "Invalid CFConstantStringType");
@@ -7205,6 +7217,9 @@
   case 'H':
     Type = Context.getObjCSelType();
     break;
+  case 'M':
+    Type = Context.getObjCSuperType();
+    break;
   case 'a':
     Type = Context.getBuiltinVaListType();
     assert(!Type.isNull() && "builtin va list type not initialized!");

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=171492&r1=171491&r2=171492&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Jan  4 12:45:40 2013
@@ -1464,6 +1464,24 @@
   return S;
 }
 
+/// \brief Looks up the declaration of "struct objc_super" and
+/// saves it for later use in building builtin declaration of
+/// objc_msgSendSuper and objc_msgSendSuper_stret. If no such
+/// pre-existing declaration exists no action takes place.
+static void LookupPredefedObjCSuperType(Sema &ThisSema, Scope *S,
+                                        IdentifierInfo *II) {
+  if (!II->isStr("objc_msgSendSuper"))
+    return;
+  ASTContext &Context = ThisSema.Context;
+    
+  LookupResult Result(ThisSema, &Context.Idents.get("objc_super"),
+                      SourceLocation(), Sema::LookupTagName);
+  ThisSema.LookupName(Result, S);
+  if (Result.getResultKind() == LookupResult::Found)
+    if (const TagDecl *TD = Result.getAsSingle<TagDecl>())
+      Context.setObjCSuperType(Context.getTagDeclType(TD));
+}
+
 /// LazilyCreateBuiltin - The specified Builtin-ID was first used at
 /// file scope.  lazily create a decl for it. ForRedeclaration is true
 /// if we're creating this built-in in anticipation of redeclaring the
@@ -1471,6 +1489,8 @@
 NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid,
                                      Scope *S, bool ForRedeclaration,
                                      SourceLocation Loc) {
+  LookupPredefedObjCSuperType(*this, S, II);
+  
   Builtin::ID BID = (Builtin::ID)bid;
 
   ASTContext::GetBuiltinTypeError Error;

Modified: cfe/trunk/test/SemaObjC/builtin_objc_lib_functions.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/builtin_objc_lib_functions.m?rev=171492&r1=171491&r2=171492&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/builtin_objc_lib_functions.m (original)
+++ cfe/trunk/test/SemaObjC/builtin_objc_lib_functions.m Fri Jan  4 12:45:40 2013
@@ -14,7 +14,7 @@
     // 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 library function 'objc_msgSendSuper' with type 'id (void *, SEL, ...)'}} \
+  return objc_msgSendSuper(super, op); // expected-warning {{implicitly declaring library function 'objc_msgSendSuper' with type 'id (struct objc_super *, SEL, ...)'}} \
 					// expected-note {{please include the header <objc/message.h> or explicitly provide a declaration for 'objc_msgSendSuper'}}
 }
 

Modified: cfe/trunk/test/SemaObjC/builtin_objc_msgSend.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/builtin_objc_msgSend.m?rev=171492&r1=171491&r2=171492&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/builtin_objc_msgSend.m (original)
+++ cfe/trunk/test/SemaObjC/builtin_objc_msgSend.m Fri Jan  4 12:45:40 2013
@@ -2,3 +2,19 @@
 // expected-no-diagnostics
 // rdar://8632525
 extern id objc_msgSend(id self, SEL op, ...);
+
+// rdar://12489098
+struct objc_super {
+  id receiver;
+  Class super_class;
+};
+
+extern __attribute__((visibility("default"))) id objc_msgSendSuper(struct objc_super *super, SEL op, ...)
+    __attribute__((availability(macosx,introduced=10.0)));
+    
+extern __attribute__((visibility("default"))) void objc_msgSendSuper_stret(struct objc_super *super, SEL op, ...)
+    __attribute__((availability(macosx,introduced=10.0)));
+    
+extern __attribute__((visibility("default"))) void objc_msgSend_stret(id self, SEL op, ...)
+    __attribute__((availability(macosx,introduced=10.0)));
+





More information about the cfe-commits mailing list