[PATCH] D88497: [objc] Fix memory leak in CGObjCMac.cpp

2020-09-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Committed (with substantial changes) as 
984744a1314ce165378e7945bc45995302a8cb80 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88497/new/

https://reviews.llvm.org/D88497

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88497: [objc] Fix memory leak in CGObjCMac.cpp

2020-09-29 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

Thanks for updating the comment in dsymutil!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88497/new/

https://reviews.llvm.org/D88497

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88497: [objc] Fix memory leak in CGObjCMac.cpp

2020-09-29 Thread Ellis Hoag via Phabricator via cfe-commits
ellis updated this revision to Diff 295055.
ellis added a subscriber: vsapsai.
ellis added a comment.
Herald added a reviewer: JDevlieghere.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Fix a comment to reference the correct method.

Thanks to @vsapsai for pointing this out.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88497/new/

https://reviews.llvm.org/D88497

Files:
  clang/lib/CodeGen/CGObjCMac.cpp
  llvm/tools/dsymutil/SymbolMap.cpp


Index: llvm/tools/dsymutil/SymbolMap.cpp
===
--- llvm/tools/dsymutil/SymbolMap.cpp
+++ llvm/tools/dsymutil/SymbolMap.cpp
@@ -47,7 +47,7 @@
 return Translation;
 
   // Objective-C symbols for the MachO symbol table start with a \1. Please see
-  // `CGObjCCommonMac::GetNameForMethod` in clang.
+  // `MangleContext::mangleObjCMethodName` in clang.
   if (Translation[0] == 1)
 return StringRef(Translation).drop_front();
 
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ 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());


Index: llvm/tools/dsymutil/SymbolMap.cpp
===
--- llvm/tools/dsymutil/SymbolMap.cpp
+++ llvm/tools/dsymutil/SymbolMap.cpp
@@ -47,7 +47,7 @@
 return Translation;
 
   // Objective-C symbols for the MachO symbol table start with a \1. Please see
-  // `CGObjCCommonMac::GetNameForMethod` in clang.
+  // `MangleContext::mangleObjCMethodName` in clang.
   if (Translation[0] == 1)
 return StringRef(Translation).drop_front();
 
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ 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

[PATCH] D88497: [objc] Fix memory leak in CGObjCMac.cpp

2020-09-29 Thread Ellis Hoag via Phabricator via cfe-commits
ellis added a comment.

Yes please commit for me :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88497/new/

https://reviews.llvm.org/D88497

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88497: [objc] Fix memory leak in CGObjCMac.cpp

2020-09-29 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Oh, oops, I should've caught this in review.  I assume you still need a commit?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88497/new/

https://reviews.llvm.org/D88497

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88497: [objc] Fix memory leak in CGObjCMac.cpp

2020-09-29 Thread Ellis Hoag via Phabricator via cfe-commits
ellis created this revision.
ellis added a reviewer: rjmccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
ellis requested review of this revision.

A memory leak was introduced in https://reviews.llvm.org/D88329

CGObjCMac.cpp was leaking a MangleContext everytime it mangled
an ObjC method. We now have an instance variable that allocates
and deallocates the context.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88497

Files:
  clang/lib/CodeGen/CGObjCMac.cpp


Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ 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());


Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ 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());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits