-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[flang] clang-format Semantics sources, NFC #153959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There a a bunch of relatively simple changes, mostly the position of the * or & in declarations, or line breaks in declarations (usually) within if-statements. Three manual changes: - remove tailing ; in the constructor of ArithmeticIfStmtChecker, - prevent re-indentation of visitor functions in check-case.cpp and resolve-directives.cpp
|
@llvm/pr-subscribers-flang-semantics Author: Krzysztof Parzyszek (kparzysz) ChangesThere a a bunch of relatively simple changes, mostly the position of the * or & in declarations, or line breaks in declarations (usually) within if-statements. Three manual changes:
Patch is 149.38 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/153959.diff 37 Files Affected:
diff --git a/flang/include/flang/Semantics/scope.h b/flang/include/flang/Semantics/scope.h
index b4046830522b8..417548b62a255 100644
--- a/flang/include/flang/Semantics/scope.h
+++ b/flang/include/flang/Semantics/scope.h
@@ -39,8 +39,8 @@ class SemanticsContext;
struct EquivalenceObject {
EquivalenceObject(Symbol &symbol, std::vector<ConstantSubscript> subscripts,
std::optional<ConstantSubscript> substringStart, parser::CharBlock source)
- : symbol{symbol}, subscripts{subscripts},
- substringStart{substringStart}, source{source} {}
+ : symbol{symbol}, subscripts{subscripts}, substringStart{substringStart},
+ source{source} {}
explicit EquivalenceObject(Symbol &symbol)
: symbol{symbol}, source{symbol.name()} {}
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index 5bde9f39ca0b0..861dd2a20ffec 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -32,7 +32,7 @@ namespace Fortran::parser {
struct Expr;
struct OpenMPDeclareReductionConstruct;
struct OmpMetadirectiveDirective;
-}
+} // namespace Fortran::parser
namespace Fortran::semantics {
diff --git a/flang/include/flang/Semantics/tools.h b/flang/include/flang/Semantics/tools.h
index 966a30f7081fd..9cefe94e0ce79 100644
--- a/flang/include/flang/Semantics/tools.h
+++ b/flang/include/flang/Semantics/tools.h
@@ -203,7 +203,7 @@ bool IsDeviceAllocatable(const Symbol &symbol);
inline bool IsCUDADeviceContext(const Scope *scope) {
if (scope) {
- if (const Symbol * symbol{scope->symbol()}) {
+ if (const Symbol *symbol{scope->symbol()}) {
if (const auto *subp{symbol->detailsIf<SubprogramDetails>()}) {
if (auto attrs{subp->cudaSubprogramAttrs()}) {
return *attrs != common::CUDASubprogramAttrs::Host;
@@ -305,7 +305,7 @@ const Symbol *FindExternallyVisibleObject(const A &, const Scope &) {
template <typename T>
const Symbol *FindExternallyVisibleObject(
const evaluate::Designator<T> &designator, const Scope &scope) {
- if (const Symbol * symbol{designator.GetBaseObject().symbol()}) {
+ if (const Symbol *symbol{designator.GetBaseObject().symbol()}) {
return FindExternallyVisibleObject(*symbol, scope, false);
} else if (std::holds_alternative<evaluate::CoarrayRef>(designator.u)) {
// Coindexed values are visible even if their image-local objects are not.
@@ -670,8 +670,8 @@ class LabelEnforce {
LabelEnforce(SemanticsContext &context, std::set<parser::Label> &&labels,
parser::CharBlock constructSourcePosition, const char *construct)
: context_{context}, labels_{labels},
- constructSourcePosition_{constructSourcePosition}, construct_{
- construct} {}
+ constructSourcePosition_{constructSourcePosition},
+ construct_{construct} {}
template <typename T> bool Pre(const T &) { return true; }
template <typename T> bool Pre(const parser::Statement<T> &statement) {
currentStatementSourcePosition_ = statement.source;
diff --git a/flang/include/flang/Semantics/unparse-with-symbols.h b/flang/include/flang/Semantics/unparse-with-symbols.h
index 702911bbab627..26e28f771689c 100644
--- a/flang/include/flang/Semantics/unparse-with-symbols.h
+++ b/flang/include/flang/Semantics/unparse-with-symbols.h
@@ -32,6 +32,6 @@ void UnparseWithSymbols(llvm::raw_ostream &, const parser::Program &,
void UnparseWithModules(llvm::raw_ostream &, SemanticsContext &,
const parser::Program &,
parser::Encoding encoding = parser::Encoding::UTF_8);
-}
+} // namespace Fortran::semantics
#endif // FORTRAN_SEMANTICS_UNPARSE_WITH_SYMBOLS_H_
diff --git a/flang/lib/Semantics/assignment.cpp b/flang/lib/Semantics/assignment.cpp
index 88e08887160d9..bbe3e74b79755 100644
--- a/flang/lib/Semantics/assignment.cpp
+++ b/flang/lib/Semantics/assignment.cpp
@@ -62,7 +62,7 @@ class AssignmentContext {
};
void AssignmentContext::Analyze(const parser::AssignmentStmt &stmt) {
- if (const evaluate::Assignment * assignment{GetAssignment(stmt)}) {
+ if (const evaluate::Assignment *assignment{GetAssignment(stmt)}) {
const SomeExpr &lhs{assignment->lhs};
const SomeExpr &rhs{assignment->rhs};
auto lhsLoc{std::get<parser::Variable>(stmt.t).GetSource()};
@@ -72,8 +72,8 @@ void AssignmentContext::Analyze(const parser::AssignmentStmt &stmt) {
std::holds_alternative<evaluate::ProcedureRef>(assignment->u)};
if (isDefinedAssignment) {
flags.set(DefinabilityFlag::AllowEventLockOrNotifyType);
- } else if (const Symbol *
- whole{evaluate::UnwrapWholeSymbolOrComponentDataRef(lhs)}) {
+ } else if (const Symbol *whole{
+ evaluate::UnwrapWholeSymbolOrComponentDataRef(lhs)}) {
if (IsAllocatable(whole->GetUltimate())) {
flags.set(DefinabilityFlag::PotentialDeallocation);
}
@@ -101,7 +101,7 @@ void AssignmentContext::Analyze(const parser::AssignmentStmt &stmt) {
void AssignmentContext::Analyze(const parser::PointerAssignmentStmt &stmt) {
CHECK(whereDepth_ == 0);
- if (const evaluate::Assignment * assignment{GetAssignment(stmt)}) {
+ if (const evaluate::Assignment *assignment{GetAssignment(stmt)}) {
parser::CharBlock at{context_.location().value()};
auto restorer{foldingContext().messages().SetLocation(at)};
CheckPointerAssignment(context_, *assignment, context_.FindScope(at));
@@ -125,7 +125,7 @@ static std::optional<std::string> GetPointerComponentDesignatorName(
bool CheckCopyabilityInPureScope(parser::ContextualMessages &messages,
const SomeExpr &expr, const Scope &scope) {
if (auto pointer{GetPointerComponentDesignatorName(expr)}) {
- if (const Symbol * base{GetFirstSymbol(expr)}) {
+ if (const Symbol *base{GetFirstSymbol(expr)}) {
const char *why{WhyBaseObjectIsSuspicious(base->GetUltimate(), scope)};
if (!why) {
if (auto coarray{evaluate::ExtractCoarrayRef(expr)}) {
diff --git a/flang/lib/Semantics/canonicalize-acc.cpp b/flang/lib/Semantics/canonicalize-acc.cpp
index 108fd33c2ed94..3f7889bf96ac5 100644
--- a/flang/lib/Semantics/canonicalize-acc.cpp
+++ b/flang/lib/Semantics/canonicalize-acc.cpp
@@ -68,7 +68,7 @@ class CanonicalizationOfAcc {
return; // Tile is not allowed on DO CONCURRENT
}
for (const parser::DoConstruct *loop{&outer}; loop && tileArgNb > 0;
- --tileArgNb) {
+ --tileArgNb) {
const auto &block{std::get<parser::Block>(loop->t)};
const auto it{block.begin()};
loop = it != block.end() ? parser::Unwrap<parser::DoConstruct>(*it)
diff --git a/flang/lib/Semantics/check-acc-structure.cpp b/flang/lib/Semantics/check-acc-structure.cpp
index 051abdceba19d..db388e2737a90 100644
--- a/flang/lib/Semantics/check-acc-structure.cpp
+++ b/flang/lib/Semantics/check-acc-structure.cpp
@@ -667,8 +667,8 @@ void AccStructureChecker::Enter(const parser::OpenACCCacheConstruct &x) {
PushContextAndClauseSets(verbatim.source, llvm::acc::Directive::ACCD_cache);
SetContextDirectiveSource(verbatim.source);
if (loopNestLevel == 0) {
- context_.Say(verbatim.source,
- "The CACHE directive must be inside a loop"_err_en_US);
+ context_.Say(
+ verbatim.source, "The CACHE directive must be inside a loop"_err_en_US);
}
}
void AccStructureChecker::Leave(const parser::OpenACCCacheConstruct &x) {
diff --git a/flang/lib/Semantics/check-allocate.cpp b/flang/lib/Semantics/check-allocate.cpp
index 08053594c12e4..73395da1ee9b4 100644
--- a/flang/lib/Semantics/check-allocate.cpp
+++ b/flang/lib/Semantics/check-allocate.cpp
@@ -74,7 +74,7 @@ class AllocationCheckerHelper {
if (type_->category() == DeclTypeSpec::Category::Character) {
hasDeferredTypeParameter_ =
type_->characterTypeSpec().length().isDeferred();
- } else if (const DerivedTypeSpec * derivedTypeSpec{type_->AsDerived()}) {
+ } else if (const DerivedTypeSpec *derivedTypeSpec{type_->AsDerived()}) {
for (const auto &pair : derivedTypeSpec->parameters()) {
hasDeferredTypeParameter_ |= pair.second.isDeferred();
}
@@ -114,7 +114,7 @@ static std::optional<AllocateCheckerInfo> CheckAllocateOptions(
}
info.gotTypeSpec = true;
info.typeSpecLoc = parser::FindSourceLocation(*typeSpec);
- if (const DerivedTypeSpec * derived{info.typeSpec->AsDerived()}) {
+ if (const DerivedTypeSpec *derived{info.typeSpec->AsDerived()}) {
// C937
if (auto it{FindCoarrayUltimateComponent(*derived)}) {
context
@@ -224,8 +224,8 @@ static std::optional<AllocateCheckerInfo> CheckAllocateOptions(
}
info.sourceExprRank = expr->Rank();
info.sourceExprLoc = parserSourceExpr->source;
- if (const DerivedTypeSpec *
- derived{evaluate::GetDerivedTypeSpec(info.sourceExprType)}) {
+ if (const DerivedTypeSpec *derived{
+ evaluate::GetDerivedTypeSpec(info.sourceExprType)}) {
// C949
if (auto it{FindCoarrayUltimateComponent(*derived)}) {
context
@@ -279,13 +279,13 @@ static std::optional<AllocateCheckerInfo> CheckAllocateOptions(
// in this test.
static bool IsTypeCompatible(
const DeclTypeSpec &type1, const DerivedTypeSpec &derivedType2) {
- if (const DerivedTypeSpec * derivedType1{type1.AsDerived()}) {
+ if (const DerivedTypeSpec *derivedType1{type1.AsDerived()}) {
if (type1.category() == DeclTypeSpec::Category::TypeDerived) {
return evaluate::AreSameDerivedTypeIgnoringTypeParameters(
*derivedType1, derivedType2);
} else if (type1.category() == DeclTypeSpec::Category::ClassDerived) {
for (const DerivedTypeSpec *parent{&derivedType2}; parent;
- parent = parent->typeSymbol().GetParentTypeSpec()) {
+ parent = parent->typeSymbol().GetParentTypeSpec()) {
if (evaluate::AreSameDerivedTypeIgnoringTypeParameters(
*derivedType1, *parent)) {
return true;
@@ -303,13 +303,13 @@ static bool IsTypeCompatible(
// cannot be allocatable (C709)
return true;
}
- if (const IntrinsicTypeSpec * intrinsicType2{type2.AsIntrinsic()}) {
- if (const IntrinsicTypeSpec * intrinsicType1{type1.AsIntrinsic()}) {
+ if (const IntrinsicTypeSpec *intrinsicType2{type2.AsIntrinsic()}) {
+ if (const IntrinsicTypeSpec *intrinsicType1{type1.AsIntrinsic()}) {
return intrinsicType1->category() == intrinsicType2->category();
} else {
return false;
}
- } else if (const DerivedTypeSpec * derivedType2{type2.AsDerived()}) {
+ } else if (const DerivedTypeSpec *derivedType2{type2.AsDerived()}) {
return IsTypeCompatible(type1, *derivedType2);
}
return false;
@@ -323,7 +323,7 @@ static bool IsTypeCompatible(
return true;
}
if (type2.category() != evaluate::TypeCategory::Derived) {
- if (const IntrinsicTypeSpec * intrinsicType1{type1.AsIntrinsic()}) {
+ if (const IntrinsicTypeSpec *intrinsicType1{type1.AsIntrinsic()}) {
return intrinsicType1->category() == type2.category();
} else {
return false;
@@ -348,16 +348,16 @@ static bool HaveSameAssumedTypeParameters(
}
// It is possible to reach this if type1 is unlimited polymorphic
return !type2LengthIsAssumed;
- } else if (const DerivedTypeSpec * derivedType2{type2.AsDerived()}) {
+ } else if (const DerivedTypeSpec *derivedType2{type2.AsDerived()}) {
int type2AssumedParametersCount{0};
int type1AssumedParametersCount{0};
for (const auto &pair : derivedType2->parameters()) {
type2AssumedParametersCount += pair.second.isAssumed();
}
// type1 may be unlimited polymorphic
- if (const DerivedTypeSpec * derivedType1{type1.AsDerived()}) {
+ if (const DerivedTypeSpec *derivedType1{type1.AsDerived()}) {
for (auto it{derivedType1->parameters().begin()};
- it != derivedType1->parameters().end(); ++it) {
+ it != derivedType1->parameters().end(); ++it) {
if (it->second.isAssumed()) {
++type1AssumedParametersCount;
const ParamValue *param{derivedType2->FindParameter(it->first)};
@@ -378,8 +378,8 @@ static bool HaveSameAssumedTypeParameters(
static std::optional<std::int64_t> GetTypeParameterInt64Value(
const Symbol ¶meterSymbol, const DerivedTypeSpec &derivedType) {
- if (const ParamValue *
- paramValue{derivedType.FindParameter(parameterSymbol.name())}) {
+ if (const ParamValue *paramValue{
+ derivedType.FindParameter(parameterSymbol.name())}) {
return evaluate::ToInt64(paramValue->GetExplicit());
}
return std::nullopt;
@@ -403,11 +403,11 @@ static bool HaveCompatibleTypeParameters(
if (type1.category() == DeclTypeSpec::Category::ClassStar) {
return true;
}
- if (const IntrinsicTypeSpec * intrinsicType1{type1.AsIntrinsic()}) {
+ if (const IntrinsicTypeSpec *intrinsicType1{type1.AsIntrinsic()}) {
return evaluate::ToInt64(intrinsicType1->kind()).value() == type2.kind();
} else if (type2.IsUnlimitedPolymorphic()) {
return false;
- } else if (const DerivedTypeSpec * derivedType1{type1.AsDerived()}) {
+ } else if (const DerivedTypeSpec *derivedType1{type1.AsDerived()}) {
return HaveCompatibleTypeParameters(
*derivedType1, type2.GetDerivedTypeSpec());
} else {
@@ -419,10 +419,10 @@ static bool HaveCompatibleTypeParameters(
const DeclTypeSpec &type1, const DeclTypeSpec &type2) {
if (type1.category() == DeclTypeSpec::Category::ClassStar) {
return true;
- } else if (const IntrinsicTypeSpec * intrinsicType1{type1.AsIntrinsic()}) {
+ } else if (const IntrinsicTypeSpec *intrinsicType1{type1.AsIntrinsic()}) {
const IntrinsicTypeSpec *intrinsicType2{type2.AsIntrinsic()};
return !intrinsicType2 || intrinsicType1->kind() == intrinsicType2->kind();
- } else if (const DerivedTypeSpec * derivedType1{type1.AsDerived()}) {
+ } else if (const DerivedTypeSpec *derivedType1{type1.AsDerived()}) {
const DerivedTypeSpec *derivedType2{type2.AsDerived()};
return !derivedType2 ||
HaveCompatibleTypeParameters(*derivedType1, *derivedType2);
@@ -699,8 +699,7 @@ bool AllocationCheckerHelper::RunCoarrayRelatedChecks(
if (evaluate::IsCoarray(*ultimate_)) {
if (allocateInfo_.gotTypeSpec) {
// C938
- if (const DerivedTypeSpec *
- derived{allocateInfo_.typeSpec->AsDerived()}) {
+ if (const DerivedTypeSpec *derived{allocateInfo_.typeSpec->AsDerived()}) {
if (IsTeamType(derived)) {
context
.Say(allocateInfo_.typeSpecLoc.value(),
@@ -784,8 +783,8 @@ bool AllocationCheckerHelper::RunCoarrayRelatedChecks(
return false;
}
}
- if (const parser::CoindexedNamedObject *
- coindexedObject{parser::GetCoindexedNamedObject(allocateObject_)}) {
+ if (const parser::CoindexedNamedObject *coindexedObject{
+ parser::GetCoindexedNamedObject(allocateObject_)}) {
// C950
context.Say(parser::FindSourceLocation(*coindexedObject),
"Allocatable object must not be coindexed in ALLOCATE"_err_en_US);
diff --git a/flang/lib/Semantics/check-arithmeticif.h b/flang/lib/Semantics/check-arithmeticif.h
index 1d156763e5513..64d0c00b58d75 100644
--- a/flang/lib/Semantics/check-arithmeticif.h
+++ b/flang/lib/Semantics/check-arithmeticif.h
@@ -18,7 +18,7 @@ struct ArithmeticIfStmt;
namespace Fortran::semantics {
class ArithmeticIfStmtChecker : public virtual BaseChecker {
public:
- ArithmeticIfStmtChecker(SemanticsContext &context) : context_(context){};
+ ArithmeticIfStmtChecker(SemanticsContext &context) : context_(context) {}
void Leave(const parser::ArithmeticIfStmt &);
private:
diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index 83f59f0cac3df..b4d0e42c1da32 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -43,7 +43,7 @@ static void CheckImplicitInterfaceArg(evaluate::ActualArgument &arg,
} else if (type->IsUnlimitedPolymorphic()) {
messages.Say(
"Unlimited polymorphic actual argument requires an explicit interface"_err_en_US);
- } else if (const DerivedTypeSpec * derived{GetDerivedTypeSpec(type)}) {
+ } else if (const DerivedTypeSpec *derived{GetDerivedTypeSpec(type)}) {
if (!derived->parameters().empty()) {
messages.Say(
"Parameterized derived type actual argument requires an explicit interface"_err_en_US);
@@ -56,7 +56,7 @@ static void CheckImplicitInterfaceArg(evaluate::ActualArgument &arg,
"%VAL argument must be a scalar numeric or logical expression"_err_en_US);
}
if (const auto *expr{arg.UnwrapExpr()}) {
- if (const Symbol * base{GetFirstSymbol(*expr)};
+ if (const Symbol *base{GetFirstSymbol(*expr)};
base && IsFunctionResult(*base)) {
context.NoteDefinedSymbol(*base);
}
@@ -92,7 +92,7 @@ static void CheckImplicitInterfaceArg(evaluate::ActualArgument &arg,
"Non-intrinsic ELEMENTAL procedure '%s' may not be passed as an actual argument"_err_en_US,
argProcSymbol->name());
} else if (const auto *subp{argProcSymbol->GetUltimate()
- .detailsIf<SubprogramDetails>()}) {
+ .detailsIf<SubprogramDetails>()}) {
if (subp->stmtFunction()) {
evaluate::SayWithDeclaration(messages, *argProcSymbol,
"Statement function '%s' may not be passed as an actual argument"_err_en_US,
@@ -480,10 +480,10 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
"Actual argument associated with TYPE(*) %s may not have a parameterized derived type"_err_en_US,
dummyName);
}
- if (const Symbol *
- tbp{FindImmediateComponent(*actualDerived, [](const Symbol &symbol) {
- return symbol.has<ProcBindingDetails>();
- })}) { // 15.5.2.4(2)
+ if (const Symbol *tbp{
+ FindImmediateComponent(*actualDerived, [](const Symbol &symbol) {
+ return symbol.has<ProcBindingDetails>();
+ })}) { // 15.5.2.4(2)
evaluate::SayWithDeclaration(messages, *tbp,
"Actual argument associated with TYPE(*) %s may not have type-bound procedure '%s'"_err_en_US,
dummyName, tbp->name());
@@ -509,8 +509,8 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
}
}
const Symbol &coarray{actualCoarrayRef->GetLastSymbol()};
- if (const DeclTypeSpec * type{coarray.GetType()}) { // C1537
- if (const DerivedTypeSpec * derived{type->AsDerived()}) {
+ if (const DeclTypeSpec *type{coarray.GetType()}) { // C1537
+ if (const DerivedTypeSpec *derived{type->AsDerived()}) {
if (auto bad{semantics::FindPointerUltimateComponent(*derived)}) {
evaluate::SayWithDeclaration(messages, coarray,
"Coindexed object '%s' with POINTER ultimate component '%s' cannot be associated with %s"_err_en_US,
@@ -764,7 +764,7 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
} else if (dummy.intent != common::Intent::In ||
(dummyIsPointer && !actualIsPointer)) {
if (auto named{evaluate::ExtractNamedEntity(actual)}) {
- if (const Symbol & base{named->GetFirstSymbol()};
+ if (const Symbol &base{named->GetFirstSymbol()};
IsFunctionResult(base)) {
context.NoteDefinedSymbol(base);
}
@@ -1104,7 +1104,7 @@ static void CheckProcedureArg(evaluate::ActualArgument &arg,
parser::ContextualMessages &messages{foldingContext.messages()};
parser::CharBlock location{arg.sourceLocation().value_or(messages.at())};
auto restorer{messages.SetLocation(location)};
- const characteristics::Procedure &interface { dummy.procedure.value() };
+ const characteristics::Procedure &interface{dummy.procedure.value()};
if (const auto *expr{arg.UnwrapExpr()}) {
bool dummyIsPointer{
dummy.attrs.test(characteristics::DummyProcedure::Attr::Pointer)};
@@ -1343,8 +1343,8 @@ static void CheckExplicitInterfaceArg(evaluate::ActualArgument &arg,
messages.Say(
"Actual argument associated with %s is a NULL() pointer without a MOLD= to provide a character length"_err_en_US,
...
[truncated]
|
|
@llvm/pr-subscribers-flang-openmp Author: Krzysztof Parzyszek (kparzysz) ChangesThere a a bunch of relatively simple changes, mostly the position of the * or & in declarations, or line breaks in declarations (usually) within if-statements. Three manual changes:
Patch is 149.38 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/153959.diff 37 Files Affected:
diff --git a/flang/include/flang/Semantics/scope.h b/flang/include/flang/Semantics/scope.h
index b4046830522b8..417548b62a255 100644
--- a/flang/include/flang/Semantics/scope.h
+++ b/flang/include/flang/Semantics/scope.h
@@ -39,8 +39,8 @@ class SemanticsContext;
struct EquivalenceObject {
EquivalenceObject(Symbol &symbol, std::vector<ConstantSubscript> subscripts,
std::optional<ConstantSubscript> substringStart, parser::CharBlock source)
- : symbol{symbol}, subscripts{subscripts},
- substringStart{substringStart}, source{source} {}
+ : symbol{symbol}, subscripts{subscripts}, substringStart{substringStart},
+ source{source} {}
explicit EquivalenceObject(Symbol &symbol)
: symbol{symbol}, source{symbol.name()} {}
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index 5bde9f39ca0b0..861dd2a20ffec 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -32,7 +32,7 @@ namespace Fortran::parser {
struct Expr;
struct OpenMPDeclareReductionConstruct;
struct OmpMetadirectiveDirective;
-}
+} // namespace Fortran::parser
namespace Fortran::semantics {
diff --git a/flang/include/flang/Semantics/tools.h b/flang/include/flang/Semantics/tools.h
index 966a30f7081fd..9cefe94e0ce79 100644
--- a/flang/include/flang/Semantics/tools.h
+++ b/flang/include/flang/Semantics/tools.h
@@ -203,7 +203,7 @@ bool IsDeviceAllocatable(const Symbol &symbol);
inline bool IsCUDADeviceContext(const Scope *scope) {
if (scope) {
- if (const Symbol * symbol{scope->symbol()}) {
+ if (const Symbol *symbol{scope->symbol()}) {
if (const auto *subp{symbol->detailsIf<SubprogramDetails>()}) {
if (auto attrs{subp->cudaSubprogramAttrs()}) {
return *attrs != common::CUDASubprogramAttrs::Host;
@@ -305,7 +305,7 @@ const Symbol *FindExternallyVisibleObject(const A &, const Scope &) {
template <typename T>
const Symbol *FindExternallyVisibleObject(
const evaluate::Designator<T> &designator, const Scope &scope) {
- if (const Symbol * symbol{designator.GetBaseObject().symbol()}) {
+ if (const Symbol *symbol{designator.GetBaseObject().symbol()}) {
return FindExternallyVisibleObject(*symbol, scope, false);
} else if (std::holds_alternative<evaluate::CoarrayRef>(designator.u)) {
// Coindexed values are visible even if their image-local objects are not.
@@ -670,8 +670,8 @@ class LabelEnforce {
LabelEnforce(SemanticsContext &context, std::set<parser::Label> &&labels,
parser::CharBlock constructSourcePosition, const char *construct)
: context_{context}, labels_{labels},
- constructSourcePosition_{constructSourcePosition}, construct_{
- construct} {}
+ constructSourcePosition_{constructSourcePosition},
+ construct_{construct} {}
template <typename T> bool Pre(const T &) { return true; }
template <typename T> bool Pre(const parser::Statement<T> &statement) {
currentStatementSourcePosition_ = statement.source;
diff --git a/flang/include/flang/Semantics/unparse-with-symbols.h b/flang/include/flang/Semantics/unparse-with-symbols.h
index 702911bbab627..26e28f771689c 100644
--- a/flang/include/flang/Semantics/unparse-with-symbols.h
+++ b/flang/include/flang/Semantics/unparse-with-symbols.h
@@ -32,6 +32,6 @@ void UnparseWithSymbols(llvm::raw_ostream &, const parser::Program &,
void UnparseWithModules(llvm::raw_ostream &, SemanticsContext &,
const parser::Program &,
parser::Encoding encoding = parser::Encoding::UTF_8);
-}
+} // namespace Fortran::semantics
#endif // FORTRAN_SEMANTICS_UNPARSE_WITH_SYMBOLS_H_
diff --git a/flang/lib/Semantics/assignment.cpp b/flang/lib/Semantics/assignment.cpp
index 88e08887160d9..bbe3e74b79755 100644
--- a/flang/lib/Semantics/assignment.cpp
+++ b/flang/lib/Semantics/assignment.cpp
@@ -62,7 +62,7 @@ class AssignmentContext {
};
void AssignmentContext::Analyze(const parser::AssignmentStmt &stmt) {
- if (const evaluate::Assignment * assignment{GetAssignment(stmt)}) {
+ if (const evaluate::Assignment *assignment{GetAssignment(stmt)}) {
const SomeExpr &lhs{assignment->lhs};
const SomeExpr &rhs{assignment->rhs};
auto lhsLoc{std::get<parser::Variable>(stmt.t).GetSource()};
@@ -72,8 +72,8 @@ void AssignmentContext::Analyze(const parser::AssignmentStmt &stmt) {
std::holds_alternative<evaluate::ProcedureRef>(assignment->u)};
if (isDefinedAssignment) {
flags.set(DefinabilityFlag::AllowEventLockOrNotifyType);
- } else if (const Symbol *
- whole{evaluate::UnwrapWholeSymbolOrComponentDataRef(lhs)}) {
+ } else if (const Symbol *whole{
+ evaluate::UnwrapWholeSymbolOrComponentDataRef(lhs)}) {
if (IsAllocatable(whole->GetUltimate())) {
flags.set(DefinabilityFlag::PotentialDeallocation);
}
@@ -101,7 +101,7 @@ void AssignmentContext::Analyze(const parser::AssignmentStmt &stmt) {
void AssignmentContext::Analyze(const parser::PointerAssignmentStmt &stmt) {
CHECK(whereDepth_ == 0);
- if (const evaluate::Assignment * assignment{GetAssignment(stmt)}) {
+ if (const evaluate::Assignment *assignment{GetAssignment(stmt)}) {
parser::CharBlock at{context_.location().value()};
auto restorer{foldingContext().messages().SetLocation(at)};
CheckPointerAssignment(context_, *assignment, context_.FindScope(at));
@@ -125,7 +125,7 @@ static std::optional<std::string> GetPointerComponentDesignatorName(
bool CheckCopyabilityInPureScope(parser::ContextualMessages &messages,
const SomeExpr &expr, const Scope &scope) {
if (auto pointer{GetPointerComponentDesignatorName(expr)}) {
- if (const Symbol * base{GetFirstSymbol(expr)}) {
+ if (const Symbol *base{GetFirstSymbol(expr)}) {
const char *why{WhyBaseObjectIsSuspicious(base->GetUltimate(), scope)};
if (!why) {
if (auto coarray{evaluate::ExtractCoarrayRef(expr)}) {
diff --git a/flang/lib/Semantics/canonicalize-acc.cpp b/flang/lib/Semantics/canonicalize-acc.cpp
index 108fd33c2ed94..3f7889bf96ac5 100644
--- a/flang/lib/Semantics/canonicalize-acc.cpp
+++ b/flang/lib/Semantics/canonicalize-acc.cpp
@@ -68,7 +68,7 @@ class CanonicalizationOfAcc {
return; // Tile is not allowed on DO CONCURRENT
}
for (const parser::DoConstruct *loop{&outer}; loop && tileArgNb > 0;
- --tileArgNb) {
+ --tileArgNb) {
const auto &block{std::get<parser::Block>(loop->t)};
const auto it{block.begin()};
loop = it != block.end() ? parser::Unwrap<parser::DoConstruct>(*it)
diff --git a/flang/lib/Semantics/check-acc-structure.cpp b/flang/lib/Semantics/check-acc-structure.cpp
index 051abdceba19d..db388e2737a90 100644
--- a/flang/lib/Semantics/check-acc-structure.cpp
+++ b/flang/lib/Semantics/check-acc-structure.cpp
@@ -667,8 +667,8 @@ void AccStructureChecker::Enter(const parser::OpenACCCacheConstruct &x) {
PushContextAndClauseSets(verbatim.source, llvm::acc::Directive::ACCD_cache);
SetContextDirectiveSource(verbatim.source);
if (loopNestLevel == 0) {
- context_.Say(verbatim.source,
- "The CACHE directive must be inside a loop"_err_en_US);
+ context_.Say(
+ verbatim.source, "The CACHE directive must be inside a loop"_err_en_US);
}
}
void AccStructureChecker::Leave(const parser::OpenACCCacheConstruct &x) {
diff --git a/flang/lib/Semantics/check-allocate.cpp b/flang/lib/Semantics/check-allocate.cpp
index 08053594c12e4..73395da1ee9b4 100644
--- a/flang/lib/Semantics/check-allocate.cpp
+++ b/flang/lib/Semantics/check-allocate.cpp
@@ -74,7 +74,7 @@ class AllocationCheckerHelper {
if (type_->category() == DeclTypeSpec::Category::Character) {
hasDeferredTypeParameter_ =
type_->characterTypeSpec().length().isDeferred();
- } else if (const DerivedTypeSpec * derivedTypeSpec{type_->AsDerived()}) {
+ } else if (const DerivedTypeSpec *derivedTypeSpec{type_->AsDerived()}) {
for (const auto &pair : derivedTypeSpec->parameters()) {
hasDeferredTypeParameter_ |= pair.second.isDeferred();
}
@@ -114,7 +114,7 @@ static std::optional<AllocateCheckerInfo> CheckAllocateOptions(
}
info.gotTypeSpec = true;
info.typeSpecLoc = parser::FindSourceLocation(*typeSpec);
- if (const DerivedTypeSpec * derived{info.typeSpec->AsDerived()}) {
+ if (const DerivedTypeSpec *derived{info.typeSpec->AsDerived()}) {
// C937
if (auto it{FindCoarrayUltimateComponent(*derived)}) {
context
@@ -224,8 +224,8 @@ static std::optional<AllocateCheckerInfo> CheckAllocateOptions(
}
info.sourceExprRank = expr->Rank();
info.sourceExprLoc = parserSourceExpr->source;
- if (const DerivedTypeSpec *
- derived{evaluate::GetDerivedTypeSpec(info.sourceExprType)}) {
+ if (const DerivedTypeSpec *derived{
+ evaluate::GetDerivedTypeSpec(info.sourceExprType)}) {
// C949
if (auto it{FindCoarrayUltimateComponent(*derived)}) {
context
@@ -279,13 +279,13 @@ static std::optional<AllocateCheckerInfo> CheckAllocateOptions(
// in this test.
static bool IsTypeCompatible(
const DeclTypeSpec &type1, const DerivedTypeSpec &derivedType2) {
- if (const DerivedTypeSpec * derivedType1{type1.AsDerived()}) {
+ if (const DerivedTypeSpec *derivedType1{type1.AsDerived()}) {
if (type1.category() == DeclTypeSpec::Category::TypeDerived) {
return evaluate::AreSameDerivedTypeIgnoringTypeParameters(
*derivedType1, derivedType2);
} else if (type1.category() == DeclTypeSpec::Category::ClassDerived) {
for (const DerivedTypeSpec *parent{&derivedType2}; parent;
- parent = parent->typeSymbol().GetParentTypeSpec()) {
+ parent = parent->typeSymbol().GetParentTypeSpec()) {
if (evaluate::AreSameDerivedTypeIgnoringTypeParameters(
*derivedType1, *parent)) {
return true;
@@ -303,13 +303,13 @@ static bool IsTypeCompatible(
// cannot be allocatable (C709)
return true;
}
- if (const IntrinsicTypeSpec * intrinsicType2{type2.AsIntrinsic()}) {
- if (const IntrinsicTypeSpec * intrinsicType1{type1.AsIntrinsic()}) {
+ if (const IntrinsicTypeSpec *intrinsicType2{type2.AsIntrinsic()}) {
+ if (const IntrinsicTypeSpec *intrinsicType1{type1.AsIntrinsic()}) {
return intrinsicType1->category() == intrinsicType2->category();
} else {
return false;
}
- } else if (const DerivedTypeSpec * derivedType2{type2.AsDerived()}) {
+ } else if (const DerivedTypeSpec *derivedType2{type2.AsDerived()}) {
return IsTypeCompatible(type1, *derivedType2);
}
return false;
@@ -323,7 +323,7 @@ static bool IsTypeCompatible(
return true;
}
if (type2.category() != evaluate::TypeCategory::Derived) {
- if (const IntrinsicTypeSpec * intrinsicType1{type1.AsIntrinsic()}) {
+ if (const IntrinsicTypeSpec *intrinsicType1{type1.AsIntrinsic()}) {
return intrinsicType1->category() == type2.category();
} else {
return false;
@@ -348,16 +348,16 @@ static bool HaveSameAssumedTypeParameters(
}
// It is possible to reach this if type1 is unlimited polymorphic
return !type2LengthIsAssumed;
- } else if (const DerivedTypeSpec * derivedType2{type2.AsDerived()}) {
+ } else if (const DerivedTypeSpec *derivedType2{type2.AsDerived()}) {
int type2AssumedParametersCount{0};
int type1AssumedParametersCount{0};
for (const auto &pair : derivedType2->parameters()) {
type2AssumedParametersCount += pair.second.isAssumed();
}
// type1 may be unlimited polymorphic
- if (const DerivedTypeSpec * derivedType1{type1.AsDerived()}) {
+ if (const DerivedTypeSpec *derivedType1{type1.AsDerived()}) {
for (auto it{derivedType1->parameters().begin()};
- it != derivedType1->parameters().end(); ++it) {
+ it != derivedType1->parameters().end(); ++it) {
if (it->second.isAssumed()) {
++type1AssumedParametersCount;
const ParamValue *param{derivedType2->FindParameter(it->first)};
@@ -378,8 +378,8 @@ static bool HaveSameAssumedTypeParameters(
static std::optional<std::int64_t> GetTypeParameterInt64Value(
const Symbol ¶meterSymbol, const DerivedTypeSpec &derivedType) {
- if (const ParamValue *
- paramValue{derivedType.FindParameter(parameterSymbol.name())}) {
+ if (const ParamValue *paramValue{
+ derivedType.FindParameter(parameterSymbol.name())}) {
return evaluate::ToInt64(paramValue->GetExplicit());
}
return std::nullopt;
@@ -403,11 +403,11 @@ static bool HaveCompatibleTypeParameters(
if (type1.category() == DeclTypeSpec::Category::ClassStar) {
return true;
}
- if (const IntrinsicTypeSpec * intrinsicType1{type1.AsIntrinsic()}) {
+ if (const IntrinsicTypeSpec *intrinsicType1{type1.AsIntrinsic()}) {
return evaluate::ToInt64(intrinsicType1->kind()).value() == type2.kind();
} else if (type2.IsUnlimitedPolymorphic()) {
return false;
- } else if (const DerivedTypeSpec * derivedType1{type1.AsDerived()}) {
+ } else if (const DerivedTypeSpec *derivedType1{type1.AsDerived()}) {
return HaveCompatibleTypeParameters(
*derivedType1, type2.GetDerivedTypeSpec());
} else {
@@ -419,10 +419,10 @@ static bool HaveCompatibleTypeParameters(
const DeclTypeSpec &type1, const DeclTypeSpec &type2) {
if (type1.category() == DeclTypeSpec::Category::ClassStar) {
return true;
- } else if (const IntrinsicTypeSpec * intrinsicType1{type1.AsIntrinsic()}) {
+ } else if (const IntrinsicTypeSpec *intrinsicType1{type1.AsIntrinsic()}) {
const IntrinsicTypeSpec *intrinsicType2{type2.AsIntrinsic()};
return !intrinsicType2 || intrinsicType1->kind() == intrinsicType2->kind();
- } else if (const DerivedTypeSpec * derivedType1{type1.AsDerived()}) {
+ } else if (const DerivedTypeSpec *derivedType1{type1.AsDerived()}) {
const DerivedTypeSpec *derivedType2{type2.AsDerived()};
return !derivedType2 ||
HaveCompatibleTypeParameters(*derivedType1, *derivedType2);
@@ -699,8 +699,7 @@ bool AllocationCheckerHelper::RunCoarrayRelatedChecks(
if (evaluate::IsCoarray(*ultimate_)) {
if (allocateInfo_.gotTypeSpec) {
// C938
- if (const DerivedTypeSpec *
- derived{allocateInfo_.typeSpec->AsDerived()}) {
+ if (const DerivedTypeSpec *derived{allocateInfo_.typeSpec->AsDerived()}) {
if (IsTeamType(derived)) {
context
.Say(allocateInfo_.typeSpecLoc.value(),
@@ -784,8 +783,8 @@ bool AllocationCheckerHelper::RunCoarrayRelatedChecks(
return false;
}
}
- if (const parser::CoindexedNamedObject *
- coindexedObject{parser::GetCoindexedNamedObject(allocateObject_)}) {
+ if (const parser::CoindexedNamedObject *coindexedObject{
+ parser::GetCoindexedNamedObject(allocateObject_)}) {
// C950
context.Say(parser::FindSourceLocation(*coindexedObject),
"Allocatable object must not be coindexed in ALLOCATE"_err_en_US);
diff --git a/flang/lib/Semantics/check-arithmeticif.h b/flang/lib/Semantics/check-arithmeticif.h
index 1d156763e5513..64d0c00b58d75 100644
--- a/flang/lib/Semantics/check-arithmeticif.h
+++ b/flang/lib/Semantics/check-arithmeticif.h
@@ -18,7 +18,7 @@ struct ArithmeticIfStmt;
namespace Fortran::semantics {
class ArithmeticIfStmtChecker : public virtual BaseChecker {
public:
- ArithmeticIfStmtChecker(SemanticsContext &context) : context_(context){};
+ ArithmeticIfStmtChecker(SemanticsContext &context) : context_(context) {}
void Leave(const parser::ArithmeticIfStmt &);
private:
diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index 83f59f0cac3df..b4d0e42c1da32 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -43,7 +43,7 @@ static void CheckImplicitInterfaceArg(evaluate::ActualArgument &arg,
} else if (type->IsUnlimitedPolymorphic()) {
messages.Say(
"Unlimited polymorphic actual argument requires an explicit interface"_err_en_US);
- } else if (const DerivedTypeSpec * derived{GetDerivedTypeSpec(type)}) {
+ } else if (const DerivedTypeSpec *derived{GetDerivedTypeSpec(type)}) {
if (!derived->parameters().empty()) {
messages.Say(
"Parameterized derived type actual argument requires an explicit interface"_err_en_US);
@@ -56,7 +56,7 @@ static void CheckImplicitInterfaceArg(evaluate::ActualArgument &arg,
"%VAL argument must be a scalar numeric or logical expression"_err_en_US);
}
if (const auto *expr{arg.UnwrapExpr()}) {
- if (const Symbol * base{GetFirstSymbol(*expr)};
+ if (const Symbol *base{GetFirstSymbol(*expr)};
base && IsFunctionResult(*base)) {
context.NoteDefinedSymbol(*base);
}
@@ -92,7 +92,7 @@ static void CheckImplicitInterfaceArg(evaluate::ActualArgument &arg,
"Non-intrinsic ELEMENTAL procedure '%s' may not be passed as an actual argument"_err_en_US,
argProcSymbol->name());
} else if (const auto *subp{argProcSymbol->GetUltimate()
- .detailsIf<SubprogramDetails>()}) {
+ .detailsIf<SubprogramDetails>()}) {
if (subp->stmtFunction()) {
evaluate::SayWithDeclaration(messages, *argProcSymbol,
"Statement function '%s' may not be passed as an actual argument"_err_en_US,
@@ -480,10 +480,10 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
"Actual argument associated with TYPE(*) %s may not have a parameterized derived type"_err_en_US,
dummyName);
}
- if (const Symbol *
- tbp{FindImmediateComponent(*actualDerived, [](const Symbol &symbol) {
- return symbol.has<ProcBindingDetails>();
- })}) { // 15.5.2.4(2)
+ if (const Symbol *tbp{
+ FindImmediateComponent(*actualDerived, [](const Symbol &symbol) {
+ return symbol.has<ProcBindingDetails>();
+ })}) { // 15.5.2.4(2)
evaluate::SayWithDeclaration(messages, *tbp,
"Actual argument associated with TYPE(*) %s may not have type-bound procedure '%s'"_err_en_US,
dummyName, tbp->name());
@@ -509,8 +509,8 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
}
}
const Symbol &coarray{actualCoarrayRef->GetLastSymbol()};
- if (const DeclTypeSpec * type{coarray.GetType()}) { // C1537
- if (const DerivedTypeSpec * derived{type->AsDerived()}) {
+ if (const DeclTypeSpec *type{coarray.GetType()}) { // C1537
+ if (const DerivedTypeSpec *derived{type->AsDerived()}) {
if (auto bad{semantics::FindPointerUltimateComponent(*derived)}) {
evaluate::SayWithDeclaration(messages, coarray,
"Coindexed object '%s' with POINTER ultimate component '%s' cannot be associated with %s"_err_en_US,
@@ -764,7 +764,7 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
} else if (dummy.intent != common::Intent::In ||
(dummyIsPointer && !actualIsPointer)) {
if (auto named{evaluate::ExtractNamedEntity(actual)}) {
- if (const Symbol & base{named->GetFirstSymbol()};
+ if (const Symbol &base{named->GetFirstSymbol()};
IsFunctionResult(base)) {
context.NoteDefinedSymbol(base);
}
@@ -1104,7 +1104,7 @@ static void CheckProcedureArg(evaluate::ActualArgument &arg,
parser::ContextualMessages &messages{foldingContext.messages()};
parser::CharBlock location{arg.sourceLocation().value_or(messages.at())};
auto restorer{messages.SetLocation(location)};
- const characteristics::Procedure &interface { dummy.procedure.value() };
+ const characteristics::Procedure &interface{dummy.procedure.value()};
if (const auto *expr{arg.UnwrapExpr()}) {
bool dummyIsPointer{
dummy.attrs.test(characteristics::DummyProcedure::Attr::Pointer)};
@@ -1343,8 +1343,8 @@ static void CheckExplicitInterfaceArg(evaluate::ActualArgument &arg,
messages.Say(
"Actual argument associated with %s is a NULL() pointer without a MOLD= to provide a character length"_err_en_US,
...
[truncated]
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
vzakhari
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me. @klausler are you okay with the batch change of the formatting?
No. It is needless churn that will make it harder to find the original commits that added these lines of code. We should only reformat code that is being modified for a useful purpose. |
|
There is |
There a a bunch of relatively simple changes, mostly the position of the * or & in declarations, or line breaks in declarations (usually) within if-statements.
Three manual changes: