diff --git a/IDEHelper/Compiler/BfMangler.cpp b/IDEHelper/Compiler/BfMangler.cpp index 6954585f..e9f7dd66 100644 --- a/IDEHelper/Compiler/BfMangler.cpp +++ b/IDEHelper/Compiler/BfMangler.cpp @@ -914,13 +914,16 @@ String BfGNUMangler::Mangle(BfMethodInstance* methodInst) prefixLen = true; } - if (methodDef->mCheckedKind == BfCheckedKind_Checked) - name += "`CHK"; - else if (methodDef->mCheckedKind == BfCheckedKind_Unchecked) - name += "`UCHK"; + if (!mangleContext.mCPPMangle) + { + if (methodDef->mCheckedKind == BfCheckedKind_Checked) + name += "`CHK"; + else if (methodDef->mCheckedKind == BfCheckedKind_Unchecked) + name += "`UCHK"; - if (methodDef->mHasComptime) - name += "`COMPTIME"; + if (methodDef->mHasComptime) + name += "`COMPTIME"; + } if (((methodInst->GetOwner()->mTypeDef->IsGlobalsContainer()) && ((methodDef->mMethodType == BfMethodType_Ctor) || (methodDef->mMethodType == BfMethodType_Dtor) || (methodDef->mName == BF_METHODNAME_MARKMEMBERS_STATIC))) || @@ -1021,12 +1024,22 @@ String BfGNUMangler::Mangle(BfMethodInstance* methodInst) HandleParamCustomAttributes(paramDecl->mAttributes, false, isConst); } - auto paramKind = methodInst->GetParamKind(paramIdx); - if (paramKind == BfParamKind_Params) - name += "U6params"; - else if (paramKind == BfParamKind_DelegateParam) - name += "U5param"; - Mangle(mangleContext, name, paramType, NULL, isConst); + if (!mangleContext.mCPPMangle) + { + auto paramKind = methodInst->GetParamKind(paramIdx); + if (paramKind == BfParamKind_Params) + name += "U6params"; + else if (paramKind == BfParamKind_DelegateParam) + name += "U5param"; + } + + if ((paramType->IsVoid()) && (methodInst->GetParamCount() == 1)) + { + // Avoid collision between 'Method()' and 'Method(void)' + name += "U4void"; + } + else + Mangle(mangleContext, name, paramType, NULL, isConst); } if ((methodInst->GetParamCount() == 0) && (!doExplicitThis)) name += 'v'; @@ -2232,8 +2245,10 @@ void BfMSMangler::Mangle(StringImpl& name, bool is64Bit, BfMethodInstance* metho { Mangle(mangleContext, name, typeInst->GetUnderlyingType(), true); } - for (auto& param : methodInst->mParams) + + for (int paramIdx = 0; paramIdx < methodInst->mParams.mSize; paramIdx++) { + auto& param = methodInst->mParams[paramIdx]; bool isConst = false; if ((param.mParamDefIdx >= 0) && (methodDeclaration != NULL) && (param.mParamDefIdx < methodDeclaration->mParams.mSize)) { @@ -2241,6 +2256,14 @@ void BfMSMangler::Mangle(StringImpl& name, bool is64Bit, BfMethodInstance* metho HandleParamCustomAttributes(paramDecl->mAttributes, false, isConst); } + if (!mangleContext.mCPPMangle) + { + auto paramKind = methodInst->GetParamKind(paramIdx); + if (paramKind == BfParamKind_Params) + name += "Tparams@@"; + else if (paramKind == BfParamKind_DelegateParam) + name += "Tparam@@"; + } Mangle(mangleContext, name, param.mResolvedType, true, isConst); } name += '@'; diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 39548cba..7b7391fc 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -23374,9 +23374,8 @@ void BfModule::SetupIRFunction(BfMethodInstance* methodInstance, StringImpl& man mCurMethodInstance->mMangleWithIdx = true; mangledName.Clear(); BfMangler::Mangle(mangledName, mCompiler->GetMangleKind(), mCurMethodInstance); - prevFunc = mBfIRBuilder->GetFunction(mangledName); - BfLogSysM("Function collision forced mangleWithIdx for %p: %d\n", methodInstance, prevFunc.mId); + BfLogSysM("Function collision forced mangleWithIdx for %p: %d GenericArgs: %d Unspecialized: %d\n", methodInstance, prevFunc.mId, methodInstance->GetNumGenericArguments(), methodInstance->mIsUnspecialized); } else {