diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2009-10-21 18:38:00 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-10-21 18:38:00 +0000 |
| commit | 4ebdff5e1cfd100a1b257b22cc33158184fa3d42 (patch) | |
| tree | 1cd908c80ce94fe64668b42cea774268c71f5d5e /clang/lib/CodeGen | |
| parent | 945fec05dde3451f72886fbf29c4505833581bc2 (diff) | |
| download | bcm5719-llvm-4ebdff5e1cfd100a1b257b22cc33158184fa3d42.tar.gz bcm5719-llvm-4ebdff5e1cfd100a1b257b22cc33158184fa3d42.zip | |
Code gen for pointer-to-datamember - WIP.
llvm-svn: 84771
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 21 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index d3d1c61fe99..2266b25c682 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -866,6 +866,9 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { llvm::Value *V = LocalDeclMap[IPD]; assert(V && "BlockVarDecl not entered in LocalDeclMap?"); return LValue::MakeAddr(V, MakeQualifiers(E->getType())); + } else if (const QualifiedDeclRefExpr *QDRExpr = + dyn_cast<QualifiedDeclRefExpr>(E)) { + return EmitPointerToDataMemberLValue(QDRExpr); } assert(0 && "Unimp declref"); //an invalid LValue, but the assert will @@ -1513,6 +1516,24 @@ LValue CodeGenFunction::EmitStmtExprLValue(const StmtExpr *E) { } +LValue CodeGenFunction::EmitPointerToDataMemberLValue( + const QualifiedDeclRefExpr *E) { + const FieldDecl *Field = cast<FieldDecl>(E->getDecl()); + const NestedNameSpecifier *NNSpec = E->getQualifier(); + const Type *NNSpecType = NNSpec->getAsType(); + QualType NNSpecTy = getContext().getCanonicalType(QualType(NNSpecType, 0)); + NNSpecTy = getContext().getPointerType(NNSpecTy); + llvm::Value *V = llvm::Constant::getNullValue(ConvertType(NNSpecTy)); + LValue MemExpLV = EmitLValueForField(V, const_cast<FieldDecl*>(Field), + /*isUnion*/false, /*Qualifiers*/0); + const llvm::Type* ResultType = ConvertType( + getContext().getPointerDiffType()); + V = Builder.CreatePtrToInt(MemExpLV.getAddress(), ResultType, + "datamember"); + LValue LV = LValue::MakeAddr(V, MakeQualifiers(E->getType())); + return LV; +} + RValue CodeGenFunction::EmitCall(llvm::Value *Callee, QualType CalleeType, CallExpr::const_arg_iterator ArgBeg, CallExpr::const_arg_iterator ArgEnd, diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 00b07e4b682..3e65e47024b 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -819,6 +819,7 @@ public: LValue EmitConditionalOperatorLValue(const ConditionalOperator *E); LValue EmitCastLValue(const CastExpr *E); LValue EmitNullInitializationLValue(const CXXZeroInitValueExpr *E); + LValue EmitPointerToDataMemberLValue(const QualifiedDeclRefExpr *E); llvm::Value *EmitIvarOffset(const ObjCInterfaceDecl *Interface, const ObjCIvarDecl *Ivar); |

