summaryrefslogtreecommitdiff
path: root/tools/llvm-readobj
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2014-04-20 21:05:30 +0000
committerSimon Atanasyan <simon@atanasyan.com>2014-04-20 21:05:30 +0000
commit1eed8904e8bdb7dbeaa412d5b176f7668ec5b59b (patch)
tree81dfacb4565f2a26e74d2277704d0f26dc3ef9ef /tools/llvm-readobj
parent8f5902164338c448b04985ff251f72a55e24ce0b (diff)
[C++11] Range-based loop simplification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206715 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-readobj')
-rw-r--r--tools/llvm-readobj/StreamWriter.h29
1 files changed, 13 insertions, 16 deletions
diff --git a/tools/llvm-readobj/StreamWriter.h b/tools/llvm-readobj/StreamWriter.h
index c40077a1799..9282dcc91a8 100644
--- a/tools/llvm-readobj/StreamWriter.h
+++ b/tools/llvm-readobj/StreamWriter.h
@@ -81,9 +81,9 @@ public:
ArrayRef<EnumEntry<TEnum> > EnumValues) {
StringRef Name;
bool Found = false;
- for (size_t i = 0; i < EnumValues.size(); ++i) {
- if (EnumValues[i].Value == Value) {
- Name = EnumValues[i].Name;
+ for (const auto &EnumItem : EnumValues) {
+ if (EnumItem.Value == Value) {
+ Name = EnumItem.Name;
Found = true;
break;
}
@@ -103,25 +103,22 @@ public:
typedef SmallVector<FlagEntry, 10> FlagVector;
FlagVector SetFlags;
- for (typename ArrayRef<FlagEntry>::const_iterator I = Flags.begin(),
- E = Flags.end(); I != E; ++I) {
- if (I->Value == 0)
+ for (const auto &Flag : Flags) {
+ if (Flag.Value == 0)
continue;
- bool IsEnum = (I->Value & EnumMask) != 0;
- if ((!IsEnum && (Value & I->Value) == I->Value) ||
- (IsEnum && (Value & EnumMask) == I->Value)) {
- SetFlags.push_back(*I);
+ bool IsEnum = (Flag.Value & EnumMask) != 0;
+ if ((!IsEnum && (Value & Flag.Value) == Flag.Value) ||
+ (IsEnum && (Value & EnumMask) == Flag.Value)) {
+ SetFlags.push_back(Flag);
}
}
std::sort(SetFlags.begin(), SetFlags.end(), &flagName<TFlag>);
startLine() << Label << " [ (" << hex(Value) << ")\n";
- for (typename FlagVector::const_iterator I = SetFlags.begin(),
- E = SetFlags.end();
- I != E; ++I) {
- startLine() << " " << I->Name << " (" << hex(I->Value) << ")\n";
+ for (const auto &Flag : SetFlags) {
+ startLine() << " " << Flag.Name << " (" << hex(Flag.Value) << ")\n";
}
startLine() << "]\n";
}
@@ -176,10 +173,10 @@ public:
void printList(StringRef Label, const SmallVectorImpl<T_> &List) {
startLine() << Label << ": [";
bool Comma = false;
- for (unsigned LI = 0, LE = List.size(); LI != LE; ++LI) {
+ for (const auto &Item : List) {
if (Comma)
OS << ", ";
- OS << List[LI];
+ OS << Item;
Comma = true;
}
OS << "]\n";