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

Tim Keith via flang-commits flang-commits at lists.llvm.org
Wed Jul 1 16:53:13 PDT 2020


Author: Tim Keith
Date: 2020-07-01T16:51:46-07:00
New Revision: dd904082625b4fd83f90647952dabee93ef5e990

URL: https://github.com/llvm/llvm-project/commit/dd904082625b4fd83f90647952dabee93ef5e990
DIFF: https://github.com/llvm/llvm-project/commit/dd904082625b4fd83f90647952dabee93ef5e990.diff

LOG: [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

Added: 
    flang/module/.clang-format

Modified: 
    flang/include/flang/Lower/AbstractConverter.h
    flang/include/flang/Parser/characters.h
    flang/include/flang/Semantics/scope.h
    flang/lib/Evaluate/fold-integer.cpp
    flang/lib/Lower/ConvertType.cpp
    flang/lib/Semantics/canonicalize-do.cpp
    flang/lib/Semantics/check-data.cpp
    flang/lib/Semantics/expression.cpp
    flang/runtime/edit-output.cpp
    flang/runtime/memory.h

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Lower/AbstractConverter.h b/flang/include/flang/Lower/AbstractConverter.h
index 5121c22ed352..190e69230c8e 100644
--- a/flang/include/flang/Lower/AbstractConverter.h
+++ b/flang/include/flang/Lower/AbstractConverter.h
@@ -51,7 +51,7 @@ class FirOpBuilder;
 class AbstractConverter {
 public:
   //===--------------------------------------------------------------------===//
-  // Symbols     
+  // Symbols
   //===--------------------------------------------------------------------===//
 
   /// Get the mlir instance of a symbol.

diff  --git a/flang/include/flang/Parser/characters.h b/flang/include/flang/Parser/characters.h
index c18140780956..eefb524e5d87 100644
--- a/flang/include/flang/Parser/characters.h
+++ b/flang/include/flang/Parser/characters.h
@@ -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) {

diff  --git a/flang/include/flang/Semantics/scope.h b/flang/include/flang/Semantics/scope.h
index a85a24770ef8..a67a00888927 100644
--- a/flang/include/flang/Semantics/scope.h
+++ b/flang/include/flang/Semantics/scope.h
@@ -265,8 +265,9 @@ class Scope {
 // 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

diff  --git a/flang/lib/Evaluate/fold-integer.cpp b/flang/lib/Evaluate/fold-integer.cpp
index 3472f9a444c1..5b07eaa454d8 100644
--- a/flang/lib/Evaluate/fold-integer.cpp
+++ b/flang/lib/Evaluate/fold-integer.cpp
@@ -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);
                       }});
             }
           },

diff  --git a/flang/lib/Lower/ConvertType.cpp b/flang/lib/Lower/ConvertType.cpp
index 54792a51b4eb..276df03d6288 100644
--- a/flang/lib/Lower/ConvertType.cpp
+++ b/flang/lib/Lower/ConvertType.cpp
@@ -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 @@ class TypeBuilder {
   //===--------------------------------------------------------------------===//
   // Generate type helpers
   //===--------------------------------------------------------------------===//
-  
+
   mlir::Type gen(const Fortran::evaluate::ImpliedDoIndex &) {
     return genFIRType<Fortran::common::TypeCategory::Integer>(
         context, defaultKind<Fortran::common::TypeCategory::Integer>());

diff  --git a/flang/lib/Semantics/canonicalize-do.cpp b/flang/lib/Semantics/canonicalize-do.cpp
index 8d27d6344423..797fb27b2b14 100644
--- a/flang/lib/Semantics/canonicalize-do.cpp
+++ b/flang/lib/Semantics/canonicalize-do.cpp
@@ -30,58 +30,62 @@ class CanonicalizationOfDoLoops {
                 // 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);

diff  --git a/flang/lib/Semantics/check-data.cpp b/flang/lib/Semantics/check-data.cpp
index 7e86790a529e..1aa52f06f642 100644
--- a/flang/lib/Semantics/check-data.cpp
+++ b/flang/lib/Semantics/check-data.cpp
@@ -61,18 +61,18 @@ class DataVarChecker : public evaluate::AllTraverse<DataVarChecker, true> {
     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());

diff  --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 60e705f0ee88..1e7d1d582a34 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -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 {

diff  --git a/flang/module/.clang-format b/flang/module/.clang-format
new file mode 100644
index 000000000000..e3845288a2ae
--- /dev/null
+++ b/flang/module/.clang-format
@@ -0,0 +1 @@
+DisableFormat: true

diff  --git a/flang/runtime/edit-output.cpp b/flang/runtime/edit-output.cpp
index a162726a592b..941c5ccf3d59 100644
--- a/flang/runtime/edit-output.cpp
+++ b/flang/runtime/edit-output.cpp
@@ -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

diff  --git a/flang/runtime/memory.h b/flang/runtime/memory.h
index f26213f954a4..b8e84952a99f 100644
--- a/flang/runtime/memory.h
+++ b/flang/runtime/memory.h
@@ -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 *);


        


More information about the flang-commits mailing list