#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"
}
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);
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
/// 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,
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,
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
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();