Skip to content

Commit 10a3a2e

Browse files
jj-marrvbvictor
andcommitted
Use early return
Co-authored-by: Baranov Victor <bar.victor.2002@gmail.com>
1 parent 2a6222d commit 10a3a2e

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

clang-tools-extra/clang-tidy/portability/AvoidPlatformSpecificFundamentalTypesCheck.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,24 +148,25 @@ void AvoidPlatformSpecificFundamentalTypesCheck::check(
148148
assert(BT);
149149
if (BT->isFloatingPoint()) {
150150
const auto Replacement = getFloatReplacement(BT, *Result.Context);
151-
if (Replacement.has_value()) {
152-
auto Diag =
153-
diag(Loc, "avoid using platform-dependent floating point type '%0'; "
154-
"consider using '%1' instead")
155-
<< TypeName << Replacement;
156-
157-
if (TypeRange.isValid())
158-
Diag << FixItHint::CreateReplacement(TypeRange, Replacement.value());
159-
160-
if (auto IncludeFixit = IncludeInserter.createIncludeInsertion(
161-
Result.SourceManager->getFileID(Loc), "<stdfloat>")) {
162-
Diag << *IncludeFixit;
163-
}
164-
} else {
151+
152+
if (!Replacement.has_value()) {
165153
diag(Loc, "avoid using platform-dependent floating point type '%0'; "
166154
"consider using a type alias or fixed-width type instead")
167155
<< TypeName;
168156
}
157+
158+
auto Diag =
159+
diag(Loc, "avoid using platform-dependent floating point type '%0'; "
160+
"consider using '%1' instead")
161+
<< TypeName << Replacement;
162+
163+
if (TypeRange.isValid())
164+
Diag << FixItHint::CreateReplacement(TypeRange, Replacement.value());
165+
166+
if (auto IncludeFixit = IncludeInserter.createIncludeInsertion(
167+
Result.SourceManager->getFileID(Loc), "<stdfloat>")) {
168+
Diag << *IncludeFixit;
169+
}
169170
} else if (QT->isCharType() || QT->isWideCharType()) {
170171
diag(Loc, "avoid using platform-dependent character type '%0'; "
171172
"consider using 'char8_t' for text or 'std::byte' for bytes")

0 commit comments

Comments
 (0)