diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp --- a/clang/lib/AST/Mangle.cpp +++ b/clang/lib/AST/Mangle.cpp @@ -36,11 +36,18 @@ StringRef Outer, const BlockDecl *BD, raw_ostream &Out) { - unsigned discriminator = Context.getBlockId(BD, true); - if (discriminator == 0) - Out << "__" << Outer << "_block_invoke"; - else - Out << "__" << Outer << "_block_invoke_" << discriminator+1; + SmallString<256> ParamBuff; + llvm::raw_svector_ostream ParamTypes(ParamBuff); + for (ParmVarDecl *PVD : BD->parameters()) { + Context.mangleTypeName(PVD->getType(), ParamTypes); + } + + llvm::MD5 Hash; + llvm::MD5::MD5Result Result; + Hash.update(ParamTypes.str()); + Hash.final(Result); + + Out << "__" << Outer << "_block_invoke_" << *(unsigned short*)&Result; } void MangleContext::anchor() { }