diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-09-03 00:27:26 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-09-03 00:27:26 +0000 |
commit | e66f4e3e3ae9d7d11b0c302211066fad69228aba (patch) | |
tree | ebf694ed165de059748450009d609ec820a3be27 /lib | |
parent | 7e8cc57bad2b670b0a3b48fa3d84dce79b5c7288 (diff) |
Fix ObjCPropertRefExpr to be able to encode all the information for
uses which refer to methods not properties.
- Not yet wired in Sema.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55681 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/StmtDumper.cpp | 13 | ||||
-rw-r--r-- | lib/AST/StmtSerialization.cpp | 17 | ||||
-rw-r--r-- | lib/CodeGen/CGObjC.cpp | 26 | ||||
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 5 |
4 files changed, 43 insertions, 18 deletions
diff --git a/lib/AST/StmtDumper.cpp b/lib/AST/StmtDumper.cpp index af19b61cd6..a0af132bc4 100644 --- a/lib/AST/StmtDumper.cpp +++ b/lib/AST/StmtDumper.cpp @@ -453,12 +453,15 @@ void StmtDumper::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) { void StmtDumper::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) { DumpExpr(Node); - - if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(Node->getDecl())) { - fprintf(F, " MethodDecl=\"%s\"", MD->getSelector().getName().c_str()); + + if (Node->getKind() == ObjCPropertyRefExpr::MethodRef) { + ObjCMethodDecl *Getter = Node->getGetterMethod(); + ObjCMethodDecl *Setter = Node->getSetterMethod(); + fprintf(F, " Kind=MethodRef Getter=\"%s\" Setter=\"%s\"", + Getter->getSelector().getName().c_str(), + Setter ? Setter->getSelector().getName().c_str() : "(null)"); } else { - ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(Node->getDecl()); - fprintf(F, " PropertyDecl=\"%s\"", PD->getName()); + fprintf(F, " Kind=PropertyRef Property=\"%s\"", Node->getProperty()->getName()); } } diff --git a/lib/AST/StmtSerialization.cpp b/lib/AST/StmtSerialization.cpp index 1c61b66512..23879ee63b 100644 --- a/lib/AST/StmtSerialization.cpp +++ b/lib/AST/StmtSerialization.cpp @@ -998,7 +998,14 @@ ObjCIvarRefExpr* ObjCIvarRefExpr::CreateImpl(Deserializer& D, ASTContext& C) { void ObjCPropertyRefExpr::EmitImpl(Serializer& S) const { S.Emit(Loc); S.Emit(getType()); - S.EmitPtr(getDecl()); + unsigned Kind = getKind(); + S.Emit(Kind); + if (Kind == PropertyRef) { + S.EmitPtr(getProperty()); + } else { + S.EmitPtr(getGetterMethod()); + S.EmitPtr(getSetterMethod()); + } } ObjCPropertyRefExpr* ObjCPropertyRefExpr::CreateImpl(Deserializer& D, @@ -1006,7 +1013,13 @@ ObjCPropertyRefExpr* ObjCPropertyRefExpr::CreateImpl(Deserializer& D, SourceLocation Loc = SourceLocation::ReadVal(D); QualType T = QualType::ReadVal(D); ObjCPropertyRefExpr* dr = new ObjCPropertyRefExpr(NULL,T,Loc,0); - D.ReadPtr(dr->D,false); + unsigned Kind = D.ReadInt(); + if (Kind == PropertyRef) { + D.ReadPtr(dr->Referent.AsProperty,false); + } else { + D.ReadPtr(dr->Referent.AsMethod.Setter,false); + D.ReadPtr(dr->Referent.AsMethod.Getter,false); + } return dr; } diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index 5376d0f3c7..af79b66106 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -16,6 +16,7 @@ #include "CodeGenModule.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclObjC.h" +#include "clang/Basic/Diagnostic.h" #include "llvm/ADT/STLExtras.h" using namespace clang; @@ -231,10 +232,10 @@ llvm::Value *CodeGenFunction::LoadObjCSelf(void) { RValue CodeGenFunction::EmitObjCPropertyGet(const ObjCPropertyRefExpr *E) { // Determine getter selector. Selector S; - if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(E->getDecl())) { - S = MD->getSelector(); + if (E->getKind() == ObjCPropertyRefExpr::MethodRef) { + S = E->getGetterMethod()->getSelector(); } else { - S = cast<ObjCPropertyDecl>(E->getDecl())->getGetterName(); + S = E->getProperty()->getGetterName(); } return CGM.getObjCRuntime(). @@ -246,12 +247,21 @@ RValue CodeGenFunction::EmitObjCPropertyGet(const ObjCPropertyRefExpr *E) { void CodeGenFunction::EmitObjCPropertySet(const ObjCPropertyRefExpr *E, RValue Src) { Selector S; - if (const ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(E->getDecl())) { - S = PD->getSetterName(); + if (E->getKind() == ObjCPropertyRefExpr::MethodRef) { + ObjCMethodDecl *Setter = E->getSetterMethod(); + + if (Setter) { + S = Setter->getSelector(); + } else { + // FIXME: This should be diagnosed by sema. + SourceRange Range = E->getSourceRange(); + CGM.getDiags().Report(getContext().getFullLoc(E->getLocStart()), + diag::err_typecheck_assign_const, 0, 0, + &Range, 1); + return; + } } else { - // FIXME: How can we have a method decl here? - ErrorUnsupported(E, "Objective-C property setter call"); - return; + S = E->getProperty()->getSetterName(); } CallArgList Args; diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 798c9d3c4b..d1a1651277 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -499,9 +499,8 @@ CodeGen::RValue CGObjCMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF, ActualArgs.insert(ActualArgs.end(), CallArgs.begin(), CallArgs.end()); // FIXME: This is a hack, we are implicitly coordinating with - // EmitCallExprExt, which will move the return type to the first - // parameter and set the structure return flag. See - // getMessageSendFn(). + // EmitCall, which will move the return type to the first parameter + // and set the structure return flag. See getMessageSendFn(). const llvm::Type *ReturnTy = CGM.getTypes().ConvertType(ResultType); return CGF.EmitCall(ObjCTypes.getMessageSendFn(IsSuper, ReturnTy), |