@@ -156,66 +156,62 @@ bool lldb_private::formatters::swift::SwiftOptionSetSummaryProvider::
156
156
return false ;
157
157
158
158
llvm::APInt value;
159
- if (ReadValueIfAny (*rawValue_sp, value)) {
160
- FillCasesIfNeeded ();
161
-
162
- StreamString ss;
163
- bool first_match = true ;
164
- bool any_match = false ;
165
-
166
- llvm::APInt matched_value (llvm::APInt::getNullValue (64 ));
167
-
168
- for (auto val_name : *m_cases) {
169
- llvm::APInt case_value = val_name.first ;
170
- // Print single valued sets without using enclosing brackets.
171
- // `WouldEvenConsiderFormatting` can't opt out early because it
172
- // has only the type, but needs the value for this case.
173
- if (case_value == value) {
174
- ss << ' .' << val_name.second ;
175
- dest.assign (ss.GetData ());
176
- return true ;
177
- }
178
- // Don't display the zero case in an option set unless it's the
179
- // only value.
180
- if (case_value == 0 && value != 0 )
181
- continue ;
182
- if ((case_value & value) == case_value) {
183
- // hey a case matched!!
184
- any_match = true ;
185
- if (first_match) {
186
- ss.Printf (" [.%s" , val_name.second .AsCString ());
187
- first_match = false ;
188
- } else {
189
- ss.Printf (" , .%s" , val_name.second .AsCString ());
190
- }
191
-
192
- matched_value |= case_value;
193
-
194
- // if we matched everything, get out
195
- if (matched_value == value)
196
- break ;
197
- }
159
+ if (!ReadValueIfAny (*rawValue_sp, value))
160
+ return false ;
161
+
162
+ FillCasesIfNeeded ();
163
+
164
+ StreamString ss;
165
+ bool first_match = true ;
166
+ bool any_match = false ;
167
+
168
+ llvm::APInt matched_value (llvm::APInt::getNullValue (64 ));
169
+
170
+ for (auto val_name : *m_cases) {
171
+ llvm::APInt case_value = val_name.first ;
172
+ // Print single valued sets without using enclosing brackets.
173
+ // `WouldEvenConsiderFormatting` can't opt out early because it
174
+ // has only the type, but needs the value for this case.
175
+ if (case_value == value) {
176
+ ss << ' .' << val_name.second ;
177
+ dest.assign (ss.GetData ());
178
+ return true ;
198
179
}
180
+ // Don't display the zero case in an option set unless it's the
181
+ // only value.
182
+ if (case_value == 0 && value != 0 )
183
+ continue ;
184
+ if ((case_value & value) == case_value) {
185
+ // hey a case matched!!
186
+ any_match = true ;
187
+ if (first_match) {
188
+ ss << " [." << val_name.second ;
189
+ first_match = false ;
190
+ } else {
191
+ ss << " , ." << val_name.second ;
192
+ }
193
+
194
+ matched_value |= case_value;
199
195
200
- if (any_match) {
201
- // if we found a full match, then close the list
196
+ // if we matched everything, get out
202
197
if (matched_value == value)
203
- ss.PutChar (' ]' );
204
- else {
205
- // print the unaccounted-for bits separately
206
- llvm::APInt residual = (value & ~matched_value);
207
- ss.Printf (" , 0x%s]" , residual.toString (16 , false ).c_str ());
208
- }
198
+ break ;
209
199
}
200
+ }
210
201
211
- // if we printed anything, use it
212
- const char *data = ss.GetData ();
213
- if (data && data[0 ]) {
214
- dest.assign (data);
215
- return true ;
216
- }
202
+ if (!any_match)
203
+ return false ;
204
+
205
+ if (matched_value != value) {
206
+ // print the unaccounted-for bits separately
207
+ llvm::APInt residual = value & ~matched_value;
208
+ ss << " , 0x" << residual.toString (16 , false );
217
209
}
218
- return false ;
210
+ // close the list
211
+ ss << ' ]' ;
212
+
213
+ dest.assign (ss.GetData ());
214
+ return true ;
219
215
}
220
216
221
217
bool lldb_private::formatters::swift::SwiftOptionSetSummaryProvider::
0 commit comments