Add and use Type::subtypes. NFC.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 24 Nov 2014 20:44:36 +0000 (20:44 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 24 Nov 2014 20:44:36 +0000 (20:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222682 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Type.h
lib/Analysis/IPA/FindUsedTypes.cpp
lib/Bitcode/Writer/ValueEnumerator.cpp

index a36fb0f9702e6c1a13dfa31ed7e149c7dd136f5f..c2073c7750b26f4df0cd171769775a29f6f745a4 100644 (file)
@@ -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<Type*> subtypes() const {
+    return makeArrayRef(subtype_begin(), subtype_end());
+  }
 
   typedef std::reverse_iterator<subtype_iterator> subtype_reverse_iterator;
   subtype_reverse_iterator subtype_rbegin() const {
index b37344b044ced68a9742b9ca18a9ca69d522a30d..61af7a6d7b6f8bc49f973be1bfbe3aa088c60848 100644 (file)
@@ -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) {
index f065c83ab892471ae752fb6774be29b91ae2769e..6971d3aacd31afaa2bd61de9e3a3e1eea27b2dc5 100644 (file)
@@ -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];