[llvm] [IR] Avoid call to deprecated PointerType::getUnqual (NFC)\ (PR #134609)

Mats Jun Larsen via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 7 04:02:08 PDT 2025


https://github.com/junlarsen created https://github.com/llvm/llvm-project/pull/134609

Should keep MSVC quiet as noticed by @rksimon in #134517.

Assertions have been copied over from PointerType::get in order to not silently change invariants with this call.


>From 1658f60e50bcc9587fd165b82b043ae1927d2822 Mon Sep 17 00:00:00 2001
From: Mats Jun Larsen <mats at jun.codes>
Date: Mon, 7 Apr 2025 19:56:17 +0900
Subject: [PATCH] [IR] Avoid call to deprecated PointerType::getUnqual (NFC)

Should keep MSVC quiet as noticed by @rksimon in #134517.
---
 llvm/include/llvm/IR/DerivedTypes.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h
index ba5c41ff033f5..d0dffa9de616a 100644
--- a/llvm/include/llvm/IR/DerivedTypes.h
+++ b/llvm/include/llvm/IR/DerivedTypes.h
@@ -697,7 +697,10 @@ class PointerType : public Type {
   [[deprecated("PointerType::getUnqual with pointee type is pending removal. "
                "Use Context overload.")]]
   static PointerType *getUnqual(Type *ElementType) {
-    return PointerType::get(ElementType, 0);
+    assert(ElementType && "Can't get a pointer to <null> type!");
+    assert(isValidElementType(ElementType) &&
+           "Invalid type for pointer element!");
+    return PointerType::getUnqual(ElementType->getContext());
   }
 
   /// This constructs an opaque pointer to an object in the



More information about the llvm-commits mailing list