From 468d2fc5ca04bec1d186d6434652684e702a192b Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 24 Nov 2014 20:44:36 +0000 Subject: [PATCH] Add and use Type::subtypes. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222682 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Type.h | 3 +++ lib/Analysis/IPA/FindUsedTypes.cpp | 5 ++--- lib/Bitcode/Writer/ValueEnumerator.cpp | 5 ++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/llvm/IR/Type.h b/include/llvm/IR/Type.h index a36fb0f9702..c2073c7750b 100644 --- a/include/llvm/IR/Type.h +++ b/include/llvm/IR/Type.h @@ -313,6 +313,9 @@ public: typedef Type * const *subtype_iterator; subtype_iterator subtype_begin() const { return ContainedTys; } subtype_iterator subtype_end() const { return &ContainedTys[NumContainedTys];} + ArrayRef subtypes() const { + return makeArrayRef(subtype_begin(), subtype_end()); + } typedef std::reverse_iterator subtype_reverse_iterator; subtype_reverse_iterator subtype_rbegin() const { diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp index b37344b044c..61af7a6d7b6 100644 --- a/lib/Analysis/IPA/FindUsedTypes.cpp +++ b/lib/Analysis/IPA/FindUsedTypes.cpp @@ -35,9 +35,8 @@ void FindUsedTypes::IncorporateType(Type *Ty) { // Make sure to add any types this type references now. // - for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); - I != E; ++I) - IncorporateType(*I); + for (Type *SubTy : Ty->subtypes()) + IncorporateType(SubTy); } void FindUsedTypes::IncorporateValue(const Value *V) { diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp index f065c83ab89..6971d3aacd3 100644 --- a/lib/Bitcode/Writer/ValueEnumerator.cpp +++ b/lib/Bitcode/Writer/ValueEnumerator.cpp @@ -620,9 +620,8 @@ void ValueEnumerator::EnumerateType(Type *Ty) { // 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. - for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); - I != E; ++I) - EnumerateType(*I); + for (Type *SubTy : Ty->subtypes()) + EnumerateType(SubTy); // Refresh the TypeID pointer in case the table rehashed. TypeID = &TypeMap[Ty]; -- 2.34.1