[llvm] [IR] Avoid call to deprecated PointerType::getUnqual (NFC) (PR #134609)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 7 04:02:43 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Mats Jun Larsen (junlarsen)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/134609.diff
1 Files Affected:
- (modified) llvm/include/llvm/IR/DerivedTypes.h (+4-1)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/134609
More information about the llvm-commits
mailing list