[cfe-commits] r69050 - in /cfe/trunk/lib/CodeGen: CGCXX.cpp CGExprScalar.cpp CodeGenFunction.h
Anders Carlsson
andersca at mac.com
Tue Apr 14 09:58:56 PDT 2009
Author: andersca
Date: Tue Apr 14 11:58:56 2009
New Revision: 69050
URL: http://llvm.org/viewvc/llvm-project?rev=69050&view=rev
Log:
Support code generation of 'this' exprs
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=69050&r1=69049&r2=69050&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Tue Apr 14 11:58:56 2009
@@ -113,3 +113,14 @@
return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args),
Callee, Args, MD);
}
+
+
+llvm::Value *CodeGenFunction::LoadCXXThis() {
+ assert(isa<CXXMethodDecl>(CurFuncDecl) &&
+ "Must be in a C++ member function decl to load 'this'");
+ assert(cast<CXXMethodDecl>(CurFuncDecl)->isInstance() &&
+ "Must be in a C++ member function decl to load 'this'");
+
+ // FIXME: What if we're inside a block?
+ return Builder.CreateLoad(LocalDeclMap[CXXThisDecl], "this");
+}
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=69050&r1=69049&r2=69050&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Apr 14 11:58:56 2009
@@ -256,9 +256,14 @@
return Visit(E->getSubExpr());
}
Value *VisitUnaryOffsetOf(const UnaryOperator *E);
+
+ // C++
Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
return Visit(DAE->getExpr());
}
+ Value *VisitCXXThisExpr(CXXThisExpr *TE) {
+ return CGF.LoadCXXThis();
+ }
// Binary Operators.
Value *EmitMul(const BinOpInfo &Ops) {
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=69050&r1=69049&r2=69050&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Apr 14 11:58:56 2009
@@ -454,6 +454,10 @@
// of a variable length array type.
llvm::Value *GetVLASize(const VariableArrayType *);
+ /// LoadCXXThis - Load the value of 'this'. This function is only valid while
+ /// generating code for an C++ member function.
+ llvm::Value *LoadCXXThis();
+
//===--------------------------------------------------------------------===//
// Declaration Emission
//===--------------------------------------------------------------------===//
More information about the cfe-commits
mailing list