[NFC][ADT/Support] Add {} for else when if body has {} (#140758)

This commit is contained in:
Rahul Joshi
2025-05-21 13:19:09 -07:00
committed by GitHub
parent 89d9a83b70
commit a76bf4da53
19 changed files with 84 additions and 50 deletions

View File

@@ -2132,9 +2132,10 @@ class IntervalMapOverlaps {
posB.advanceTo(posA.start());
if (!posB.valid() || !Traits::stopLess(posA.stop(), posB.start()))
return;
} else
} else {
// Already overlapping.
return;
}
while (true) {
// Make a.end > b.start.

View File

@@ -1804,8 +1804,9 @@ T *find_singleton(R &&Range, Predicate P, bool AllowRepeats = false) {
if (RC) {
if (!AllowRepeats || PRC != RC)
return nullptr;
} else
} else {
RC = PRC;
}
}
}
return RC;
@@ -1835,8 +1836,9 @@ std::pair<T *, bool> find_singleton_nested(R &&Range, Predicate P,
if (RC) {
if (!AllowRepeats || PRC.first != RC)
return {nullptr, true};
} else
} else {
RC = PRC.first;
}
}
}
return {RC, false};

View File

@@ -393,8 +393,9 @@ public:
uintptr_t IMask = ((uintptr_t)1) << I;
uintptr_t Mask = EMask - IMask;
setSmallBits(getSmallBits() | Mask);
} else
} else {
getPointer()->set(I, E);
}
return *this;
}
@@ -424,8 +425,9 @@ public:
uintptr_t IMask = ((uintptr_t)1) << I;
uintptr_t Mask = EMask - IMask;
setSmallBits(getSmallBits() & ~Mask);
} else
} else {
getPointer()->reset(I, E);
}
return *this;
}

View File

@@ -275,8 +275,9 @@ namespace llvm {
if (Str[0] != '\0') {
LHS.cString = Str;
LHSKind = CStringKind;
} else
} else {
LHSKind = EmptyKind;
}
assert(isValid() && "Invalid twine!");
}

View File

@@ -418,8 +418,9 @@ private:
auto &E2List = static_cast<ErrorList &>(*E2Payload);
for (auto &Payload : E2List.Payloads)
E1List.Payloads.push_back(std::move(Payload));
} else
} else {
E1List.Payloads.push_back(E2.takePayload());
}
return E1;
}
@@ -714,10 +715,11 @@ private:
if (HasError) {
dbgs() << "Unchecked Expected<T> contained error:\n";
(*getErrorStorage())->log(dbgs());
} else
} else {
dbgs() << "Expected<T> value was in success state. (Note: Expected<T> "
"values in success mode must still be checked prior to being "
"destroyed).\n";
}
abort();
}
#endif

View File

@@ -425,8 +425,9 @@ void LoopBase<BlockT, LoopT>::print(raw_ostream &OS, bool Verbose,
if (i)
OS << ",";
BB->printAsOperand(OS, false);
} else
OS << "\n";
} else {
OS << '\n';
}
if (BB == H)
OS << "<header>";

View File

@@ -200,8 +200,9 @@ public:
O << "<<table border=\"0\" cellborder=\"1\" cellspacing=\"0\""
<< " cellpadding=\"0\"><tr><td align=\"text\" colspan=\"" << ColSpan
<< "\">";
} else
} else {
O << "\"{";
}
if (!DTraits.renderGraphFromBottomUp()) {
if (RenderUsingHTML)

View File

@@ -27,8 +27,9 @@
// yaml::Node *n = di->getRoot();
// if (n) {
// // Do something with n...
// } else
// } else {
// break;
// }
// }
//
//===----------------------------------------------------------------------===//

View File

@@ -289,8 +289,9 @@ APFixedPoint APFixedPoint::mul(const APFixedPoint &Other,
Result = Min;
else if (Result > Max)
Result = Max;
} else
} else {
Overflowed = Result < Min || Result > Max;
}
if (Overflow)
*Overflow = Overflowed;
@@ -335,8 +336,9 @@ APFixedPoint APFixedPoint::div(const APFixedPoint &Other,
// towards negative infinity by subtracting epsilon from the result.
if (ThisVal.isNegative() != OtherVal.isNegative() && !Rem.isZero())
Result = Result - 1;
} else
} else {
Result = ThisVal.udiv(OtherVal);
}
Result.setIsSigned(CommonFXSema.isSigned());
// If our result lies outside of the representative range of the common
@@ -350,8 +352,9 @@ APFixedPoint APFixedPoint::div(const APFixedPoint &Other,
Result = Min;
else if (Result > Max)
Result = Max;
} else
} else {
Overflowed = Result < Min || Result > Max;
}
if (Overflow)
*Overflow = Overflowed;
@@ -385,8 +388,9 @@ APFixedPoint APFixedPoint::shl(unsigned Amt, bool *Overflow) const {
Result = Min;
else if (Result > Max)
Result = Max;
} else
} else {
Overflowed = Result < Min || Result > Max;
}
if (Overflow)
*Overflow = Overflowed;
@@ -612,8 +616,9 @@ APFixedPoint::getFromFloatValue(const APFloat &Value,
Res = getMax(DstFXSema).getValue();
else if (Val < FloatMin)
Res = getMin(DstFXSema).getValue();
} else
} else {
Overflowed = Val > FloatMax || Val < FloatMin;
}
if (Overflow)
*Overflow = Overflowed;

