[PATCH] D141083: [NFC][IR] Avoid string leak with target extension types.

Joshua Cranmer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 5 13:55:34 PST 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG45d9079f7c32: [NFC][IR] Avoid string leak with target extension types. (authored by jcranmer-intel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141083

Files:
  llvm/include/llvm/IR/DerivedTypes.h
  llvm/lib/IR/Type.cpp


Index: llvm/lib/IR/Type.cpp
===================================================================
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -793,7 +793,7 @@
 
 TargetExtType::TargetExtType(LLVMContext &C, StringRef Name,
                              ArrayRef<Type *> Types, ArrayRef<unsigned> Ints)
-    : Type(C, TargetExtTyID), Name(Name) {
+    : Type(C, TargetExtTyID), Name(C.pImpl->Saver.save(Name)) {
   NumContainedTys = Types.size();
 
   // Parameter storage immediately follows the class in allocation.
Index: llvm/include/llvm/IR/DerivedTypes.h
===================================================================
--- llvm/include/llvm/IR/DerivedTypes.h
+++ llvm/include/llvm/IR/DerivedTypes.h
@@ -740,7 +740,8 @@
   TargetExtType(LLVMContext &C, StringRef Name, ArrayRef<Type *> Types,
                 ArrayRef<unsigned> Ints);
 
-  std::string Name;
+  // These strings are ultimately owned by the context.
+  StringRef Name;
   unsigned *IntParams;
 
 public:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141083.486673.patch
Type: text/x-patch
Size: 985 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230105/deb37ab3/attachment.bin>


More information about the llvm-commits mailing list