Skip to content

Commit

Permalink
[OpaquePtrs] Deprecate PointerType::getElementType()
Browse files Browse the repository at this point in the history
This deprecates PointerType::getElementType() in favor of
Type::getPointerElementType(). The motivation is to make it more
apparent when code accesses the pointer element type, because
getElementType() may also also refer to at least
ArrayType::getElementType() and VectorType::getElementType().

Differential Revision: https://reviews.llvm.org/D117885
  • Loading branch information
nikic committed Jan 25, 2022
1 parent 2248728 commit 184591a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion llvm/include/llvm/IR/DerivedTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,11 @@ class PointerType : public Type {
unsigned AddressSpace) {
if (PT->isOpaque())
return get(PT->getContext(), AddressSpace);
return get(PT->getElementType(), AddressSpace);
return get(PT->PointeeTy, AddressSpace);
}

[[deprecated("Pointer element types are deprecated. You can *temporarily* "
"use Type::getPointerElementType() instead")]]
Type *getElementType() const {
assert(!isOpaque() && "Attempting to get element type of opaque pointer");
return PointeeTy;
Expand Down

0 comments on commit 184591a

Please sign in to comment.