[llvm] [IR] Deprecate PointerType::get/getUnqual pointee type overload (PR #134517)

Mats Jun Larsen via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 6 03:50:58 PDT 2025


https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/134517

>From 58d92f58cfb2b91e1a0bfb380f9394b853334382 Mon Sep 17 00:00:00 2001
From: Mats Jun Larsen <mats at jun.codes>
Date: Mon, 31 Mar 2025 23:54:53 +0200
Subject: [PATCH 1/2] [IR] Deprecate PointerType::get/getUnqual pointee type
 overload

Deprecates the methods and schedules them for removal in the future as
the overloads taking LLVMContext are preferred, as the pointee type
has no meaning in opaque pointers.

Part of #123569
---
 llvm/include/llvm/IR/DerivedTypes.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h
index 60606d34c32c3..cc6230287bfe4 100644
--- a/llvm/include/llvm/IR/DerivedTypes.h
+++ b/llvm/include/llvm/IR/DerivedTypes.h
@@ -685,6 +685,9 @@ class PointerType : public Type {
 
   /// This constructs a pointer to an object of the specified type in a numbered
   /// address space.
+  LLVM_DEPRECATED("PointerType::get with pointee type is pending removal. Use "
+                  "Context overload.",
+                  "PointerType::get(LLVMContext, AS)")
   static PointerType *get(Type *ElementType, unsigned AddressSpace);
   /// This constructs an opaque pointer to an object in a numbered address
   /// space.
@@ -692,6 +695,9 @@ class PointerType : public Type {
 
   /// This constructs a pointer to an object of the specified type in the
   /// default address space (address space zero).
+  LLVM_DEPRECATED("PointerType::getUnqual with pointee type is pending "
+                  "removal. Use Context overload.",
+                  "PointerType::getUnqual(LLVMCOntext)")
   static PointerType *getUnqual(Type *ElementType) {
     return PointerType::get(ElementType, 0);
   }

>From b3c03d6bdad9f82834984f6aff0bca9c19af8afb Mon Sep 17 00:00:00 2001
From: Mats Jun Larsen <mats at jun.codes>
Date: Sun, 6 Apr 2025 19:50:28 +0900
Subject: [PATCH 2/2] Use [[deprecated]] attribute instead

---
 llvm/include/llvm/IR/DerivedTypes.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h
index cc6230287bfe4..ba5c41ff033f5 100644
--- a/llvm/include/llvm/IR/DerivedTypes.h
+++ b/llvm/include/llvm/IR/DerivedTypes.h
@@ -685,9 +685,8 @@ class PointerType : public Type {
 
   /// This constructs a pointer to an object of the specified type in a numbered
   /// address space.
-  LLVM_DEPRECATED("PointerType::get with pointee type is pending removal. Use "
-                  "Context overload.",
-                  "PointerType::get(LLVMContext, AS)")
+  [[deprecated("PointerType::get with pointee type is pending removal. Use "
+               "Context overload.")]]
   static PointerType *get(Type *ElementType, unsigned AddressSpace);
   /// This constructs an opaque pointer to an object in a numbered address
   /// space.
@@ -695,9 +694,8 @@ class PointerType : public Type {
 
   /// This constructs a pointer to an object of the specified type in the
   /// default address space (address space zero).
-  LLVM_DEPRECATED("PointerType::getUnqual with pointee type is pending "
-                  "removal. Use Context overload.",
-                  "PointerType::getUnqual(LLVMCOntext)")
+  [[deprecated("PointerType::getUnqual with pointee type is pending removal. "
+               "Use Context overload.")]]
   static PointerType *getUnqual(Type *ElementType) {
     return PointerType::get(ElementType, 0);
   }



More information about the llvm-commits mailing list