View File

@@ -893,8 +893,9 @@ writeSignedDecimal (char *dst, int value)
if (value < 0) {
*dst++ = '-';
dst = writeUnsignedDecimal(dst, -(unsigned) value);
} else
} else {
dst = writeUnsignedDecimal(dst, value);
}
return dst;
}
@@ -2814,8 +2815,8 @@ APFloat::opStatus IEEEFloat::convertToSignExtendedInteger(
if (lost_fraction == lfExactlyZero) {
*isExact = true;
return opOK;
} else
return opInexact;
}
return opInexact;
}
/* Same as convertToSignExtendedInteger, except we provide
@@ -3302,8 +3303,9 @@ bool IEEEFloat::convertFromStringSpecials(StringRef str) {
if (str.size() > 1 && tolower(str[1]) == 'x') {
str = str.drop_front(2);
Radix = 16;
} else
} else {
Radix = 8;
}
}
// Parse the payload and make the NaN.
@@ -4529,8 +4531,9 @@ void IEEEFloat::toString(SmallVectorImpl<char> &Str, unsigned FormatPrecision,
Str.append(FormatPrecision - 1, '0');
append(Str, "e+00");
}
} else
} else {
Str.push_back('0');
}
return;
case fcNormal:

View File

@@ -878,15 +878,14 @@ APInt llvm::APIntOps::RoundDoubleToAPInt(double Double, unsigned width) {
/// | 1[63] 11[62-52] 52[51-00] 1023 |
/// --------------------------------------
double APInt::roundToDouble(bool isSigned) const {
// Handle the simple case where the value is contained in one uint64_t.
// It is wrong to optimize getWord(0) to VAL; there might be more than one word.
if (isSingleWord() || getActiveBits() <= APINT_BITS_PER_WORD) {
if (isSigned) {
int64_t sext = SignExtend64(getWord(0), BitWidth);
return double(sext);
} else
return double(getWord(0));
}
return double(getWord(0));
}
// Determine if the value is negative.
@@ -2578,8 +2577,9 @@ int APInt::tcMultiplyPart(WordType *dst, const WordType *src,
if (low + dst[i] < low)
high++;
dst[i] += low;
} else
} else {
dst[i] = low;
}
carry = high;
}

View File

@@ -2692,8 +2692,9 @@ void HelpPrinterWrapper::operator=(bool Value) {
CommonOptions->HLOp.setHiddenFlag(NotHidden);
CategorizedPrinter = true; // Invoke categorized printer
} else
} else {
UncategorizedPrinter = true; // Invoke uncategorized printer
}
}
// Print the value of each option.

View File

@@ -660,8 +660,9 @@ const json::Value *ASTNode::findContext() {
CurrentContext = CurrentValue->getAsObject();
if (!CurrentContext)
return nullptr;
} else
} else {
Context = CurrentValue;
}
}
return Context;
}

View File

@@ -185,8 +185,9 @@ static void CrashHandler(void *) {
if (!crashHandlerString.empty()) {
setCrashLogMessage(crashHandlerString.c_str());
errs() << crashHandlerString.str();
} else
} else {
setCrashLogMessage("No crash information.");
}
#endif
}

View File

@@ -240,8 +240,9 @@ std::string ScaledNumberBase::toString(uint64_t D, int16_t E, int Width,
if (Above0) {
appendNumber(Str, Above0);
DigitsOut = Str.size();
} else
} else {
appendDigit(Str, 0);
}
std::reverse(Str.begin(), Str.end());
// Return early if there's nothing after the decimal.
@@ -262,8 +263,9 @@ std::string ScaledNumberBase::toString(uint64_t D, int16_t E, int Width,
if (ExtraShift) {
--ExtraShift;
Error *= 5;
} else
} else {
Error *= 10;
}
Below0 *= 10;
Extra *= 10;

View File

@@ -389,8 +389,9 @@ std::error_code current_path(SmallVectorImpl<char> &result) {
}
// Otherwise there just wasn't enough space.
result.resize_for_overwrite(result.capacity() * 2);
} else
} else {
break;
}
}
result.truncate(strlen(result.data()));
@@ -938,8 +939,9 @@ std::error_code detail::directory_iterator_increment(detail::DirIterState &It) {
(Name.size() == 2 && Name[0] == '.' && Name[1] == '.'))
return directory_iterator_increment(It);
It.CurrentEntry.replace_filename(Name, direntType(CurDir));
} else
} else {
return directory_iterator_destruct(It);
}
return std::error_code();
}

View File

@@ -118,8 +118,9 @@ std::error_code widenPath(const Twine &Path8, SmallVectorImpl<wchar_t> &Path16,
if (RootName[1] != ':') { // Check if UNC.
FullPath.append("UNC\\");
FullPath.append(Path8Str.begin() + 2, Path8Str.end());
} else
} else {
FullPath.append(Path8Str);
}
return UTF8ToUTF16(FullPath, Path16);
}
@@ -1057,8 +1058,9 @@ std::error_code detail::directory_iterator_construct(detail::DirIterState &IT,
if (LastError == ERROR_NO_MORE_FILES)
return detail::directory_iterator_destruct(IT);
return mapWindowsError(LastError);
} else
} else {
FilenameLen = ::wcslen(FirstFind.cFileName);
}
// Construct the current directory entry.
SmallString<128> DirectoryEntryNameUTF8;

View File

@@ -761,8 +761,9 @@ std::string yaml::escape(StringRef Input, bool EscapePrintable) {
EscapedInput += "\\U" + std::string(8 - HexStr.size(), '0') + HexStr;
}
i += UnicodeScalarValue.second - 1;
} else
} else {
EscapedInput.push_back(*i);
}
}
return EscapedInput;
}
@@ -1011,17 +1012,16 @@ void Scanner::scan_ns_uri_char() {
while (true) {
if (Current == End)
break;
if (( *Current == '%'
&& Current + 2 < End
&& is_ns_hex_digit(*(Current + 1))
&& is_ns_hex_digit(*(Current + 2)))
|| is_ns_word_char(*Current)
|| StringRef(Current, 1).find_first_of("#;/?:@&=+$,_.!~*'()[]")
!= StringRef::npos) {
if ((*Current == '%' && Current + 2 < End &&
is_ns_hex_digit(*(Current + 1)) && is_ns_hex_digit(*(Current + 2))) ||
is_ns_word_char(*Current) ||
StringRef(Current, 1).find_first_of("#;/?:@&=+$,_.!~*'()[]") !=
StringRef::npos) {
++Current;
++Column;
} else
} else {
break;
}
}
}
@@ -1105,8 +1105,9 @@ void Scanner::removeStaleSimpleKeyCandidates() {
setError( "Could not find expected : for simple key"
, i->Tok->Range.begin());
i = SimpleKeys.erase(i);
} else
} else {
++i;
}
}
}
@@ -2631,8 +2632,9 @@ bool Document::parseDirectives() {
} else if (T.Kind == Token::TK_VersionDirective) {
parseYAMLDirective();
isDirective = true;
} else
} else {
break;
}
}
return isDirective;
}

View File

@@ -304,8 +304,9 @@ llvm_regcomp(llvm_regex_t *preg, const char *pattern, int cflags) {
if (preg->re_endp < pattern)
return (REG_INVARG);
len = preg->re_endp - pattern;
} else
} else {
len = strlen((const char *)pattern);
}
/* do the mallocs early so failure handling is easy */
g = (struct re_guts *)malloc(sizeof(struct re_guts) +
@@ -715,8 +716,9 @@ p_simp_re(struct parse *p,
assert(OP(p->strip[p->pend[i]]) == ORPAREN);
(void)dupl(p, p->pbegin[i] + 1, p->pend[i]);
EMIT(O_BACK, i);
} else
} else {
SETERROR(REG_ESUBREG);
}
p->g->backrefs = 1;
break;
case '*':
@@ -851,8 +853,9 @@ static void p_bracket(struct parse *p) {
if (nch(p, cs) == 1) { /* optimize singleton sets */
ordinary(p, firstch(p, cs));
freeset(p, cs);
} else
} else {
EMIT(OANYOF, freezeset(p, cs));
}
}
/*
@@ -906,8 +909,9 @@ static void p_b_term(struct parse *p, cset *cs) {
finish = '-';
else
finish = p_b_symbol(p);
} else
} else {
finish = start;
}
/* xxx what about signed chars here... */
REQUIRE(start <= finish, REG_ERANGE);
for (i = start; i <= finish; i++)