Skip to content

Commit 74d5c3c

Browse files
committed
[Flang] Run clang-format on all flang files
This will make it easier for me to do reviews. Differential Revision: https://reviews.llvm.org/D137291
1 parent 6f04011 commit 74d5c3c

27 files changed

+215
-209
lines changed

flang/include/flang/Frontend/CompilerInvocation.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ class CompilerInvocation : public CompilerInvocationBase {
9696

9797
bool warnAsErr = false;
9898

99-
/// This flag controls the unparsing and is used to decide whether to print out
100-
/// the semantically analyzed version of an object or expression or the plain
101-
/// version that does not include any information from semantic analysis.
99+
/// This flag controls the unparsing and is used to decide whether to print
100+
/// out the semantically analyzed version of an object or expression or the
101+
/// plain version that does not include any information from semantic
102+
/// analysis.
102103
bool useAnalyzedObjectsForUnparse = true;
103104

104105
// Fortran Dialect options

flang/include/flang/Frontend/FrontendAction.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ class FrontendAction {
135135
}
136136

137137
private:
138-
template <unsigned N> bool reportFatalErrors(const char (&message)[N]);
138+
template <unsigned N>
139+
bool reportFatalErrors(const char (&message)[N]);
139140
};
140141

141142
} // namespace Fortran::frontend

