llvm.org GIT mirror llvm / 1eed890
[C++11] Range-based loop simplification. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206715 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Atanasyan 6 years ago
1 changed file(s) with 13 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
8080 ArrayRef > EnumValues) {
8181 StringRef Name;
8282 bool Found = false;
83 for (size_t i = 0; i < EnumValues.size(); ++i) {
84 if (EnumValues[i].Value == Value) {
85 Name = EnumValues[i].Name;
83 for (const auto &EnumItem : EnumValues) {
84 if (EnumItem.Value == Value) {
85 Name = EnumItem.Name;
8686 Found = true;
8787 break;
8888 }
102102 typedef SmallVector FlagVector;
103103 FlagVector SetFlags;
104104
105 for (typename ArrayRef::const_iterator I = Flags.begin(),
106 E = Flags.end(); I != E; ++I) {
107 if (I->Value == 0)
105 for (const auto &Flag : Flags) {
106 if (Flag.Value == 0)
108107 continue;
109108
110 bool IsEnum = (I->Value & EnumMask) != 0;
111 if ((!IsEnum && (Value & I->Value) == I->Value) ||
112 (IsEnum && (Value & EnumMask) == I->Value)) {
113 SetFlags.push_back(*I);
109 bool IsEnum = (Flag.Value & EnumMask) != 0;
110 if ((!IsEnum && (Value & Flag.Value) == Flag.Value) ||
111 (IsEnum && (Value & EnumMask) == Flag.Value)) {
112 SetFlags.push_back(Flag);
114113 }
115114 }
116115
117116 std::sort(SetFlags.begin(), SetFlags.end(), &flagName);
118117
119118 startLine() << Label << " [ (" << hex(Value) << ")\n";
120 for (typename FlagVector::const_iterator I = SetFlags.begin(),
121 E = SetFlags.end();
122 I != E; ++I) {
123 startLine() << " " << I->Name << " (" << hex(I->Value) << ")\n";
119 for (const auto &Flag : SetFlags) {
120 startLine() << " " << Flag.Name << " (" << hex(Flag.Value) << ")\n";
124121 }
125122 startLine() << "]\n";
126123 }
175172 void printList(StringRef Label, const SmallVectorImpl &List) {
176173 startLine() << Label << ": [";
177174 bool Comma = false;
178 for (unsigned LI = 0, LE = List.size(); LI != LE; ++LI) {
175 for (const auto &Item : List) {
179176 if (Comma)
180177 OS << ", ";
181 OS << List[LI];
178 OS << Item;
182179 Comma = true;
183180 }
184181 OS << "]\n";