Mark CompositeType::getTypeAtIndex as const. NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243845 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2015-08-01 22:52:12 +00:00
parent 55afc08759
commit f03f83cfc0
2 changed files with 9 additions and 7 deletions

View File

@ -153,8 +153,8 @@ public:
/// getTypeAtIndex - Given an index value into the type, return the type of
/// the element.
///
Type *getTypeAtIndex(const Value *V);
Type *getTypeAtIndex(unsigned Idx);
Type *getTypeAtIndex(const Value *V) const;
Type *getTypeAtIndex(unsigned Idx) const;
bool indexValid(const Value *V) const;
bool indexValid(unsigned Idx) const;

View File

@ -620,8 +620,8 @@ StructType *Module::getTypeByName(StringRef Name) const {
// CompositeType Implementation
//===----------------------------------------------------------------------===//
Type *CompositeType::getTypeAtIndex(const Value *V) {
if (StructType *STy = dyn_cast<StructType>(this)) {
Type *CompositeType::getTypeAtIndex(const Value *V) const {
if (auto *STy = dyn_cast<StructType>(this)) {
unsigned Idx =
(unsigned)cast<Constant>(V)->getUniqueInteger().getZExtValue();
assert(indexValid(Idx) && "Invalid structure index!");
@ -630,14 +630,16 @@ Type *CompositeType::getTypeAtIndex(const Value *V) {
return cast<SequentialType>(this)->getElementType();
}
Type *CompositeType::getTypeAtIndex(unsigned Idx) {
if (StructType *STy = dyn_cast<StructType>(this)) {
Type *CompositeType::getTypeAtIndex(unsigned Idx) const{
if (auto *STy = dyn_cast<StructType>(this)) {
assert(indexValid(Idx) && "Invalid structure index!");
return STy->getElementType(Idx);
}
return cast<SequentialType>(this)->getElementType();
}
bool CompositeType::indexValid(const Value *V) const {
if (auto *STy = dyn_cast<StructType>(this)) {
// Structure indexes require (vectors of) 32-bit integer constants. In the