flang/include/flang/Frontend/FrontendActions.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ namespace Fortran::frontend {
2929
// TODO: This is a copy from f18.cpp. It doesn't really belong here and should
3030
// be moved to a more suitable place in future.
3131
struct MeasurementVisitor {
32-
template <typename A> bool Pre(const A &) { return true; }
33-
template <typename A> void Post(const A &) {
32+
template <typename A>
33+
bool Pre(const A &) {
34+
return true;
35+
}
36+
template <typename A>
37+
void Post(const A &) {
3438
++objects;
3539
bytes += sizeof(A);
3640
}
@@ -148,8 +152,8 @@ class PluginParseTreeAction : public PrescanAndSemaAction {
148152
/// \param extension The extension to use for the output file (ignored when
149153
/// the user decides to print to stdout via `-o -`)
150154
/// \return Null on error, ostream for the output file otherwise
151-
std::unique_ptr<llvm::raw_pwrite_stream> createOutputFile(
152-
llvm::StringRef extension);
155+
std::unique_ptr<llvm::raw_pwrite_stream>
156+
createOutputFile(llvm::StringRef extension);
153157
};
154158

155159
//===----------------------------------------------------------------------===//
@@ -184,10 +188,10 @@ class DebugDumpAllAction : public PrescanAndSemaDebugAction {
184188
/// maintain some level of consistency/similarity between the drivers.
185189
enum class BackendActionTy {
186190
Backend_EmitAssembly, ///< Emit native assembly files
187-
Backend_EmitObj, ///< Emit native object files
188-
Backend_EmitBC, ///< Emit LLVM bitcode files
189-
Backend_EmitLL, ///< Emit human-readable LLVM assembly
190-
Backend_EmitMLIR ///< Emit MLIR files
191+
Backend_EmitObj, ///< Emit native object files
192+
Backend_EmitBC, ///< Emit LLVM bitcode files
193+
Backend_EmitLL, ///< Emit human-readable LLVM assembly
194+
Backend_EmitMLIR ///< Emit MLIR files
191195
};
192196

193197
/// Abstract base class for actions that generate code (MLIR, LLVM IR, assembly

flang/include/flang/Frontend/TextDiagnosticBuffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class TextDiagnosticBuffer : public clang::DiagnosticConsumer {
4545

4646
public:
4747
void HandleDiagnostic(clang::DiagnosticsEngine::Level diagLevel,
48-
const clang::Diagnostic &info) override;
48+
const clang::Diagnostic &info) override;
4949

5050
/// Flush the buffered diagnostics to a given diagnostic engine.
5151
void flushDiagnostics(clang::DiagnosticsEngine &diags) const;

flang/include/flang/Frontend/TextDiagnosticPrinter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class TextDiagnosticPrinter : public clang::DiagnosticConsumer {
5151
void setPrefix(std::string value) { prefix = std::move(value); }
5252

5353
void HandleDiagnostic(clang::DiagnosticsEngine::Level level,
54-
const clang::Diagnostic &info) override;
54+
const clang::Diagnostic &info) override;
5555
};
5656

5757
} // namespace Fortran::frontend

flang/include/flang/Optimizer/Builder/Runtime/Derived.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Location;
1717
namespace fir {
1818
class FirOpBuilder;
1919
class RecordType;
20-
}
20+
} // namespace fir
2121

2222
namespace fir::runtime {
2323

flang/include/flang/Semantics/symbol.h

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -625,28 +625,27 @@ class Symbol {
625625
bool IsSubprogram() const;
626626
bool IsFromModFile() const;
627627
bool HasExplicitInterface() const {
628-
return common::visit(common::visitors{
629-
[](const SubprogramDetails &) { return true; },
630-
[](const SubprogramNameDetails &) { return true; },
631-
[&](const ProcEntityDetails &x) {
632-
return attrs_.test(Attr::INTRINSIC) ||
633-
x.HasExplicitInterface();
634-
},
635-
[](const ProcBindingDetails &x) {
636-
return x.symbol().HasExplicitInterface();
637-
},
638-
[](const UseDetails &x) {
639-
return x.symbol().HasExplicitInterface();
640-
},
641-
[](const HostAssocDetails &x) {
642-
return x.symbol().HasExplicitInterface();
643-
},
644-
[](const GenericDetails &x) {
645-
return x.specific() &&
646-
x.specific()->HasExplicitInterface();
647-
},
648-
[](const auto &) { return false; },
649-
},
628+
return common::visit(
629+
common::visitors{
630+
[](const SubprogramDetails &) { return true; },
631+
[](const SubprogramNameDetails &) { return true; },
632+
[&](const ProcEntityDetails &x) {
633+
return attrs_.test(Attr::INTRINSIC) || x.HasExplicitInterface();
634+
},
635+
[](const ProcBindingDetails &x) {
636+
return x.symbol().HasExplicitInterface();
637+
},
638+
[](const UseDetails &x) {
639+
return x.symbol().HasExplicitInterface();
640+
},
641+
[](const HostAssocDetails &x) {
642+
return x.symbol().HasExplicitInterface();
643+
},
644+
[](const GenericDetails &x) {
645+
return x.specific() && x.specific()->HasExplicitInterface();
646+
},
647+
[](const auto &) { return false; },
648+
},
650649
details_);
651650
}
652651

flang/lib/Evaluate/characteristics.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,7 @@ static std::optional<Procedure> CharacterizeProcedure(
506506
}
507507
return intrinsic;
508508
}
509-
const semantics::ProcInterface &interface {
510-
proc.interface()
511-
};
509+
const semantics::ProcInterface &interface { proc.interface() };
512510
if (const semantics::Symbol * interfaceSymbol{interface.symbol()}) {
513511
auto interface {
514512
CharacterizeProcedure(*interfaceSymbol, context, seenProcs)

flang/lib/Evaluate/fold-integer.cpp

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -763,20 +763,20 @@ Expr<Type<TypeCategory::Integer, KIND>> FoldIntrinsicFunction(
763763
context, std::move(funcRef), &Scalar<T>::IEOR, Scalar<T>{});
764764
} else if (name == "ishft") {
765765
return FoldElementalIntrinsic<T, T, Int4>(context, std::move(funcRef),
766-
ScalarFunc<T, T, Int4>([&](const Scalar<T> &i,
767-
const Scalar<Int4> &pos) -> Scalar<T> {
768-
auto posVal{static_cast<int>(pos.ToInt64())};
769-
if (posVal < -i.bits) {
770-
context.messages().Say(
771-
"SHIFT=%d count for ishft is less than %d"_err_en_US, posVal,
772-
-i.bits);
773-
} else if (posVal > i.bits) {
774-
context.messages().Say(
775-
"SHIFT=%d count for ishft is greater than %d"_err_en_US, posVal,
776-
i.bits);
777-
}
778-
return i.ISHFT(posVal);
779-
}));
766+
ScalarFunc<T, T, Int4>(
767+
[&](const Scalar<T> &i, const Scalar<Int4> &pos) -> Scalar<T> {
768+
auto posVal{static_cast<int>(pos.ToInt64())};
769+
if (posVal < -i.bits) {
770+
context.messages().Say(
771+
"SHIFT=%d count for ishft is less than %d"_err_en_US,
772+
posVal, -i.bits);
773+
} else if (posVal > i.bits) {
774+
context.messages().Say(
775+
"SHIFT=%d count for ishft is greater than %d"_err_en_US,
776+
posVal, i.bits);
777+
}
778+
return i.ISHFT(posVal);
779+
}));
780780
} else if (name == "ishftc") {
781781
if (args.at(2)) { // SIZE= is present
782782
return FoldElementalIntrinsic<T, T, Int4, Int4>(context,
@@ -940,16 +940,15 @@ Expr<Type<TypeCategory::Integer, KIND>> FoldIntrinsicFunction(
940940
}));
941941
} else if (name == "modulo") {
942942
return FoldElementalIntrinsic<T, T, T>(context, std::move(funcRef),
943-
ScalarFuncWithContext<T, T, T>(
944-
[](FoldingContext &context, const Scalar<T> &x,
945-
const Scalar<T> &y) -> Scalar<T> {
946-
auto result{x.MODULO(y)};
947-
if (result.overflow) {
948-
context.messages().Say(
949-
"modulo() folding overflowed"_warn_en_US);
950-
}
951-
return result.value;
952-
}));
943+
ScalarFuncWithContext<T, T, T>([](FoldingContext &context,
944+
const Scalar<T> &x,
945+
const Scalar<T> &y) -> Scalar<T> {
946+
auto result{x.MODULO(y)};
947+
if (result.overflow) {
948+
context.messages().Say("modulo() folding overflowed"_warn_en_US);
949+
}
950+
return result.value;
951+
}));
953952
} else if (name == "not") {
954953
return FoldElementalIntrinsic<T, T>(
955954
context, std::move(funcRef), &Scalar<T>::NOT);
@@ -1062,16 +1061,15 @@ Expr<Type<TypeCategory::Integer, KIND>> FoldIntrinsicFunction(
10621061
}));
10631062
} else if (name == "sign") {
10641063
return FoldElementalIntrinsic<T, T, T>(context, std::move(funcRef),
1065-
ScalarFunc<T, T, T>(
1066-
[&context](const Scalar<T> &j, const Scalar<T> &k) -> Scalar<T> {
1067-
typename Scalar<T>::ValueWithOverflow result{j.SIGN(k)};
1068-
if (result.overflow) {
1069-
context.messages().Say(
1070-
"sign(integer(kind=%d)) folding overflowed"_warn_en_US,
1071-
KIND);
1072-
}
1073-
return result.value;
1074-
}));
1064+
ScalarFunc<T, T, T>([&context](const Scalar<T> &j,
1065+
const Scalar<T> &k) -> Scalar<T> {
1066+
typename Scalar<T>::ValueWithOverflow result{j.SIGN(k)};
1067+
if (result.overflow) {
1068+
context.messages().Say(
1069+
"sign(integer(kind=%d)) folding overflowed"_warn_en_US, KIND);
1070+
}
1071+
return result.value;
1072+
}));
10751073
} else if (name == "size") {
10761074
if (auto shape{GetContextFreeShape(context, args[0])}) {
10771075
if (auto &dimArg{args[1]}) { // DIM= is present, get one extent

flang/lib/Evaluate/fold-real.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ Expr<Type<TypeCategory::Real, KIND>> FoldIntrinsicFunction(
127127
? common::RoundingMode::ToZero
128128
: common::RoundingMode::TiesAwayFromZero};
129129
return FoldElementalIntrinsic<T, T>(context, std::move(funcRef),
130-
ScalarFunc<T, T>([&name, &context, mode](
131-
const Scalar<T> &x) -> Scalar<T> {
132-
ValueWithRealFlags<Scalar<T>> y{x.ToWholeNumber(mode)};
133-
if (y.flags.test(RealFlag::Overflow)) {
134-
context.messages().Say(
135-
"%s intrinsic folding overflow"_warn_en_US, name);
136-
}
137-
return y.value;
138-
}));
130+
ScalarFunc<T, T>(
131+
[&name, &context, mode](const Scalar<T> &x) -> Scalar<T> {
132+
ValueWithRealFlags<Scalar<T>> y{x.ToWholeNumber(mode)};
133+
if (y.flags.test(RealFlag::Overflow)) {
134+
context.messages().Say(
135+
"%s intrinsic folding overflow"_warn_en_US, name);
136+
}
137+
return y.value;
138+
}));
139139
} else if (name == "dim") {
140140
return FoldElementalIntrinsic<T, T, T>(context, std::move(funcRef),
141141
ScalarFunc<T, T, T>(

0 commit comments

Comments
 (0)