[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 8 00:47:39 PST 2025


================
@@ -197,10 +198,9 @@ class Address {
 
   /// Return the type of the pointer value.
   llvm::PointerType *getType() const {
-    return llvm::PointerType::get(
-        ElementType,
-        llvm::cast<llvm::PointerType>(Pointer.getPointer()->getType())
-            ->getAddressSpace());
+    auto AS = llvm::cast<llvm::PointerType>(Pointer.getPointer()->getType())
+                  ->getAddressSpace();
+    return llvm::PointerType::get(ElementType->getContext(), AS);
----------------
nikic wrote:

Can't you directly return `Pointer.getPointer()->getType()`? No need to reconstruct it via addrspace.

https://github.com/llvm/llvm-project/pull/124771


More information about the cfe-commits mailing list