[flang][NFC] Get formatting in sync with latest clang-format

flang/module only contains Fortran files and one is a .h so disable
formatting on that directory.

Differential Revision: https://reviews.llvm.org/D82989
This commit is contained in:
Tim Keith 2020-07-01 16:51:44 -07:00
parent 48c196f5c8
commit dd90408262
11 changed files with 59 additions and 56 deletions

View File

@ -51,7 +51,7 @@ class FirOpBuilder;
class AbstractConverter {
public:
//===--------------------------------------------------------------------===//
// Symbols
// Symbols
//===--------------------------------------------------------------------===//
/// Get the mlir instance of a symbol.

View File

@ -96,9 +96,9 @@ inline constexpr bool IsSameApartFromCase(char x, char y) {
inline constexpr char DecimalDigitValue(char ch) { return ch - '0'; }
inline constexpr char HexadecimalDigitValue(char ch) {
return IsUpperCaseLetter(ch)
? ch - 'A' + 10
: IsLowerCaseLetter(ch) ? ch - 'a' + 10 : DecimalDigitValue(ch);
return IsUpperCaseLetter(ch) ? ch - 'A' + 10
: IsLowerCaseLetter(ch) ? ch - 'a' + 10
: DecimalDigitValue(ch);
}
inline constexpr std::optional<char> BackslashEscapeValue(char ch) {

View File

@ -265,8 +265,9 @@ private:
// Inline so that it can be called from Evaluate without a link-time dependency.
inline const Symbol *Scope::GetSymbol() const {
return symbol_ ? symbol_
: derivedTypeSpec_ ? &derivedTypeSpec_->typeSymbol() : nullptr;
return symbol_ ? symbol_
: derivedTypeSpec_ ? &derivedTypeSpec_->typeSymbol()
: nullptr;
}
} // namespace Fortran::semantics

View File

@ -157,9 +157,8 @@ Expr<Type<TypeCategory::Integer, KIND>> FoldIntrinsicFunction(
} else if (name == "ceiling" || name == "floor" || name == "nint") {
if (const auto *cx{UnwrapExpr<Expr<SomeReal>>(args[0])}) {
// NINT rounds ties away from zero, not to even
common::RoundingMode mode{name == "ceiling"
? common::RoundingMode::Up
: name == "floor" ? common::RoundingMode::Down
common::RoundingMode mode{name == "ceiling" ? common::RoundingMode::Up
: name == "floor" ? common::RoundingMode::Down
: common::RoundingMode::TiesAwayFromZero};
return std::visit(
[&](const auto &kx) {
@ -322,8 +321,8 @@ Expr<Type<TypeCategory::Integer, KIND>> FoldIntrinsicFunction(
return name == "index"
? CharacterUtils<TC::kind>::INDEX(str, other)
: name == "scan"
? CharacterUtils<TC::kind>::SCAN(str, other)
: CharacterUtils<TC::kind>::VERIFY(str, other);
? CharacterUtils<TC::kind>::SCAN(str, other)
: CharacterUtils<TC::kind>::VERIFY(str, other);
}});
}
},

View File

@ -177,18 +177,16 @@ namespace {
/// mlir::Type. The type returned may be an MLIR standard or FIR type.
class TypeBuilder {
public:
/// Constructor.
explicit TypeBuilder(
mlir::MLIRContext *context,
const Fortran::common::IntrinsicTypeDefaultKinds &defaults)
: context{context}, defaults{defaults} {}
//===--------------------------------------------------------------------===//
// Generate type entry points
//===--------------------------------------------------------------------===//
template <template <typename> typename A, Fortran::common::TypeCategory TC>
mlir::Type gen(const A<Fortran::evaluate::SomeKind<TC>> &) {
return genFIRType<TC>(context, defaultKind<TC>());
@ -262,7 +260,7 @@ private:
//===--------------------------------------------------------------------===//
// Generate type helpers
//===--------------------------------------------------------------------===//
mlir::Type gen(const Fortran::evaluate::ImpliedDoIndex &) {
return genFIRType<Fortran::common::TypeCategory::Integer>(
context, defaultKind<Fortran::common::TypeCategory::Integer>());

View File

@ -30,58 +30,62 @@ public:
// Labels on end-stmt of constructs are accepted by f18 as an
// extension.
[&](common::Indirection<AssociateConstruct> &associate) {
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndAssociateStmt>>(associate.value().t));
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndAssociateStmt>>(
associate.value().t));
},
[&](common::Indirection<BlockConstruct> &blockConstruct) {
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndBlockStmt>>(blockConstruct.value().t));
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndBlockStmt>>(
blockConstruct.value().t));
},
[&](common::Indirection<ChangeTeamConstruct> &changeTeam) {
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndChangeTeamStmt>>(changeTeam.value().t));
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndChangeTeamStmt>>(
changeTeam.value().t));
},
[&](common::Indirection<CriticalConstruct> &critical) {
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndCriticalStmt>>(critical.value().t));
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndCriticalStmt>>(critical.value().t));
},
[&](common::Indirection<DoConstruct> &doConstruct) {
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndDoStmt>>(doConstruct.value().t));
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndDoStmt>>(doConstruct.value().t));
},
[&](common::Indirection<IfConstruct> &ifConstruct) {
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndIfStmt>>(ifConstruct.value().t));
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndIfStmt>>(ifConstruct.value().t));
},
[&](common::Indirection<CaseConstruct> &caseConstruct) {
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndSelectStmt>>(caseConstruct.value().t));
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndSelectStmt>>(
caseConstruct.value().t));
},
[&](common::Indirection<SelectRankConstruct> &selectRank) {
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndSelectStmt>>(selectRank.value().t));
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndSelectStmt>>(selectRank.value().t));
},
[&](common::Indirection<SelectTypeConstruct> &selectType) {
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndSelectStmt>>(selectType.value().t));
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndSelectStmt>>(selectType.value().t));
},
[&](common::Indirection<ForallConstruct> &forall) {
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndForallStmt>>(forall.value().t));
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndForallStmt>>(forall.value().t));
},
[&](common::Indirection<WhereConstruct> &where) {
CanonicalizeIfMatch(block, stack, i,
std::get<Statement<EndWhereStmt>>(where.value().t));
},
[&](Statement<common::Indirection<LabelDoStmt>> &labelDoStmt) {
auto &label{std::get<Label>(labelDoStmt.statement.value().t)};
stack.push_back(LabelInfo{i, label});
auto &label{std::get<Label>(labelDoStmt.statement.value().t)};
stack.push_back(LabelInfo{i, label});
},
[&](Statement<common::Indirection<EndDoStmt>> &endDoStmt) {
CanonicalizeIfMatch(block, stack, i, endDoStmt);
CanonicalizeIfMatch(block, stack, i, endDoStmt);
},
[&](Statement<ActionStmt> &actionStmt) {
CanonicalizeIfMatch(block, stack, i, actionStmt);
CanonicalizeIfMatch(block, stack, i, actionStmt);
},
},
executableConstruct->u);

