diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -1079,8 +1079,9 @@ void EmitImageInfo(); public: - CGObjCCommonMac(CodeGen::CodeGenModule &cgm) : - CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()) { } + CGObjCCommonMac(CodeGen::CodeGenModule &cgm) + : CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()), + Mangler(cgm.getContext().createMangleContext()) {} bool isNonFragileABI() const { return ObjCABI == 2; @@ -1121,6 +1122,7 @@ private: void fillRunSkipBlockVars(CodeGenModule &CGM, const CGBlockInfo &blockInfo); + std::unique_ptr Mangler; }; namespace { @@ -4003,9 +4005,8 @@ } else { SmallString<256> Name; llvm::raw_svector_ostream OS(Name); - const auto &MC = CGM.getContext().createMangleContext(); - MC->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true, - /*includeCategoryNamespace=*/true); + Mangler->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true, + /*includeCategoryNamespace=*/true); CodeGenTypes &Types = CGM.getTypes(); llvm::FunctionType *MethodTy = @@ -4059,9 +4060,8 @@ } else { SmallString<256> Name; llvm::raw_svector_ostream OS(Name); - const auto &MC = CGM.getContext().createMangleContext(); - MC->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true, - /*includeCategoryNamespace=*/false); + Mangler->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true, + /*includeCategoryNamespace=*/false); Fn = llvm::Function::Create(MethodTy, llvm::GlobalValue::ExternalLinkage, Name.str(), &CGM.getModule());