diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-05-07 18:56:13 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-05-07 18:56:13 +0000 |
commit | bbb5224710ded82014b0be9ba8651da312613d02 (patch) | |
tree | c1c2c1023d6dc60966fba38c3ba8b51db3707d39 | |
parent | ab699798f72225f1735b60b35a7db7c8022c50c6 (diff) |
Fixes a Code gen crash trying to use a dot-syntax for
a property of a c++ class object (radar 7957369).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103279 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGExprCXX.cpp | 10 | ||||
-rw-r--r-- | test/CodeGenObjCXX/property-objects.mm | 8 |
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index b57cdc9334..f35fe733d1 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -273,8 +273,14 @@ CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, const llvm::Type *Ty = CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD), FPT->isVariadic()); - - llvm::Value *This = EmitLValue(E->getArg(0)).getAddress(); + LValue LV = EmitLValue(E->getArg(0)); + llvm::Value *This; + if (LV.isPropertyRef()) { + RValue RV = EmitLoadOfPropertyRefLValue(LV, E->getArg(0)->getType()); + This = RV.isScalar() ? RV.getScalarVal() : RV.getAggregateAddr(); + } + else + This = LV.getAddress(); llvm::Value *Callee; if (MD->isVirtual() && !canDevirtualizeMemberFunctionCalls(E->getArg(0))) diff --git a/test/CodeGenObjCXX/property-objects.mm b/test/CodeGenObjCXX/property-objects.mm index 34c22e7faa..cd327c22ca 100644 --- a/test/CodeGenObjCXX/property-objects.mm +++ b/test/CodeGenObjCXX/property-objects.mm @@ -18,3 +18,11 @@ public: @implementation I @synthesize position; @end + +int main() { + I *i; + S s1; + i.position = s1; + return 0; +} + |