Skip to content

Commit a76bf4d

Browse files
authored
[NFC][ADT/Support] Add {} for else when if body has {} (#140758)
1 parent 89d9a83 commit a76bf4d

19 files changed

+84
-50
lines changed

llvm/include/llvm/ADT/IntervalMap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2132,9 +2132,10 @@ class IntervalMapOverlaps {
21322132
posB.advanceTo(posA.start());
21332133
if (!posB.valid() || !Traits::stopLess(posA.stop(), posB.start()))
21342134
return;
2135-
} else
2135+
} else {
21362136
// Already overlapping.
21372137
return;
2138+
}
21382139

21392140
while (true) {
21402141
// Make a.end > b.start.

llvm/include/llvm/ADT/STLExtras.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,8 +1804,9 @@ T *find_singleton(R &&Range, Predicate P, bool AllowRepeats = false) {
18041804
if (RC) {
18051805
if (!AllowRepeats || PRC != RC)
18061806
return nullptr;
1807-
} else
1807+
} else {
18081808
RC = PRC;
1809+
}
18091810
}
18101811
}
18111812
return RC;
@@ -1835,8 +1836,9 @@ std::pair<T *, bool> find_singleton_nested(R &&Range, Predicate P,
18351836
if (RC) {
18361837
if (!AllowRepeats || PRC.first != RC)
18371838
return {nullptr, true};
1838-
} else
1839+
} else {
18391840
RC = PRC.first;
1841+
}
18401842
}
18411843
}
18421844
return {RC, false};

llvm/include/llvm/ADT/SmallBitVector.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,9 @@ class SmallBitVector {
393393
uintptr_t IMask = ((uintptr_t)1) << I;
394394
uintptr_t Mask = EMask - IMask;
395395
setSmallBits(getSmallBits() | Mask);
396-
} else
396+
} else {
397397
getPointer()->set(I, E);
398+
}
398399
return *this;
399400
}
400401

@@ -424,8 +425,9 @@ class SmallBitVector {
424425
uintptr_t IMask = ((uintptr_t)1) << I;
425426
uintptr_t Mask = EMask - IMask;
426427
setSmallBits(getSmallBits() & ~Mask);
427-
} else
428+
} else {
428429
getPointer()->reset(I, E);
430+
}
429431
return *this;
430432
}
431433

llvm/include/llvm/ADT/Twine.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,9 @@ namespace llvm {
275275
if (Str[0] != '\0') {
276276
LHS.cString = Str;
277277
LHSKind = CStringKind;
278-
} else
278+
} else {
279279
LHSKind = EmptyKind;
280+
}
280281

281282
assert(isValid() && "Invalid twine!");
282283
}

llvm/include/llvm/Support/Error.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,9 @@ class LLVM_ABI ErrorList final : public ErrorInfo<ErrorList> {
418418
auto &E2List = static_cast<ErrorList &>(*E2Payload);
419419
for (auto &Payload : E2List.Payloads)
420420
E1List.Payloads.push_back(std::move(Payload));
421-
} else
421+
} else {
422422
E1List.Payloads.push_back(E2.takePayload());
423+
}
423424

424425
return E1;
425426
}
@@ -714,10 +715,11 @@ template <class T> class [[nodiscard]] Expected {
714715
if (HasError) {
715716
dbgs() << "Unchecked Expected<T> contained error:\n";
716717
(*getErrorStorage())->log(dbgs());
717-
} else
718+
} else {
718719
dbgs() << "Expected<T> value was in success state. (Note: Expected<T> "
719720
"values in success mode must still be checked prior to being "
720721
"destroyed).\n";
722+
}
721723
abort();
722724
}
723725
#endif

llvm/include/llvm/Support/GenericLoopInfoImpl.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,9 @@ void LoopBase<BlockT, LoopT>::print(raw_ostream &OS, bool Verbose,
425425
if (i)
426426
OS << ",";
427427
BB->printAsOperand(OS, false);
428-
} else
429-
OS << "\n";
428+
} else {
429+
OS << '\n';
430+
}
430431

431432
if (BB == H)
432433
OS << "<header>";

llvm/include/llvm/Support/GraphWriter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ class GraphWriter {
200200
O << "<<table border=\"0\" cellborder=\"1\" cellspacing=\"0\""
201201
<< " cellpadding=\"0\"><tr><td align=\"text\" colspan=\"" << ColSpan
202202
<< "\">";
203-
} else
203+
} else {
204204
O << "\"{";
205+
}
205206

