diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-04 04:07:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-04 04:07:35 +0000 |
commit | c8aa5f1f264fb230c38182adab944232bb160c2b (patch) | |
tree | a7ab47baf8db212c4cb252e010d502e097930b86 /lib/CodeGen/CGExpr.cpp | |
parent | 1330b0e6e4a6ad2d586c4a45d6cece5611829a16 (diff) |
Codegen assignment to self correctly, patch by David Chisnall!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49201 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 66aeea3540..c80b6a7a8b 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -386,7 +386,13 @@ LValue CodeGenFunction::EmitStringLiteralLValue(const StringLiteral *E) { } LValue CodeGenFunction::EmitPreDefinedLValue(const PreDefinedExpr *E) { - std::string FunctionName(CurFuncDecl->getName()); + std::string FunctionName; + if(const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurFuncDecl)) { + FunctionName = FD->getName(); + } + else { + assert(0 && "Attempting to load predefined constant for invalid decl type"); + } std::string GlobalVarName; switch (E->getIdentType()) { @@ -404,7 +410,7 @@ LValue CodeGenFunction::EmitPreDefinedLValue(const PreDefinedExpr *E) { break; } - GlobalVarName += CurFuncDecl->getName(); + GlobalVarName += FunctionName; // FIXME: Can cache/reuse these within the module. llvm::Constant *C=llvm::ConstantArray::get(FunctionName); @@ -581,8 +587,10 @@ LValue CodeGenFunction::EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E) { // Get object pointer and coerce object pointer to correct type. llvm::Value *Object = EmitLValue(E->getBase()).getAddress(); + Object = Builder.CreateLoad(Object, E->getDecl()->getName()); if (Object->getType() != ObjectType) Object = Builder.CreateBitCast(Object, ObjectType); + // Return a pointer to the right element. return LValue::MakeAddr(Builder.CreateStructGEP(Object, Index, |