[flang-commits] [flang] 74d5c3c - [Flang] Run clang-format on all flang files
Peter Steinfeld via flang-commits
flang-commits at lists.llvm.org
Thu Nov 3 09:26:39 PDT 2022
Author: Peter Steinfeld
Date: 2022-11-03T09:26:22-07:00
New Revision: 74d5c3c0f078bf88b2462e05fa52c2ec1ce11b48
URL: https://github.com/llvm/llvm-project/commit/74d5c3c0f078bf88b2462e05fa52c2ec1ce11b48
DIFF: https://github.com/llvm/llvm-project/commit/74d5c3c0f078bf88b2462e05fa52c2ec1ce11b48.diff
LOG: [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
Added:
Modified:
flang/include/flang/Frontend/CompilerInvocation.h
flang/include/flang/Frontend/FrontendAction.h
flang/include/flang/Frontend/FrontendActions.h
flang/include/flang/Frontend/TextDiagnosticBuffer.h
flang/include/flang/Frontend/TextDiagnosticPrinter.h
flang/include/flang/Optimizer/Builder/Runtime/Derived.h
flang/include/flang/Semantics/symbol.h
flang/lib/Evaluate/characteristics.cpp
flang/lib/Evaluate/fold-integer.cpp
flang/lib/Evaluate/fold-real.cpp
flang/lib/Frontend/CompilerInstance.cpp
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendOptions.cpp
flang/lib/Frontend/TextDiagnosticPrinter.cpp
flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
flang/lib/Optimizer/Builder/MutableBox.cpp
flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
flang/lib/Semantics/check-acc-structure.h
flang/lib/Semantics/check-declarations.cpp
flang/lib/Semantics/data-to-inits.h
flang/lib/Semantics/expression.cpp
flang/lib/Semantics/mod-file.cpp
flang/lib/Semantics/symbol.cpp
flang/lib/Semantics/tools.cpp
flang/tools/flang-driver/driver.cpp
flang/unittests/Optimizer/FIRContextTest.cpp
flang/unittests/Runtime/Time.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Frontend/CompilerInvocation.h b/flang/include/flang/Frontend/CompilerInvocation.h
index a5895451bb74a..58479c8418515 100644
--- a/flang/include/flang/Frontend/CompilerInvocation.h
+++ b/flang/include/flang/Frontend/CompilerInvocation.h
@@ -96,9 +96,10 @@ class CompilerInvocation : public CompilerInvocationBase {
bool warnAsErr = false;
- /// This flag controls the unparsing and is used to decide whether to print out
- /// the semantically analyzed version of an object or expression or the plain
- /// version that does not include any information from semantic analysis.
+ /// This flag controls the unparsing and is used to decide whether to print
+ /// out the semantically analyzed version of an object or expression or the
+ /// plain version that does not include any information from semantic
+ /// analysis.
bool useAnalyzedObjectsForUnparse = true;
// Fortran Dialect options
diff --git a/flang/include/flang/Frontend/FrontendAction.h b/flang/include/flang/Frontend/FrontendAction.h
index e6e268c875e80..266050084f4c0 100644
--- a/flang/include/flang/Frontend/FrontendAction.h
+++ b/flang/include/flang/Frontend/FrontendAction.h
@@ -135,7 +135,8 @@ class FrontendAction {
}
private:
- template <unsigned N> bool reportFatalErrors(const char (&message)[N]);
+ template <unsigned N>
+ bool reportFatalErrors(const char (&message)[N]);
};
} // namespace Fortran::frontend
diff --git a/flang/include/flang/Frontend/FrontendActions.h b/flang/include/flang/Frontend/FrontendActions.h
index 3f50d320c1f3b..eb9dda75c516c 100644
--- a/flang/include/flang/Frontend/FrontendActions.h
+++ b/flang/include/flang/Frontend/FrontendActions.h
@@ -29,8 +29,12 @@ namespace Fortran::frontend {
// TODO: This is a copy from f18.cpp. It doesn't really belong here and should
// be moved to a more suitable place in future.
struct MeasurementVisitor {
- template <typename A> bool Pre(const A &) { return true; }
- template <typename A> void Post(const A &) {
+ template <typename A>
+ bool Pre(const A &) {
+ return true;
+ }
+ template <typename A>
+ void Post(const A &) {
++objects;
bytes += sizeof(A);
}
@@ -148,8 +152,8 @@ class PluginParseTreeAction : public PrescanAndSemaAction {
/// \param extension The extension to use for the output file (ignored when
/// the user decides to print to stdout via `-o -`)
/// \return Null on error, ostream for the output file otherwise
- std::unique_ptr<llvm::raw_pwrite_stream> createOutputFile(
- llvm::StringRef extension);
+ std::unique_ptr<llvm::raw_pwrite_stream>
+ createOutputFile(llvm::StringRef extension);
};
//===----------------------------------------------------------------------===//
@@ -184,10 +188,10 @@ class DebugDumpAllAction : public PrescanAndSemaDebugAction {
/// maintain some level of consistency/similarity between the drivers.
enum class BackendActionTy {
Backend_EmitAssembly, ///< Emit native assembly files
- Backend_EmitObj, ///< Emit native object files
- Backend_EmitBC, ///< Emit LLVM bitcode files
- Backend_EmitLL, ///< Emit human-readable LLVM assembly
- Backend_EmitMLIR ///< Emit MLIR files
+ Backend_EmitObj, ///< Emit native object files
+ Backend_EmitBC, ///< Emit LLVM bitcode files
+ Backend_EmitLL, ///< Emit human-readable LLVM assembly
+ Backend_EmitMLIR ///< Emit MLIR files
};
/// Abstract base class for actions that generate code (MLIR, LLVM IR, assembly
diff --git a/flang/include/flang/Frontend/TextDiagnosticBuffer.h b/flang/include/flang/Frontend/TextDiagnosticBuffer.h
index fb1028a36ea35..7eba843661328 100644
--- a/flang/include/flang/Frontend/TextDiagnosticBuffer.h
+++ b/flang/include/flang/Frontend/TextDiagnosticBuffer.h
@@ -45,7 +45,7 @@ class TextDiagnosticBuffer : public clang::DiagnosticConsumer {
public:
void HandleDiagnostic(clang::DiagnosticsEngine::Level diagLevel,
- const clang::Diagnostic &info) override;
+ const clang::Diagnostic &info) override;
/// Flush the buffered diagnostics to a given diagnostic engine.
void flushDiagnostics(clang::DiagnosticsEngine &diags) const;
diff --git a/flang/include/flang/Frontend/TextDiagnosticPrinter.h b/flang/include/flang/Frontend/TextDiagnosticPrinter.h
index 3e6e6a1977d1d..0e092a0a012e0 100644
--- a/flang/include/flang/Frontend/TextDiagnosticPrinter.h
+++ b/flang/include/flang/Frontend/TextDiagnosticPrinter.h
@@ -51,7 +51,7 @@ class TextDiagnosticPrinter : public clang::DiagnosticConsumer {
void setPrefix(std::string value) { prefix = std::move(value); }
void HandleDiagnostic(clang::DiagnosticsEngine::Level level,
- const clang::Diagnostic &info) override;
+ const clang::Diagnostic &info) override;
};
} // namespace Fortran::frontend
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/Derived.h b/flang/include/flang/Optimizer/Builder/Runtime/Derived.h
index 816d561d38913..239eab1d4e418 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/Derived.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/Derived.h
@@ -17,7 +17,7 @@ class Location;
namespace fir {
class FirOpBuilder;
class RecordType;
-}
+} // namespace fir
namespace fir::runtime {
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index 9c3c22ca8ad32..ad01b1235c537 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -625,28 +625,27 @@ class Symbol {
bool IsSubprogram() const;
bool IsFromModFile() const;
bool HasExplicitInterface() const {
- return common::visit(common::visitors{
- [](const SubprogramDetails &) { return true; },
- [](const SubprogramNameDetails &) { return true; },
- [&](const ProcEntityDetails &x) {
- return attrs_.test(Attr::INTRINSIC) ||
- x.HasExplicitInterface();
- },
- [](const ProcBindingDetails &x) {
- return x.symbol().HasExplicitInterface();
- },
- [](const UseDetails &x) {
- return x.symbol().HasExplicitInterface();
- },
- [](const HostAssocDetails &x) {
- return x.symbol().HasExplicitInterface();
- },
- [](const GenericDetails &x) {
- return x.specific() &&
- x.specific()->HasExplicitInterface();
- },
- [](const auto &) { return false; },
- },
+ return common::visit(
+ common::visitors{
+ [](const SubprogramDetails &) { return true; },
+ [](const SubprogramNameDetails &) { return true; },
+ [&](const ProcEntityDetails &x) {
+ return attrs_.test(Attr::INTRINSIC) || x.HasExplicitInterface();
+ },
+ [](const ProcBindingDetails &x) {
+ return x.symbol().HasExplicitInterface();
+ },
+ [](const UseDetails &x) {
+ return x.symbol().HasExplicitInterface();
+ },
+ [](const HostAssocDetails &x) {
+ return x.symbol().HasExplicitInterface();
+ },
+ [](const GenericDetails &x) {
+ return x.specific() && x.specific()->HasExplicitInterface();
+ },
+ [](const auto &) { return false; },
+ },
details_);
}
diff --git a/flang/lib/Evaluate/characteristics.cpp b/flang/lib/Evaluate/characteristics.cpp
index cf43bab6a5eb7..1795751fbf045 100644
--- a/flang/lib/Evaluate/characteristics.cpp
+++ b/flang/lib/Evaluate/characteristics.cpp
@@ -506,9 +506,7 @@ static std::optional<Procedure> CharacterizeProcedure(
}
return intrinsic;
}
- const semantics::ProcInterface &interface {
- proc.interface()
- };
+ const semantics::ProcInterface &interface { proc.interface() };
if (const semantics::Symbol * interfaceSymbol{interface.symbol()}) {
auto interface {
CharacterizeProcedure(*interfaceSymbol, context, seenProcs)
diff --git a/flang/lib/Evaluate/fold-integer.cpp b/flang/lib/Evaluate/fold-integer.cpp
index bc4bd3b19ea21..603c4a46f9b52 100644
--- a/flang/lib/Evaluate/fold-integer.cpp
+++ b/flang/lib/Evaluate/fold-integer.cpp
@@ -763,20 +763,20 @@ Expr<Type<TypeCategory::Integer, KIND>> FoldIntrinsicFunction(
context, std::move(funcRef), &Scalar<T>::IEOR, Scalar<T>{});
} else if (name == "ishft") {
return FoldElementalIntrinsic<T, T, Int4>(context, std::move(funcRef),
- ScalarFunc<T, T, Int4>([&](const Scalar<T> &i,
- const Scalar<Int4> &pos) -> Scalar<T> {
- auto posVal{static_cast<int>(pos.ToInt64())};
- if (posVal < -i.bits) {
- context.messages().Say(
- "SHIFT=%d count for ishft is less than %d"_err_en_US, posVal,
- -i.bits);
- } else if (posVal > i.bits) {
- context.messages().Say(
- "SHIFT=%d count for ishft is greater than %d"_err_en_US, posVal,
- i.bits);
- }
- return i.ISHFT(posVal);
- }));
+ ScalarFunc<T, T, Int4>(
+ [&](const Scalar<T> &i, const Scalar<Int4> &pos) -> Scalar<T> {
+ auto posVal{static_cast<int>(pos.ToInt64())};
+ if (posVal < -i.bits) {
+ context.messages().Say(
+ "SHIFT=%d count for ishft is less than %d"_err_en_US,
+ posVal, -i.bits);
+ } else if (posVal > i.bits) {
+ context.messages().Say(
+ "SHIFT=%d count for ishft is greater than %d"_err_en_US,
+ posVal, i.bits);
+ }
+ return i.ISHFT(posVal);
+ }));
} else if (name == "ishftc") {
if (args.at(2)) { // SIZE= is present
return FoldElementalIntrinsic<T, T, Int4, Int4>(context,
@@ -940,16 +940,15 @@ Expr<Type<TypeCategory::Integer, KIND>> FoldIntrinsicFunction(
}));
} else if (name == "modulo") {
return FoldElementalIntrinsic<T, T, T>(context, std::move(funcRef),
- ScalarFuncWithContext<T, T, T>(
- [](FoldingContext &context, const Scalar<T> &x,
- const Scalar<T> &y) -> Scalar<T> {
- auto result{x.MODULO(y)};
- if (result.overflow) {
- context.messages().Say(
- "modulo() folding overflowed"_warn_en_US);
- }
- return result.value;
- }));
+ ScalarFuncWithContext<T, T, T>([](FoldingContext &context,
+ const Scalar<T> &x,
+ const Scalar<T> &y) -> Scalar<T> {
+ auto result{x.MODULO(y)};
+ if (result.overflow) {
+ context.messages().Say("modulo() folding overflowed"_warn_en_US);
+ }
+ return result.value;
+ }));
} else if (name == "not") {
return FoldElementalIntrinsic<T, T>(
context, std::move(funcRef), &Scalar<T>::NOT);
@@ -1062,16 +1061,15 @@ Expr<Type<TypeCategory::Integer, KIND>> FoldIntrinsicFunction(
}));
} else if (name == "sign") {
return FoldElementalIntrinsic<T, T, T>(context, std::move(funcRef),
- ScalarFunc<T, T, T>(
- [&context](const Scalar<T> &j, const Scalar<T> &k) -> Scalar<T> {
- typename Scalar<T>::ValueWithOverflow result{j.SIGN(k)};
- if (result.overflow) {
- context.messages().Say(
- "sign(integer(kind=%d)) folding overflowed"_warn_en_US,
- KIND);
- }
- return result.value;
- }));
+ ScalarFunc<T, T, T>([&context](const Scalar<T> &j,
+ const Scalar<T> &k) -> Scalar<T> {
+ typename Scalar<T>::ValueWithOverflow result{j.SIGN(k)};
+ if (result.overflow) {
+ context.messages().Say(
+ "sign(integer(kind=%d)) folding overflowed"_warn_en_US, KIND);
+ }
+ return result.value;
+ }));
} else if (name == "size") {
if (auto shape{GetContextFreeShape(context, args[0])}) {
if (auto &dimArg{args[1]}) { // DIM= is present, get one extent
diff --git a/flang/lib/Evaluate/fold-real.cpp b/flang/lib/Evaluate/fold-real.cpp
index 38ece3f21edd2..ef90d12446454 100644
--- a/flang/lib/Evaluate/fold-real.cpp
+++ b/flang/lib/Evaluate/fold-real.cpp
@@ -127,15 +127,15 @@ Expr<Type<TypeCategory::Real, KIND>> FoldIntrinsicFunction(
? common::RoundingMode::ToZero
: common::RoundingMode::TiesAwayFromZero};
return FoldElementalIntrinsic<T, T>(context, std::move(funcRef),
- ScalarFunc<T, T>([&name, &context, mode](
- const Scalar<T> &x) -> Scalar<T> {
- ValueWithRealFlags<Scalar<T>> y{x.ToWholeNumber(mode)};
- if (y.flags.test(RealFlag::Overflow)) {
- context.messages().Say(
- "%s intrinsic folding overflow"_warn_en_US, name);
- }
- return y.value;
- }));
+ ScalarFunc<T, T>(
+ [&name, &context, mode](const Scalar<T> &x) -> Scalar<T> {
+ ValueWithRealFlags<Scalar<T>> y{x.ToWholeNumber(mode)};
+ if (y.flags.test(RealFlag::Overflow)) {
+ context.messages().Say(
+ "%s intrinsic folding overflow"_warn_en_US, name);
+ }
+ return y.value;
+ }));
} else if (name == "dim") {
return FoldElementalIntrinsic<T, T, T>(context, std::move(funcRef),
ScalarFunc<T, T, T>(
diff --git a/flang/lib/Frontend/CompilerInstance.cpp b/flang/lib/Frontend/CompilerInstance.cpp
index 951b8d179bed0..0d01608434618 100644
--- a/flang/lib/Frontend/CompilerInstance.cpp
+++ b/flang/lib/Frontend/CompilerInstance.cpp
@@ -117,7 +117,8 @@ CompilerInstance::createOutputFileImpl(llvm::StringRef outputFilePath,
std::unique_ptr<llvm::raw_fd_ostream> os;
std::error_code error;
- os.reset(new llvm::raw_fd_ostream(outputFilePath, error,
+ os.reset(new llvm::raw_fd_ostream(
+ outputFilePath, error,
(binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_TextWithCRLF)));
if (error) {
return llvm::errorCodeToError(error);
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 10c73169d0d02..252e1a7e697a5 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -379,12 +379,13 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
}
// Set fortranForm based on options -ffree-form and -ffixed-form.
- if (const auto *arg = args.getLastArg(clang::driver::options::OPT_ffixed_form,
- clang::driver::options::OPT_ffree_form)) {
+ if (const auto *arg =
+ args.getLastArg(clang::driver::options::OPT_ffixed_form,
+ clang::driver::options::OPT_ffree_form)) {
opts.fortranForm =
arg->getOption().matches(clang::driver::options::OPT_ffixed_form)
- ? FortranForm::FixedForm
- : FortranForm::FreeForm;
+ ? FortranForm::FixedForm
+ : FortranForm::FreeForm;
}
// Set fixedFormColumns based on -ffixed-line-length=<value>
@@ -425,22 +426,26 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
opts.features.Enable(
Fortran::common::LanguageFeature::ImplicitNoneTypeAlways,
args.hasFlag(clang::driver::options::OPT_fimplicit_none,
- clang::driver::options::OPT_fno_implicit_none, false));
+ clang::driver::options::OPT_fno_implicit_none, false));
// -f{no-}backslash
opts.features.Enable(Fortran::common::LanguageFeature::BackslashEscapes,
- args.hasFlag(clang::driver::options::OPT_fbackslash,
- clang::driver::options::OPT_fno_backslash, false));
+ args.hasFlag(clang::driver::options::OPT_fbackslash,
+ clang::driver::options::OPT_fno_backslash,
+ false));
// -f{no-}logical-abbreviations
- opts.features.Enable(Fortran::common::LanguageFeature::LogicalAbbreviations,
+ opts.features.Enable(
+ Fortran::common::LanguageFeature::LogicalAbbreviations,
args.hasFlag(clang::driver::options::OPT_flogical_abbreviations,
- clang::driver::options::OPT_fno_logical_abbreviations, false));
+ clang::driver::options::OPT_fno_logical_abbreviations,
+ false));
// -f{no-}xor-operator
- opts.features.Enable(Fortran::common::LanguageFeature::XOROperator,
+ opts.features.Enable(
+ Fortran::common::LanguageFeature::XOROperator,
args.hasFlag(clang::driver::options::OPT_fxor_operator,
- clang::driver::options::OPT_fno_xor_operator, false));
+ clang::driver::options::OPT_fno_xor_operator, false));
// -fno-automatic
if (args.hasArg(clang::driver::options::OPT_fno_automatic)) {
@@ -494,11 +499,11 @@ static std::string getOpenMPHeadersDir() {
///
/// \param [in] opts The preprocessor options instance
/// \param [out] args The list of input arguments
-static void parsePreprocessorArgs(
- Fortran::frontend::PreprocessorOptions &opts, llvm::opt::ArgList &args) {
+static void parsePreprocessorArgs(Fortran::frontend::PreprocessorOptions &opts,
+ llvm::opt::ArgList &args) {
// Add macros from the command line.
- for (const auto *currentArg : args.filtered(
- clang::driver::options::OPT_D, clang::driver::options::OPT_U)) {
+ for (const auto *currentArg : args.filtered(clang::driver::options::OPT_D,
+ clang::driver::options::OPT_U)) {
if (currentArg->getOption().matches(clang::driver::options::OPT_D)) {
opts.addMacroDef(currentArg->getValue());
} else {
@@ -513,7 +518,7 @@ static void parsePreprocessorArgs(
// Prepend the ordered list of -intrinsic-modules-path
// to the default location to search.
for (const auto *currentArg :
- args.filtered(clang::driver::options::OPT_fintrinsic_modules_path))
+ args.filtered(clang::driver::options::OPT_fintrinsic_modules_path))
opts.searchDirectoriesFromIntrModPath.emplace_back(currentArg->getValue());
// -cpp/-nocpp
@@ -521,8 +526,8 @@ static void parsePreprocessorArgs(
clang::driver::options::OPT_cpp, clang::driver::options::OPT_nocpp))
opts.macrosFlag =
(currentArg->getOption().matches(clang::driver::options::OPT_cpp))
- ? PPMacrosFlag::Include
- : PPMacrosFlag::Exclude;
+ ? PPMacrosFlag::Include
+ : PPMacrosFlag::Exclude;
opts.noReformat = args.hasArg(clang::driver::options::OPT_fno_reformat);
opts.noLineDirectives = args.hasArg(clang::driver::options::OPT_P);
@@ -531,7 +536,7 @@ static void parsePreprocessorArgs(
/// Parses all semantic related arguments and populates the variables
/// options accordingly. Returns false if new errors are generated.
static bool parseSemaArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
- clang::DiagnosticsEngine &diags) {
+ clang::DiagnosticsEngine &diags) {
unsigned numErrorsBefore = diags.getNumErrors();
// -J/module-dir option
@@ -542,7 +547,7 @@ static bool parseSemaArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
if (moduleDirList.size() > 1) {
const unsigned diagID =
diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
- "Only one '-module-dir/-J' option allowed");
+ "Only one '-module-dir/-J' option allowed");
diags.Report(diagID);
}
if (moduleDirList.size() == 1)
@@ -570,7 +575,7 @@ static bool parseSemaArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
/// Parses all diagnostics related arguments and populates the variables
/// options accordingly. Returns false if new errors are generated.
static bool parseDiagArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
- clang::DiagnosticsEngine &diags) {
+ clang::DiagnosticsEngine &diags) {
unsigned numErrorsBefore = diags.getNumErrors();
// -Werror option
@@ -583,7 +588,7 @@ static bool parseDiagArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
} else {
const unsigned diagID =
diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
- "Only `-Werror` is supported currently.");
+ "Only `-Werror` is supported currently.");
diags.Report(diagID);
}
}
@@ -598,7 +603,7 @@ static bool parseDiagArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
/// Parses all Dialect related arguments and populates the variables
/// options accordingly. Returns false if new errors are generated.
static bool parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
- clang::DiagnosticsEngine &diags) {
+ clang::DiagnosticsEngine &diags) {
unsigned numErrorsBefore = diags.getNumErrors();
// -fdefault* family
@@ -615,9 +620,9 @@ static bool parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
if (!args.hasArg(clang::driver::options::OPT_fdefault_real_8)) {
// -fdefault-double-8 has to be used with -fdefault-real-8
// to be compatible with gfortran
- const unsigned diagID =
- diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
- "Use of `-fdefault-double-8` requires `-fdefault-real-8`");
+ const unsigned diagID = diags.getCustomDiagID(
+ clang::DiagnosticsEngine::Error,
+ "Use of `-fdefault-double-8` requires `-fdefault-real-8`");
diags.Report(diagID);
}
// https://gcc.gnu.org/onlinedocs/gfortran/Fortran-Dialect-Options.html
@@ -651,7 +656,7 @@ static bool parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
} else {
const unsigned diagID =
diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
- "Only -std=f2018 is allowed currently.");
+ "Only -std=f2018 is allowed currently.");
diags.Report(diagID);
}
}
@@ -812,12 +817,12 @@ void CompilerInvocation::setDefaultPredefinitions() {
// Populate the macro list with version numbers and other predefinitions.
fortranOptions.predefinitions.emplace_back("__flang__", "1");
- fortranOptions.predefinitions.emplace_back(
- "__flang_major__", FLANG_VERSION_MAJOR_STRING);
- fortranOptions.predefinitions.emplace_back(
- "__flang_minor__", FLANG_VERSION_MINOR_STRING);
- fortranOptions.predefinitions.emplace_back(
- "__flang_patchlevel__", FLANG_VERSION_PATCHLEVEL_STRING);
+ fortranOptions.predefinitions.emplace_back("__flang_major__",
+ FLANG_VERSION_MAJOR_STRING);
+ fortranOptions.predefinitions.emplace_back("__flang_minor__",
+ FLANG_VERSION_MINOR_STRING);
+ fortranOptions.predefinitions.emplace_back("__flang_patchlevel__",
+ FLANG_VERSION_PATCHLEVEL_STRING);
// Add predefinitions based on extensions enabled
if (frontendOptions.features.IsEnabled(
diff --git a/flang/lib/Frontend/FrontendOptions.cpp b/flang/lib/Frontend/FrontendOptions.cpp
index 8353858ff5094..504fac6cd6fb9 100644
--- a/flang/lib/Frontend/FrontendOptions.cpp
+++ b/flang/lib/Frontend/FrontendOptions.cpp
@@ -17,22 +17,23 @@ using namespace Fortran::frontend;
bool Fortran::frontend::isFixedFormSuffix(llvm::StringRef suffix) {
// Note: Keep this list in-sync with flang/test/lit.cfg.py
return suffix == "f77" || suffix == "f" || suffix == "F" || suffix == "ff" ||
- suffix == "for" || suffix == "FOR" || suffix == "fpp" || suffix == "FPP";
+ suffix == "for" || suffix == "FOR" || suffix == "fpp" ||
+ suffix == "FPP";
}
bool Fortran::frontend::isFreeFormSuffix(llvm::StringRef suffix) {
// Note: Keep this list in-sync with flang/test/lit.cfg.py
// TODO: Add Cuda Fortan files (i.e. `*.cuf` and `*.CUF`).
return suffix == "f90" || suffix == "F90" || suffix == "ff90" ||
- suffix == "f95" || suffix == "F95" || suffix == "ff95" ||
- suffix == "f03" || suffix == "F03" || suffix == "f08" ||
- suffix == "F08" || suffix == "f18" || suffix == "F18";
+ suffix == "f95" || suffix == "F95" || suffix == "ff95" ||
+ suffix == "f03" || suffix == "F03" || suffix == "f08" ||
+ suffix == "F08" || suffix == "f18" || suffix == "F18";
}
bool Fortran::frontend::isToBePreprocessed(llvm::StringRef suffix) {
return suffix == "F" || suffix == "FOR" || suffix == "fpp" ||
- suffix == "FPP" || suffix == "F90" || suffix == "F95" ||
- suffix == "F03" || suffix == "F08" || suffix == "F18";
+ suffix == "FPP" || suffix == "F90" || suffix == "F95" ||
+ suffix == "F03" || suffix == "F08" || suffix == "F18";
}
InputKind FrontendOptions::getInputKindForExtension(llvm::StringRef extension) {
diff --git a/flang/lib/Frontend/TextDiagnosticPrinter.cpp b/flang/lib/Frontend/TextDiagnosticPrinter.cpp
index 12c41d77ba467..7ae19645e40a4 100644
--- a/flang/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/flang/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -46,7 +46,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(
// We only emit diagnostics in contexts that lack valid source locations.
assert(!info.getLocation().isValid() &&
- "Diagnostics with valid source location are not supported");
+ "Diagnostics with valid source location are not supported");
Fortran::frontend::TextDiagnostic::printDiagnosticLevel(os, level,
diagOpts->ShowColors);
diff --git a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index 54cbd2c99e4a0..b99d2b7196da3 100644
--- a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -82,7 +82,7 @@ createFrontendAction(CompilerInstance &ci) {
return std::make_unique<InitOnlyAction>();
case PluginAction: {
for (const FrontendPluginRegistry::entry &plugin :
- FrontendPluginRegistry::entries()) {
+ FrontendPluginRegistry::entries()) {
if (plugin.getName() == ci.getFrontendOpts().actionName) {
std::unique_ptr<PluginParseTreeAction> p(plugin.instantiate());
return std::move(p);
@@ -101,8 +101,9 @@ createFrontendAction(CompilerInstance &ci) {
bool executeCompilerInvocation(CompilerInstance *flang) {
// Honor -help.
if (flang->getFrontendOpts().showHelp) {
- clang::driver::getDriverOptTable().printHelp(llvm::outs(),
- "flang-new -fc1 [options] file...", "LLVM 'Flang' Compiler",
+ clang::driver::getDriverOptTable().printHelp(
+ llvm::outs(), "flang-new -fc1 [options] file...",
+ "LLVM 'Flang' Compiler",
/*Include=*/clang::driver::options::FC1Option,
/*Exclude=*/llvm::opt::DriverFlag::HelpHidden,
/*ShowAllAliases=*/false);
diff --git a/flang/lib/Optimizer/Builder/MutableBox.cpp b/flang/lib/Optimizer/Builder/MutableBox.cpp
index 2c6b1d05bed40..7773125919710 100644
--- a/flang/lib/Optimizer/Builder/MutableBox.cpp
+++ b/flang/lib/Optimizer/Builder/MutableBox.cpp
@@ -809,28 +809,29 @@ fir::factory::MutableBoxReallocation fir::factory::genReallocIfNeeded(
TODO(loc, "automatic allocation of derived type allocatable with "
"length parameters");
}
- auto ifOp =
- builder
- .genIfOp(loc, {addrType}, mustReallocate,
- /*withElseRegion=*/true)
- .genThen([&]() {
- // If shape or length mismatch, allocate new storage.
- // When rhs is a scalar, keep the previous shape
- auto extents = shape.empty()
- ? mlir::ValueRange(previousExtents)
- : shape;
- auto heap = allocateAndInitNewStorage(
- builder, loc, box, extents, lengthParams,
- ".auto.alloc");
- if (storageHandler)
- storageHandler(getExtValForStorage(heap));
- builder.create<fir::ResultOp>(loc, heap);
- })
- .genElse([&]() {
- if (storageHandler)
- storageHandler(getExtValForStorage(addr));
- builder.create<fir::ResultOp>(loc, addr);
- });
+ auto ifOp = builder
+ .genIfOp(loc, {addrType}, mustReallocate,
+ /*withElseRegion=*/true)
+ .genThen([&]() {
+ // If shape or length mismatch, allocate new
+ // storage. When rhs is a scalar, keep the
+ // previous shape
+ auto extents =
+ shape.empty()
+ ? mlir::ValueRange(previousExtents)
+ : shape;
+ auto heap = allocateAndInitNewStorage(
+ builder, loc, box, extents, lengthParams,
+ ".auto.alloc");
+ if (storageHandler)
+ storageHandler(getExtValForStorage(heap));
+ builder.create<fir::ResultOp>(loc, heap);
+ })
+ .genElse([&]() {
+ if (storageHandler)
+ storageHandler(getExtValForStorage(addr));
+ builder.create<fir::ResultOp>(loc, addr);
+ });
ifOp.end();
auto newAddr = ifOp.getResults()[0];
builder.create<fir::ResultOp>(
diff --git a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
index 6868d32840a2e..9bf51cc6ee1a4 100644
--- a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
+++ b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
@@ -841,17 +841,17 @@ class TargetRewrite : public fir::impl::TargetRewritePassBase<TargetRewrite> {
auto argNo = newInTys.size();
if (attr.isByVal()) {
if (auto align = attr.getAlignment())
- fixups.emplace_back(
- FixupTy::Codes::ArgumentAsLoad, argNo,
- [=](mlir::func::FuncOp func) {
- auto elemType = fir::dyn_cast_ptrOrBoxEleTy(
- func.getFunctionType().getInput(argNo));
- func.setArgAttr(argNo, "llvm.byval",
- mlir::TypeAttr::get(elemType));
- func.setArgAttr(argNo, "llvm.align",
- rewriter->getIntegerAttr(
- rewriter->getIntegerType(32), align));
- });
+ fixups.emplace_back(FixupTy::Codes::ArgumentAsLoad, argNo,
+ [=](mlir::func::FuncOp func) {
+ auto elemType = fir::dyn_cast_ptrOrBoxEleTy(
+ func.getFunctionType().getInput(argNo));
+ func.setArgAttr(argNo, "llvm.byval",
+ mlir::TypeAttr::get(elemType));
+ func.setArgAttr(
+ argNo, "llvm.align",
+ rewriter->getIntegerAttr(
+ rewriter->getIntegerType(32), align));
+ });
else
fixups.emplace_back(FixupTy::Codes::ArgumentAsLoad, newInTys.size(),
[=](mlir::func::FuncOp func) {
diff --git a/flang/lib/Semantics/check-acc-structure.h b/flang/lib/Semantics/check-acc-structure.h
index d7de0c5b02eb4..fda626e57ba63 100644
--- a/flang/lib/Semantics/check-acc-structure.h
+++ b/flang/lib/Semantics/check-acc-structure.h
@@ -70,7 +70,6 @@ class AccStructureChecker
#include "llvm/Frontend/OpenACC/ACC.inc"
private:
-
bool CheckAllowedModifier(llvm::acc::Clause clause);
bool IsComputeConstruct(llvm::acc::Directive directive) const;
bool IsInsideComputeConstruct() const;
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index e0efaa7746a3e..85dbbb14e721a 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -1573,9 +1573,7 @@ void CheckHelper::CheckPassArg(
return;
}
const auto &name{proc.name()};
- const Symbol *interface {
- interface0 ? FindInterface(*interface0) : nullptr
- };
+ const Symbol *interface { interface0 ? FindInterface(*interface0) : nullptr };
if (!interface) {
messages_.Say(name,
"Procedure component '%s' must have NOPASS attribute or explicit interface"_err_en_US,
diff --git a/flang/lib/Semantics/data-to-inits.h b/flang/lib/Semantics/data-to-inits.h
index d39a9a39bcc44..10d850d23d5d6 100644
--- a/flang/lib/Semantics/data-to-inits.h
+++ b/flang/lib/Semantics/data-to-inits.h
@@ -18,7 +18,7 @@
namespace Fortran::parser {
struct DataStmtSet;
struct DataStmtValue;
-}
+} // namespace Fortran::parser
namespace Fortran::evaluate {
class ExpressionAnalyzer;
}
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 3853b2eebc6b4..182e83eeea944 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -2307,17 +2307,17 @@ auto ExpressionAnalyzer::GetCalleeAndArguments(
const parser::ProcedureDesignator &pd, ActualArguments &&arguments,
bool isSubroutine, bool mightBeStructureConstructor)
-> std::optional<CalleeAndArguments> {
- return common::visit(
- common::visitors{
- [&](const parser::Name &name) {
- return GetCalleeAndArguments(name, std::move(arguments),
- isSubroutine, mightBeStructureConstructor);
- },
- [&](const parser::ProcComponentRef &pcr) {
- return AnalyzeProcedureComponentRef(
- pcr, std::move(arguments), isSubroutine);
- },
- },
+ return common::visit(common::visitors{
+ [&](const parser::Name &name) {
+ return GetCalleeAndArguments(name,
+ std::move(arguments), isSubroutine,
+ mightBeStructureConstructor);
+ },
+ [&](const parser::ProcComponentRef &pcr) {
+ return AnalyzeProcedureComponentRef(
+ pcr, std::move(arguments), isSubroutine);
+ },
+ },
pd.u);
}
@@ -3417,26 +3417,26 @@ void ArgumentAnalyzer::Analyze(
// be detected and represented (they're not expressions).
// TODO: C1534: Don't allow a "restricted" specific intrinsic to be passed.
std::optional<ActualArgument> actual;
- common::visit(
- common::visitors{
- [&](const common::Indirection<parser::Expr> &x) {
- actual = AnalyzeExpr(x.value());
- SetArgSourceLocation(actual, x.value().source);
- },
- [&](const parser::AltReturnSpec &label) {
- if (!isSubroutine) {
- context_.Say("alternate return specification may not appear on"
- " function reference"_err_en_US);
- }
- actual = ActualArgument(label.v);
- },
- [&](const parser::ActualArg::PercentRef &) {
- context_.Say("%REF() intrinsic for arguments"_todo_en_US);
- },
- [&](const parser::ActualArg::PercentVal &) {
- context_.Say("%VAL() intrinsic for arguments"_todo_en_US);
- },
- },
+ common::visit(common::visitors{
+ [&](const common::Indirection<parser::Expr> &x) {
+ actual = AnalyzeExpr(x.value());
+ SetArgSourceLocation(actual, x.value().source);
+ },
+ [&](const parser::AltReturnSpec &label) {
+ if (!isSubroutine) {
+ context_.Say(
+ "alternate return specification may not appear on"
+ " function reference"_err_en_US);
+ }
+ actual = ActualArgument(label.v);
+ },
+ [&](const parser::ActualArg::PercentRef &) {
+ context_.Say("%REF() intrinsic for arguments"_todo_en_US);
+ },
+ [&](const parser::ActualArg::PercentVal &) {
+ context_.Say("%VAL() intrinsic for arguments"_todo_en_US);
+ },
+ },
std::get<parser::ActualArg>(arg.t).u);
if (actual) {
if (const auto &argKW{std::get<std::optional<parser::Keyword>>(arg.t)}) {
diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp
index 422c8735eab3a..3659ead0a568d 100644
--- a/flang/lib/Semantics/mod-file.cpp
+++ b/flang/lib/Semantics/mod-file.cpp
@@ -687,7 +687,7 @@ void ModFileWriter::PutProcEntity(llvm::raw_ostream &os, const Symbol &symbol) {
return;
}
const auto &details{symbol.get<ProcEntityDetails>()};
- const ProcInterface &interface{details.interface()};
+ const ProcInterface &interface { details.interface() };
Attrs attrs{symbol.attrs()};
if (details.passName()) {
attrs.reset(Attr::PASS);
diff --git a/flang/lib/Semantics/symbol.cpp b/flang/lib/Semantics/symbol.cpp
index fe7942bbb7d79..4fe6ee4bd0076 100644
--- a/flang/lib/Semantics/symbol.cpp
+++ b/flang/lib/Semantics/symbol.cpp
@@ -715,7 +715,8 @@ bool GenericKind::Is(GenericKind::OtherKind x) const {
return y && *y == x;
}
-bool SymbolOffsetCompare::operator()(const SymbolRef &x, const SymbolRef &y) const {
+bool SymbolOffsetCompare::operator()(
+ const SymbolRef &x, const SymbolRef &y) const {
const Symbol *xCommon{FindCommonBlockContaining(*x)};
const Symbol *yCommon{FindCommonBlockContaining(*y)};
if (xCommon) {
diff --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp
index 6bf2a574fe3fa..7484993d2393e 100644
--- a/flang/lib/Semantics/tools.cpp
+++ b/flang/lib/Semantics/tools.cpp
@@ -456,9 +456,7 @@ const Symbol *FindInterface(const Symbol &symbol) {
return common::visit(
common::visitors{
[](const ProcEntityDetails &details) {
- const Symbol *interface {
- details.interface().symbol()
- };
+ const Symbol *interface { details.interface().symbol() };
return interface ? FindInterface(*interface) : nullptr;
},
[](const ProcBindingDetails &details) {
diff --git a/flang/tools/flang-driver/driver.cpp b/flang/tools/flang-driver/driver.cpp
index 28a8db2584b5c..e4880b62ee857 100644
--- a/flang/tools/flang-driver/driver.cpp
+++ b/flang/tools/flang-driver/driver.cpp
@@ -72,8 +72,8 @@ static int executeFC1Tool(llvm::SmallVectorImpl<const char *> &argV) {
return 1;
}
-static void ExpandResponseFiles(
- llvm::StringSaver &saver, llvm::SmallVectorImpl<const char *> &args) {
+static void ExpandResponseFiles(llvm::StringSaver &saver,
+ llvm::SmallVectorImpl<const char *> &args) {
// We're defaulting to the GNU syntax, since we don't have a CL mode.
llvm::cl::TokenizerCallback tokenizer = &llvm::cl::TokenizeGNUCommandLine;
llvm::cl::ExpansionContext ExpCtx(saver.getAllocator(), tokenizer);
@@ -96,8 +96,8 @@ int main(int argc, const char **argv) {
ExpandResponseFiles(saver, args);
// Check if flang-new is in the frontend mode
- auto firstArg = std::find_if(
- args.begin() + 1, args.end(), [](const char *a) { return a != nullptr; });
+ auto firstArg = std::find_if(args.begin() + 1, args.end(),
+ [](const char *a) { return a != nullptr; });
if (firstArg != args.end()) {
if (llvm::StringRef(args[1]).startswith("-cc1")) {
llvm::errs() << "error: unknown integrated tool '" << args[1] << "'. "
@@ -127,7 +127,8 @@ int main(int argc, const char **argv) {
// Prepare the driver
clang::driver::Driver theDriver(driverPath,
- llvm::sys::getDefaultTargetTriple(), diags, "flang LLVM compiler");
+ llvm::sys::getDefaultTargetTriple(), diags,
+ "flang LLVM compiler");
theDriver.setTargetAndMode(targetandMode);
std::unique_ptr<clang::driver::Compilation> c(
theDriver.BuildCompilation(args));
diff --git a/flang/unittests/Optimizer/FIRContextTest.cpp b/flang/unittests/Optimizer/FIRContextTest.cpp
index 5976f2c4979f3..7e1b97bbbd4f2 100644
--- a/flang/unittests/Optimizer/FIRContextTest.cpp
+++ b/flang/unittests/Optimizer/FIRContextTest.cpp
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "flang/Optimizer/Support/FIRContext.h"
-#include "flang/Optimizer/Support/KindMapping.h"
+#include "gtest/gtest.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinOps.h"
+#include "flang/Optimizer/Support/KindMapping.h"
#include "llvm/Support/Host.h"
-#include "gtest/gtest.h"
#include <string>
using namespace fir;
diff --git a/flang/unittests/Runtime/Time.cpp b/flang/unittests/Runtime/Time.cpp
index 479f82ffe524c..ceccb4a70805c 100644
--- a/flang/unittests/Runtime/Time.cpp
+++ b/flang/unittests/Runtime/Time.cpp
@@ -166,4 +166,3 @@ TEST(TimeIntrinsics, DateAndTime) {
EXPECT_LE(minutes, 59);
}
}
-
More information about the flang-commits
mailing list