206207
if (!DTraits.renderGraphFromBottomUp()) {
207208
if (RenderUsingHTML)

llvm/include/llvm/Support/YAMLParser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
// yaml::Node *n = di->getRoot();
2828
// if (n) {
2929
// // Do something with n...
30-
// } else
30+
// } else {
3131
// break;
32+
// }
3233
// }
3334
//
3435
//===----------------------------------------------------------------------===//

llvm/lib/Support/APFixedPoint.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,9 @@ APFixedPoint APFixedPoint::mul(const APFixedPoint &Other,
289289
Result = Min;
290290
else if (Result > Max)
291291
Result = Max;
292-
} else
292+
} else {
293293
Overflowed = Result < Min || Result > Max;
294+
}
294295

295296
if (Overflow)
296297
*Overflow = Overflowed;
@@ -335,8 +336,9 @@ APFixedPoint APFixedPoint::div(const APFixedPoint &Other,
335336
// towards negative infinity by subtracting epsilon from the result.
336337
if (ThisVal.isNegative() != OtherVal.isNegative() && !Rem.isZero())
337338
Result = Result - 1;
338-
} else
339+
} else {
339340
Result = ThisVal.udiv(OtherVal);
341+
}
340342
Result.setIsSigned(CommonFXSema.isSigned());
341343

342344
// If our result lies outside of the representative range of the common
@@ -350,8 +352,9 @@ APFixedPoint APFixedPoint::div(const APFixedPoint &Other,
350352
Result = Min;
351353
else if (Result > Max)
352354
Result = Max;
353-
} else
355+
} else {
354356
Overflowed = Result < Min || Result > Max;
357+
}
355358

356359
if (Overflow)
357360
*Overflow = Overflowed;
@@ -385,8 +388,9 @@ APFixedPoint APFixedPoint::shl(unsigned Amt, bool *Overflow) const {
385388
Result = Min;
386389
else if (Result > Max)
387390
Result = Max;
388-
} else
391+
} else {
389392
Overflowed = Result < Min || Result > Max;
393+
}
390394

391395
if (Overflow)
392396
*Overflow = Overflowed;
@@ -612,8 +616,9 @@ APFixedPoint::getFromFloatValue(const APFloat &Value,
612616
Res = getMax(DstFXSema).getValue();
613617
else if (Val < FloatMin)
614618
Res = getMin(DstFXSema).getValue();
615-
} else
619+
} else {
616620
Overflowed = Val > FloatMax || Val < FloatMin;
621+
}
617622

618623
if (Overflow)
619624
*Overflow = Overflowed;

llvm/lib/Support/APFloat.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,9 @@ writeSignedDecimal (char *dst, int value)
893893
if (value < 0) {
894894
*dst++ = '-';
895895
dst = writeUnsignedDecimal(dst, -(unsigned) value);
896-
} else
896+
} else {
897897
dst = writeUnsignedDecimal(dst, value);
898+
}
898899

899900
return dst;
900901
}
@@ -2814,8 +2815,8 @@ APFloat::opStatus IEEEFloat::convertToSignExtendedInteger(
28142815
if (lost_fraction == lfExactlyZero) {
28152816
*isExact = true;
28162817
return opOK;
2817-
} else
2818-
return opInexact;
2818+
}
2819+
return opInexact;
28192820
}
28202821

28212822
/* Same as convertToSignExtendedInteger, except we provide
@@ -3302,8 +3303,9 @@ bool IEEEFloat::convertFromStringSpecials(StringRef str) {
33023303
if (str.size() > 1 && tolower(str[1]) == 'x') {
33033304
str = str.drop_front(2);
33043305
Radix = 16;
3305-
} else
3306+
} else {
33063307
Radix = 8;
3308+
}
33073309
}
33083310

33093311
// Parse the payload and make the NaN.
@@ -4529,8 +4531,9 @@ void IEEEFloat::toString(SmallVectorImpl<char> &Str, unsigned FormatPrecision,
45294531
Str.append(FormatPrecision - 1, '0');
45304532
append(Str, "e+00");
45314533
}
4532-
} else
4534+
} else {
45334535
Str.push_back('0');
4536+
}
45344537
return;
45354538

45364539
case fcNormal:

0 commit comments

Comments
 (0)