From fa361ed598672e4083468c620b63195db97de146 Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Mon, 13 Feb 2012 14:05:28 +0400 Subject: [PATCH] DMD Issue 4523 - [tdpl] .remove method for Associative Arrays returns void in all cases --- gen/aa.cpp | 12 +++++++++--- gen/aa.h | 2 +- gen/runtime.cpp | 6 ++++-- gen/toir.cpp | 4 +--- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/gen/aa.cpp b/gen/aa.cpp index 75720f75..1816f764 100644 --- a/gen/aa.cpp +++ b/gen/aa.cpp @@ -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 } ///////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/aa.h b/gen/aa.h index 7775ed6e..d5e72eb5 100644 --- a/gen/aa.h +++ b/gen/aa.h @@ -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 diff --git a/gen/runtime.cpp b/gen/runtime.cpp index 82a88375..5763cf1e 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -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 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); } diff --git a/gen/toir.cpp b/gen/toir.cpp index f327616a..fd65f5f8 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -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); } //////////////////////////////////////////////////////////////////////////////////////////