[cfe-commits] r54666 - in /cfe/trunk/lib/CodeGen: CGExprScalar.cpp CGObjCRuntime.h CodeGenTypes.cpp
Daniel Dunbar
daniel at zuster.org
Mon Aug 11 22:08:22 PDT 2008
Author: ddunbar
Date: Tue Aug 12 00:08:18 2008
New Revision: 54666
URL: http://llvm.org/viewvc/llvm-project?rev=54666&view=rev
Log:
Protocol related tweaks
- Implement type conversion of ObjCQualifiedIdType
- Wire @protocol(...) to GenerateProtocolRef in ScalarExprEmitter
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGObjCRuntime.h
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=54666&r1=54665&r2=54666&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Aug 12 00:08:18 2008
@@ -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 @@
}
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 @@
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
Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.h?rev=54666&r1=54665&r2=54666&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.h Tue Aug 12 00:08:18 2008
@@ -47,6 +47,10 @@
/// 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 @@
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,
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=54666&r1=54665&r2=54666&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Tue Aug 12 00:08:18 2008
@@ -306,6 +306,10 @@
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 @@
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();
More information about the cfe-commits
mailing list