DMD Issue 4523 - [tdpl] .remove method for Associative Arrays returns void in all cases

This commit is contained in:
Alexey Prokhin
2012-02-13 14:05:28 +04:00
parent 6fea4b65a2
commit fa361ed598
4 changed files with 15 additions and 9 deletions

View File

@@ -191,7 +191,7 @@ DValue* DtoAAIn(Loc& loc, Type* type, DValue* aa, DValue* key)
/////////////////////////////////////////////////////////////////////////////////////
void DtoAARemove(Loc& loc, DValue* aa, DValue* key)
DValue *DtoAARemove(Loc& loc, DValue* aa, DValue* key)
{
// D1:
// call:
@@ -199,7 +199,7 @@ void DtoAARemove(Loc& loc, DValue* aa, DValue* key)
// D2:
// call:
// extern(C) void _aaDelX(AA aa, TypeInfo keyti, void* pkey)
// extern(C) bool _aaDelX(AA aa, TypeInfo keyti, void* pkey)
// first get the runtime function
#if DMDV2
@@ -240,7 +240,13 @@ void DtoAARemove(Loc& loc, DValue* aa, DValue* key)
args.push_back(pkey);
// call runtime
gIR->CreateCallOrInvoke(func, args);
LLCallSite call = gIR->CreateCallOrInvoke(func, args);
#if DMDV2
return new DImValue(Type::tbool, call.getInstruction());
#else
return NULL;
#endif
}
/////////////////////////////////////////////////////////////////////////////////////

View File

@@ -3,7 +3,7 @@
DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue);
DValue* DtoAAIn(Loc& loc, Type* type, DValue* aa, DValue* key);
void DtoAARemove(Loc& loc, DValue* aa, DValue* key);
DValue* DtoAARemove(Loc& loc, DValue* aa, DValue* key);
LLValue* DtoAAEquals(Loc& loc, TOK op, DValue* l, DValue* r);
#endif // LDC_GEN_AA_H

View File

@@ -874,18 +874,20 @@ static void LLVM_D_BuildRuntimeModule()
// D1:
// void _aaDel(AA aa, TypeInfo keyti, void* pkey)
// D2:
// void _aaDelX(AA aa, TypeInfo keyti, void* pkey)
// bool _aaDelX(AA aa, TypeInfo keyti, void* pkey)
{
#if DMDV2
llvm::StringRef fname("_aaDelX");
LLType *retType = boolTy;
#else
llvm::StringRef fname("_aaDel");
LLType *retType = voidTy;
#endif
std::vector<LLType*> types;
types.push_back(aaTy);
types.push_back(typeInfoTy);
types.push_back(voidPtrTy);
LLFunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
LLFunctionType* fty = llvm::FunctionType::get(retType, types, false);
llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)
->setAttributes(Attr_1_3_NoCapture);
}

View File

@@ -2988,9 +2988,7 @@ DValue* RemoveExp::toElem(IRState* p)
DValue* aa = e1->toElem(p);
DValue* key = e2->toElem(p);
DtoAARemove(loc, aa, key);
return NULL; // does not produce anything useful
return DtoAARemove(loc, aa, key);
}
//////////////////////////////////////////////////////////////////////////////////////////