View File

@ -61,18 +61,18 @@ public:
const Scope &scope{context_.FindScope(source_)};
bool isFirstSymbol{isFirstSymbol_};
isFirstSymbol_ = false;
if (const char *whyNot{IsAutomatic(symbol) ? "Automatic variable"
: IsDummy(symbol) ? "Dummy argument"
: IsFunctionResult(symbol) ? "Function result"
: IsAllocatable(symbol) ? "Allocatable"
: IsInitialized(symbol, true) ? "Default-initialized"
: IsInBlankCommon(symbol) ? "Blank COMMON object"
: IsProcedure(symbol) && !IsPointer(symbol) ? "Procedure"
// remaining checks don't apply to components
: !isFirstSymbol ? nullptr
: IsHostAssociated(symbol, scope) ? "Host-associated object"
: IsUseAssociated(symbol, scope) ? "USE-associated object"
: nullptr}) {
if (const char *whyNot{IsAutomatic(symbol) ? "Automatic variable"
: IsDummy(symbol) ? "Dummy argument"
: IsFunctionResult(symbol) ? "Function result"
: IsAllocatable(symbol) ? "Allocatable"
: IsInitialized(symbol, true) ? "Default-initialized"
: IsInBlankCommon(symbol) ? "Blank COMMON object"
: IsProcedure(symbol) && !IsPointer(symbol) ? "Procedure"
// remaining checks don't apply to components
: !isFirstSymbol ? nullptr
: IsHostAssociated(symbol, scope) ? "Host-associated object"
: IsUseAssociated(symbol, scope) ? "USE-associated object"
: nullptr}) {
context_.Say(source_,
"%s '%s' must not be initialized in a DATA statement"_err_en_US,
whyNot, symbol.name());

View File

@ -3023,7 +3023,7 @@ std::string ArgumentAnalyzer::TypeAsFortran(std::size_t i) {
if (std::optional<DynamicType> type{GetType(i)}) {
return type->category() == TypeCategory::Derived
? "TYPE("s + type->AsFortran() + ')'
: type->category() == TypeCategory::Character
: type->category() == TypeCategory::Character
? "CHARACTER(KIND="s + std::to_string(type->kind()) + ')'
: ToUpperCase(type->AsFortran());
} else {

View File

@ -0,0 +1 @@
DisableFormat: true

View File

@ -127,9 +127,9 @@ const char *RealOutputEditingBase::FormatExponent(
bool RealOutputEditingBase::EmitPrefix(
const DataEdit &edit, std::size_t length, std::size_t width) {
if (edit.IsListDirected()) {
int prefixLength{edit.descriptor == DataEdit::ListDirectedRealPart
? 2
: edit.descriptor == DataEdit::ListDirectedImaginaryPart ? 0 : 1};
int prefixLength{edit.descriptor == DataEdit::ListDirectedRealPart ? 2
: edit.descriptor == DataEdit::ListDirectedImaginaryPart ? 0
: 1};
int suffixLength{edit.descriptor == DataEdit::ListDirectedRealPart ||
edit.descriptor == DataEdit::ListDirectedImaginaryPart
? 1

View File

@ -20,7 +20,7 @@ class Terminator;
[[nodiscard]] void *AllocateMemoryOrCrash(
const Terminator &, std::size_t bytes);
template <typename A>[[nodiscard]] A &AllocateOrCrash(const Terminator &t) {
template <typename A> [[nodiscard]] A &AllocateOrCrash(const Terminator &t) {
return *reinterpret_cast<A *>(AllocateMemoryOrCrash(t, sizeof(A)));
}
void FreeMemory(void *);