From: Craig Topper Date: Sat, 1 Aug 2015 22:20:31 +0000 (+0000) Subject: Mark Type::getPointerTo as const. Unfortunately, this requires a const_cast inside... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=55afc087595de0574b7fd7cbd383b54deb5986c4;p=llvm Mark Type::getPointerTo as const. Unfortunately, this requires a const_cast inside, but at least it makes all methods on Type const. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243844 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/Type.h b/include/llvm/IR/Type.h index bbee3f93741..93a8a2f1865 100644 --- a/include/llvm/IR/Type.h +++ b/include/llvm/IR/Type.h @@ -416,7 +416,7 @@ public: /// getPointerTo - Return a pointer to the current type. This is equivalent /// to PointerType::get(Foo, AddrSpace). - PointerType *getPointerTo(unsigned AddrSpace = 0); + PointerType *getPointerTo(unsigned AddrSpace = 0) const; private: /// isSizedDerivedType - Derived types like structures and arrays are sized diff --git a/lib/IR/Type.cpp b/lib/IR/Type.cpp index 17d24465601..553fa93f585 100644 --- a/lib/IR/Type.cpp +++ b/lib/IR/Type.cpp @@ -748,8 +748,8 @@ PointerType::PointerType(Type *E, unsigned AddrSpace) assert(oldNCT == NumContainedTys && "bitfield written out of bounds?"); } -PointerType *Type::getPointerTo(unsigned addrs) { - return PointerType::get(this, addrs); +PointerType *Type::getPointerTo(unsigned addrs) const { + return PointerType::get(const_cast(this), addrs); } bool PointerType::isValidElementType(Type *ElemTy) {