[llvm] r222682 - Add and use Type::subtypes. NFC.
Rafael Espindola
rafael.espindola at gmail.com
Mon Nov 24 12:44:36 PST 2014
Author: rafael
Date: Mon Nov 24 14:44:36 2014
New Revision: 222682
URL: http://llvm.org/viewvc/llvm-project?rev=222682&view=rev
Log:
Add and use Type::subtypes. NFC.
Modified:
llvm/trunk/include/llvm/IR/Type.h
llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp
llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
Modified: llvm/trunk/include/llvm/IR/Type.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Type.h?rev=222682&r1=222681&r2=222682&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Type.h (original)
+++ llvm/trunk/include/llvm/IR/Type.h Mon Nov 24 14:44:36 2014
@@ -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 {
Modified: llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp?rev=222682&r1=222681&r2=222682&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp (original)
+++ llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp Mon Nov 24 14:44:36 2014
@@ -35,9 +35,8 @@ void FindUsedTypes::IncorporateType(Type
// 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) {
Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=222682&r1=222681&r2=222682&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Mon Nov 24 14:44:36 2014
@@ -620,9 +620,8 @@ void ValueEnumerator::EnumerateType(Type
// 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];
More information about the llvm-commits
mailing list