Add and use Type::subtypes. NFC.

llvm-svn: 222682
This commit is contained in:
Rafael Espindola 2014-11-24 20:44:36 +00:00
parent 3410466495
commit ffbfcf29f2
3 changed files with 7 additions and 6 deletions

View File

@ -313,6 +313,9 @@ public:
typedef Type * const *subtype_iterator; typedef Type * const *subtype_iterator;
subtype_iterator subtype_begin() const { return ContainedTys; } subtype_iterator subtype_begin() const { return ContainedTys; }
subtype_iterator subtype_end() const { return &ContainedTys[NumContainedTys];} subtype_iterator subtype_end() const { return &ContainedTys[NumContainedTys];}
ArrayRef<Type*> subtypes() const {
return makeArrayRef(subtype_begin(), subtype_end());
}
typedef std::reverse_iterator<subtype_iterator> subtype_reverse_iterator; typedef std::reverse_iterator<subtype_iterator> subtype_reverse_iterator;
subtype_reverse_iterator subtype_rbegin() const { subtype_reverse_iterator subtype_rbegin() const {

View File

@ -35,9 +35,8 @@ void FindUsedTypes::IncorporateType(Type *Ty) {
// Make sure to add any types this type references now. // Make sure to add any types this type references now.
// //
for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); for (Type *SubTy : Ty->subtypes())
I != E; ++I) IncorporateType(SubTy);
IncorporateType(*I);
} }
void FindUsedTypes::IncorporateValue(const Value *V) { void FindUsedTypes::IncorporateValue(const Value *V) {

View File

@ -620,9 +620,8 @@ void ValueEnumerator::EnumerateType(Type *Ty) {
// Enumerate all of the subtypes before we enumerate this type. This ensures // Enumerate all of the subtypes before we enumerate this type. This ensures
// that the type will be enumerated in an order that can be directly built. // that the type will be enumerated in an order that can be directly built.
for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); for (Type *SubTy : Ty->subtypes())
I != E; ++I) EnumerateType(SubTy);
EnumerateType(*I);
// Refresh the TypeID pointer in case the table rehashed. // Refresh the TypeID pointer in case the table rehashed.
TypeID = &TypeMap[Ty]; TypeID = &TypeMap[Ty];