Mercurial > projects > ldc
changeset 1222:b6370749ec8d
Use 'undef' instead of null for unneeded contexts.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Fri, 17 Apr 2009 03:47:56 +0200 |
parents | f41ff8ccc249 |
children | 5f340a6dc749 |
files | gen/nested.cpp |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/nested.cpp Fri Apr 17 01:14:35 2009 +0200 +++ b/gen/nested.cpp Fri Apr 17 03:47:56 2009 +0200 @@ -228,19 +228,25 @@ { ClassDeclaration* cd = irfunc->decl->isMember2()->isClassDeclaration(); if (!cd || !cd->vthis) - return getNullPtr(getVoidPtrType()); + return llvm::UndefValue::get(getVoidPtrType()); val = DtoLoad(irfunc->thisArg); val = DtoLoad(DtoGEPi(val, 0,cd->vthis->ir.irField->index, ".vthis")); } else { - return getNullPtr(getVoidPtrType()); + return llvm::UndefValue::get(getVoidPtrType()); } if (nestedCtx == NCHybrid) { // If sym is a nested function, and it's parent context is different than the // one we got, adjust it. if (FuncDeclaration* fd = getParentFunc(sym->isFuncDeclaration(), true)) { + // if this is for a function that doesn't access variables from + // enclosing scopes, it doesn't matter what we pass. + // Tell LLVM about it by passing an 'undef'. + if (fd->ir.irFunc->depth == 0) + return llvm::UndefValue::get(getVoidPtrType()); + Logger::println("For nested function, parent is %s", fd->toChars()); FuncDeclaration* ctxfd = irfunc->decl; Logger::println("Current function is %s", ctxfd->toChars());