]> granicus.if.org Git - clang/commitdiff
Protocol related tweaks
authorDaniel Dunbar <daniel@zuster.org>
Tue, 12 Aug 2008 05:08:18 +0000 (05:08 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 12 Aug 2008 05:08:18 +0000 (05:08 +0000)
 - Implement type conversion of ObjCQualifiedIdType
 - Wire @protocol(...) to GenerateProtocolRef in ScalarExprEmitter

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

lib/CodeGen/CGExprScalar.cpp
lib/CodeGen/CGObjCRuntime.h
lib/CodeGen/CodeGenTypes.cpp

index decf539f1c8a3084457944a29ad07b50d68403b1..294965498ec8ec0336167537870aa9a838206395 100644 (file)
@@ -14,6 +14,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/TargetInfo.h"
 #include "llvm/Constants.h"
@@ -135,6 +136,7 @@ public:
   }
   Value *VisitObjCMessageExpr(ObjCMessageExpr *E);
   Value *VisitObjCSelectorExpr(ObjCSelectorExpr *E);
+  Value *VisitObjCProtocolExpr(ObjCProtocolExpr *E);
   Value *VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { return EmitLoadOfLValue(E);}
   Value *VisitArraySubscriptExpr(ArraySubscriptExpr *E);
   Value *VisitShuffleVectorExpr(ShuffleVectorExpr *E);
@@ -506,6 +508,11 @@ Value *ScalarExprEmitter::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
   return Runtime->GetSelector(Builder, E->getSelector());
 }
 
+Value *ScalarExprEmitter::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
+  // FIXME: This should pass the Decl not the name.
+  return Runtime->GenerateProtocolRef(Builder, E->getProtocol()->getName());
+}
+
 Value *ScalarExprEmitter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
   // Emit subscript expressions in rvalue context's.  For most cases, this just
   // loads the lvalue formed by the subscript expr.  However, we have to be
index 5e8172b6651da85d3b82cc7f8e1dde76c5c48722..d4f7bb07cd097159b96f7c2ff74e7c4e081d37d1 100644 (file)
@@ -47,6 +47,10 @@ public:
   /// Generate an Objective-C message send operation
   virtual llvm::Value *GenerateMessageSend(BuilderType &Builder,
                                            const llvm::Type *ReturnTy,
+                                           // FIXME: This should be
+                                           // dropped, it is unused
+                                           // and generates a spurious
+                                           // load.
                                            llvm::Value *Sender,
                                            llvm::Value *Receiver,
                                            Selector Sel,
@@ -81,17 +85,25 @@ public:
              const llvm::SmallVectorImpl<Selector>  &ClassMethodSels,
              const llvm::SmallVectorImpl<llvm::Constant *>  &ClassMethodTypes,
              const llvm::SmallVectorImpl<std::string> &Protocols) =0;
-  /// Generate a reference to the named protocol.
-  virtual llvm::Value *GenerateProtocolRef(llvm::IRBuilder<true> &Builder,
-                                           const char *ProtocolName) = 0;
   virtual llvm::Value *GenerateMessageSendSuper(llvm::IRBuilder<true> &Builder,
                                                 const llvm::Type *ReturnTy,
+                                                // FIXME: This should
+                                                // be dropped, it is
+                                                // unused and
+                                                // generates a
+                                                // spurious load.
                                                 llvm::Value *Sender,
                                                 const char *SuperClassName,
                                                 llvm::Value *Receiver,
                                                 Selector Sel,
                                                 llvm::Value** ArgV,
                                                 unsigned ArgC) = 0;
+
+  /// Emit the code to return the named protocol as an object, as in a
+  /// @protocol expression.
+  virtual llvm::Value *GenerateProtocolRef(llvm::IRBuilder<true> &Builder,
+                                           const char *ProtocolName) = 0;
+
   /// Generate the named protocol.  Protocols contain method metadata but no 
   /// implementations. 
   virtual void GenerateProtocol(const char *ProtocolName,
index ab0829e81feff84a97b167dc410cd61d4f71015c..2d5bd12f928295280ddfd3317111090cce37957d 100644 (file)
@@ -306,6 +306,10 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
       ConvertTypeRecursive(QualType(cast<ASQualType>(Ty).getBaseType(), 0));
 
   case Type::ObjCInterface: {
+    // FIXME: This comment is broken. Either the code should check for
+    // the flag it is referring to or it should do the right thing in
+    // the presence of it.
+    
     // Warning: Use of this is strongly discouraged.  Late binding of instance
     // variables is supported on some runtimes and so using static binding can
     // break code when libraries are updated.  Only use this if you have
@@ -322,8 +326,8 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
     break;
 
   case Type::ObjCQualifiedId:
-    assert(0 && "FIXME: add missing functionality here");
-    break;
+    // Protocols don't influence the LLVM type.
+    return ConvertTypeRecursive(Context.getObjCIdType());
 
   case Type::Tagged: {
     const TagDecl *TD = cast<TagType>(Ty).getDecl();