[flang-commits] [flang] [Flang] KIND De-Templatization (PR #206907)
via flang-commits
flang-commits at lists.llvm.org
Wed Jul 1 01:33:53 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- flang/include/flang/Evaluate/character-value-impl.h flang/include/flang/Evaluate/character-value.h flang/include/flang/Evaluate/complex-value.h flang/include/flang/Evaluate/integer-value.h flang/include/flang/Evaluate/logical-value.h flang/include/flang/Evaluate/object-sizes.h flang/include/flang/Evaluate/real-value.h flang/lib/Evaluate/character-value-impl.cpp flang/lib/Evaluate/character-value.cpp flang/lib/Evaluate/complex-value.cpp flang/lib/Evaluate/integer-value.cpp flang/lib/Evaluate/logical-value.cpp flang/lib/Evaluate/object-size-probe.cpp flang/lib/Evaluate/real-value-impl.h flang/lib/Evaluate/real-value.cpp flang/include/flang/Evaluate/call.h flang/include/flang/Evaluate/characteristics.h flang/include/flang/Evaluate/constant.h flang/include/flang/Evaluate/expression.h flang/include/flang/Evaluate/fold-designator.h flang/include/flang/Evaluate/fold.h flang/include/flang/Evaluate/initial-image.h flang/include/flang/Evaluate/integer.h flang/include/flang/Evaluate/match.h flang/include/flang/Evaluate/real.h flang/include/flang/Evaluate/rewrite.h flang/include/flang/Evaluate/rounding-bits.h flang/include/flang/Evaluate/shape.h flang/include/flang/Evaluate/static-data.h flang/include/flang/Evaluate/tools.h flang/include/flang/Evaluate/type.h flang/include/flang/Evaluate/variable.h flang/include/flang/Lower/DirectivesCommon.h flang/include/flang/Lower/Mangler.h flang/include/flang/Lower/Support/Utils.h flang/include/flang/Semantics/dump-expr.h flang/lib/Evaluate/character.h flang/lib/Evaluate/characteristics.cpp flang/lib/Evaluate/check-expression.cpp flang/lib/Evaluate/constant.cpp flang/lib/Evaluate/expression.cpp flang/lib/Evaluate/fold-character.cpp flang/lib/Evaluate/fold-complex.cpp flang/lib/Evaluate/fold-designator.cpp flang/lib/Evaluate/fold-implementation.h flang/lib/Evaluate/fold-integer.cpp flang/lib/Evaluate/fold-logical.cpp flang/lib/Evaluate/fold-matmul.h flang/lib/Evaluate/fold-real.cpp flang/lib/Evaluate/fold-reduction.h flang/lib/Evaluate/fold.cpp flang/lib/Evaluate/formatting.cpp flang/lib/Evaluate/host.h flang/lib/Evaluate/initial-image.cpp flang/lib/Evaluate/int-power.h flang/lib/Evaluate/integer.cpp flang/lib/Evaluate/intrinsics-library.cpp flang/lib/Evaluate/real.cpp flang/lib/Evaluate/shape.cpp flang/lib/Evaluate/static-data.cpp flang/lib/Evaluate/target.cpp flang/lib/Evaluate/tools.cpp flang/lib/Evaluate/type.cpp flang/lib/Evaluate/variable.cpp flang/lib/Lower/Bridge.cpp flang/lib/Lower/CallInterface.cpp flang/lib/Lower/ConvertArrayConstructor.cpp flang/lib/Lower/ConvertConstant.cpp flang/lib/Lower/ConvertExpr.cpp flang/lib/Lower/ConvertExprToHLFIR.cpp flang/lib/Lower/ConvertType.cpp flang/lib/Lower/Support/Utils.cpp flang/lib/Semantics/check-call.cpp flang/lib/Semantics/check-case.cpp flang/lib/Semantics/check-coarray.cpp flang/lib/Semantics/check-data.cpp flang/lib/Semantics/check-io.h flang/lib/Semantics/check-omp-atomic.cpp flang/lib/Semantics/data-to-inits.cpp flang/lib/Semantics/dump-expr.cpp flang/lib/Semantics/expression.cpp flang/lib/Semantics/openmp-utils.cpp flang/lib/Semantics/pointer-assignment.cpp flang/lib/Semantics/resolve-names-utils.cpp flang/lib/Semantics/resolve-names.cpp flang/lib/Semantics/runtime-type-info.cpp flang/lib/Semantics/type.cpp flang/unittests/Evaluate/expression.cpp flang/unittests/Evaluate/folding.cpp flang/unittests/Evaluate/integer.cpp flang/unittests/Evaluate/intrinsics.cpp flang/unittests/Evaluate/logical.cpp flang/unittests/Evaluate/real.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/flang/include/flang/Evaluate/character-value-impl.h b/flang/include/flang/Evaluate/character-value-impl.h
index b6cfa6587..5a1042b74 100644
--- a/flang/include/flang/Evaluate/character-value-impl.h
+++ b/flang/include/flang/Evaluate/character-value-impl.h
@@ -54,8 +54,8 @@ public:
// Dispatch a callable over the active string alternative, mirroring
// RealValueImpl::WithReal. Precondition: not monostate.
template <typename F>
- auto WithChar(F &&f) const -> decltype(std::declval<F>()(
- std::declval<const std::string &>())) {
+ auto WithChar(F &&f) const
+ -> decltype(std::declval<F>()(std::declval<const std::string &>())) {
switch (storage_.index()) {
case 1:
return f(std::get<std::string>(storage_));
diff --git a/flang/include/flang/Evaluate/initial-image.h b/flang/include/flang/Evaluate/initial-image.h
index 04cca9268..51ba38076 100644
--- a/flang/include/flang/Evaluate/initial-image.h
+++ b/flang/include/flang/Evaluate/initial-image.h
@@ -61,7 +61,7 @@ public:
Result result{OkNoChange};
auto at{x.lbounds()};
for (std::size_t j{0}; j < x.values().size();
- ++j, x.IncrementSubscripts(at)) {
+ ++j, x.IncrementSubscripts(at)) {
auto *to{&data_.at(offset + j * strideBytes)};
const auto &scalar{x.At(at)};
if (scalar.StoreRawBytes(to, strideBytes)) {
diff --git a/flang/lib/Evaluate/character-value-impl.cpp b/flang/lib/Evaluate/character-value-impl.cpp
index a769980e7..15f39eb2a 100644
--- a/flang/lib/Evaluate/character-value-impl.cpp
+++ b/flang/lib/Evaluate/character-value-impl.cpp
@@ -83,7 +83,8 @@ bool CharacterValueImpl::StoreRawBytes(void *to, std::size_t bytes) const {
sizeof(typename std::decay_t<decltype(s)>::value_type))};
if (std::memcmp(to, s.data(), payloadBytes) != 0 ||
(payloadBytes < bytes &&
- !std::all_of(static_cast<const char *>(to) + payloadBytes,
+ !std::all_of(
+ static_cast<const char *>(to) + payloadBytes,
static_cast<const char *>(to) + bytes,
[](char x) { return x == 0; }))) {
std::memcpy(to, s.data(), payloadBytes);
diff --git a/flang/lib/Evaluate/complex-value.cpp b/flang/lib/Evaluate/complex-value.cpp
index c240c083a..f1441a467 100644
--- a/flang/lib/Evaluate/complex-value.cpp
+++ b/flang/lib/Evaluate/complex-value.cpp
@@ -237,9 +237,9 @@ ValueWithRealFlags<ComplexValue> ComplexValue::KahanSummation(
}
RealFlags flags;
RealValue reSum{re_.KahanSummation(y.re_, correction.re_, rounding)
- .AccumulateFlags(flags)};
+ .AccumulateFlags(flags)};
RealValue imSum{im_.KahanSummation(y.im_, correction.im_, rounding)
- .AccumulateFlags(flags)};
+ .AccumulateFlags(flags)};
return {ComplexValue{reSum, imSum}, flags};
}
diff --git a/flang/lib/Evaluate/fold-integer.cpp b/flang/lib/Evaluate/fold-integer.cpp
index 9097cd122..eb670abca 100644
--- a/flang/lib/Evaluate/fold-integer.cpp
+++ b/flang/lib/Evaluate/fold-integer.cpp
@@ -664,7 +664,7 @@ std::optional<Expr<T>> FoldIntrinsicFunctionCommon(
argCon && argCon->empty()) {
} else if (const auto *shiftCon{Folder<Int4>(
context, /*forOptionalArgument=*/false, /*toKind=*/4)
- .Folding(args[2])}) {
+ .Folding(args[2])}) {
for (const auto &scalar : shiftCon->values()) {
std::int64_t shiftVal{scalar.ToInt64()};
if (shiftVal < 0) {
@@ -717,7 +717,7 @@ std::optional<Expr<T>> FoldIntrinsicFunctionCommon(
argCon && argCon->empty()) {
} else if (const auto *posCon{Folder<Int4>(
context, /*forOptionalArgument=*/false, /*toKind=*/4)
- .Folding(args[1])}) {
+ .Folding(args[1])}) {
for (const auto &scalar : posCon->values()) {
std::int64_t posVal{scalar.ToInt64()};
if (posVal < 0) {
@@ -967,7 +967,7 @@ std::optional<Expr<T>> FoldIntrinsicFunctionCommon(
argCon && argCon->empty()) {
} else if (const auto *shiftCon{Folder<Int4>(
context, /*forOptionalArgument=*/false, /*toKind=*/4)
- .Folding(args[1])}) {
+ .Folding(args[1])}) {
for (const auto &scalar : shiftCon->values()) {
std::int64_t shiftVal{scalar.ToInt64()};
if (shiftVal < 0) {
diff --git a/flang/lib/Evaluate/fold-logical.cpp b/flang/lib/Evaluate/fold-logical.cpp
index 769e9904b..97d0051a4 100644
--- a/flang/lib/Evaluate/fold-logical.cpp
+++ b/flang/lib/Evaluate/fold-logical.cpp
@@ -61,7 +61,7 @@ static Expr<SomeReal> RealToIntBound(
RealType::FromInteger(IntType{negate ? -1 : 1, moldIKind}, xRKind).value};
bool decrement{true};
while (!at.ToInteger(roundingMode, 8 * moldIKind)
- .flags.test(RealFlag::Overflow)) {
+ .flags.test(RealFlag::Overflow)) {
auto tmp{at.SCALE(IntType{1, moldIKind})};
if (tmp.flags.test(RealFlag::Overflow)) {
decrement = false;
@@ -79,7 +79,7 @@ static Expr<SomeReal> RealToIntBound(
if (tmp.flags.test(RealFlag::Inexact)) {
break;
} else if (!tmp.value.ToInteger(roundingMode, 8 * moldIKind)
- .flags.test(RealFlag::Overflow)) {
+ .flags.test(RealFlag::Overflow)) {
result = tmp.value;
}
}
@@ -129,7 +129,7 @@ static std::optional<std::pair<Expr<SomeReal>, Expr<SomeReal>>>
RealToRealBounds(int xRKind, int moldRKind) {
using RealType = Scalar<Type<TypeCategory::Real>>;
if (!RealType::Convert(RealType::HUGE(xRKind), moldRKind)
- .flags.test(RealFlag::Overflow)) {
+ .flags.test(RealFlag::Overflow)) {
return std::nullopt;
} else {
return std::make_pair(
diff --git a/flang/lib/Evaluate/real-value-impl.h b/flang/lib/Evaluate/real-value-impl.h
index 585ccf036..ce94415fa 100644
--- a/flang/lib/Evaluate/real-value-impl.h
+++ b/flang/lib/Evaluate/real-value-impl.h
@@ -165,8 +165,8 @@ public:
llvm::raw_ostream &o, int kind, bool minimal = false) const;
template <typename F>
- auto WithReal(
- F &&f) const -> decltype(std::declval<F>()(std::declval<R8>())) {
+ auto WithReal(F &&f) const
+ -> decltype(std::declval<F>()(std::declval<R8>())) {
switch (storage_.index()) {
case 1:
return f(std::get<R2>(storage_));
diff --git a/flang/lib/Evaluate/real-value.cpp b/flang/lib/Evaluate/real-value.cpp
index e4a511c59..654dca671 100644
--- a/flang/lib/Evaluate/real-value.cpp
+++ b/flang/lib/Evaluate/real-value.cpp
@@ -385,7 +385,8 @@ bool RealValueImpl::StoreRawBytes(void *to, std::size_t bytes) const {
std::min(bytes, static_cast<std::size_t>((bits() + 7) / 8))};
bool changed{raw.StoreRawBytes(to, kind())};
if (payloadBytes < bytes &&
- !std::all_of(static_cast<const char *>(to) + payloadBytes,
+ !std::all_of(
+ static_cast<const char *>(to) + payloadBytes,
static_cast<const char *>(to) + bytes,
[](char x) { return x == 0; })) {
std::memset(
diff --git a/flang/lib/Evaluate/tools.cpp b/flang/lib/Evaluate/tools.cpp
index 0ae7e1b6e..ad62a3040 100644
--- a/flang/lib/Evaluate/tools.cpp
+++ b/flang/lib/Evaluate/tools.cpp
@@ -1617,7 +1617,7 @@ static std::optional<Expr<SomeType>> DataConstantConversionHelper(
} else if constexpr (FROM == TypeCategory::Logical) {
values.emplace_back(value::IntegerValue::ConvertUnsigned(
elt.word(), 8 * kind)
- .value);
+ .value);
} else {
// Reinterpret the source element's bits as an integer of
// the destination kind (same numeric kind value).
diff --git a/flang/lib/Evaluate/variable.cpp b/flang/lib/Evaluate/variable.cpp
index 1000b7e3c..f32d3fa9f 100644
--- a/flang/lib/Evaluate/variable.cpp
+++ b/flang/lib/Evaluate/variable.cpp
@@ -673,7 +673,7 @@ std::optional<DynamicType> Designator<T>::GetType() const {
// The character kind is a runtime property carried by the designated
// entity rather than a compile-time template parameter.
int charKind{asciiKind};
- if (const Symbol * symbol{GetLastSymbol()}) {
+ if (const Symbol *symbol{GetLastSymbol()}) {
if (auto dt{DynamicType::From(*symbol)}) {
charKind = dt->kind();
}
diff --git a/flang/lib/Lower/ConvertConstant.cpp b/flang/lib/Lower/ConvertConstant.cpp
index 7e4e3519a..1b0712a45 100644
--- a/flang/lib/Lower/ConvertConstant.cpp
+++ b/flang/lib/Lower/ConvertConstant.cpp
@@ -377,8 +377,8 @@ genScalarLit(fir::FirOpBuilder &builder, mlir::Location loc,
if (!outlineInReadOnlyMemory)
return createStringLitOp(builder, loc, value, len);
- // Otherwise, the string is in a plain old expression so "outline" the value
- // in read only data by hash consing it to a constant literal object.
+ // Otherwise, the string is in a plain old expression so "outline" the value
+ // in read only data by hash consing it to a constant literal object.
#if 0
// ASCII global constants are created using an mlir string attribute.
diff --git a/flang/unittests/Evaluate/real.cpp b/flang/unittests/Evaluate/real.cpp
index 2b8a9da71..2394f8126 100644
--- a/flang/unittests/Evaluate/real.cpp
+++ b/flang/unittests/Evaluate/real.cpp
@@ -63,8 +63,7 @@ void dumpTest() {
};
for (int j{0}; table[j].expected != nullptr; ++j) {
TEST((Real4{Integer4{table[j].raw, 4}, 4}.DumpHexadecimal() ==
- table[j].expected))
- ("%d", j);
+ table[j].expected))("%d", j);
}
}
@@ -123,8 +122,8 @@ template <int KIND> void basicTests(int rm, Rounding rounding) {
MATCH(nan.Exponent(), maxExponent)(desc);
Word infWord{Word{maxExponent, KIND}.SHIFTL(significandBits)};
Word negInfWord{Word{maxExponent, KIND}
- .SHIFTL(significandBits)
- .IOR(Word::MASKL(1, kind))};
+ .SHIFTL(significandBits)
+ .IOR(Word::MASKL(1, kind))};
if constexpr (kind == 10) { // x87
infWord = infWord.IBSET(63);
negInfWord = negInfWord.IBSET(63);
``````````
</details>
https://github.com/llvm/llvm-project/pull/206907
More information about the flang-commits
mailing list