diff --git a/flang/include/flang/Common/uint128.h b/flang/include/flang/Common/uint128.h --- a/flang/include/flang/Common/uint128.h +++ b/flang/include/flang/Common/uint128.h @@ -34,14 +34,14 @@ constexpr Int128(unsigned long n) : low_{n} {} constexpr Int128(unsigned long long n) : low_{n} {} constexpr Int128(int n) - : low_{static_cast(n)}, high_{-static_cast( - n < 0)} {} + : low_{static_cast(n)}, + high_{-static_cast(n < 0)} {} constexpr Int128(long n) - : low_{static_cast(n)}, high_{-static_cast( - n < 0)} {} + : low_{static_cast(n)}, + high_{-static_cast(n < 0)} {} constexpr Int128(long long n) - : low_{static_cast(n)}, high_{-static_cast( - n < 0)} {} + : low_{static_cast(n)}, + high_{-static_cast(n < 0)} {} constexpr Int128(const Int128 &) = default; constexpr Int128(Int128 &&) = default; constexpr Int128 &operator=(const Int128 &) = default; diff --git a/flang/include/flang/Common/unwrap.h b/flang/include/flang/Common/unwrap.h --- a/flang/include/flang/Common/unwrap.h +++ b/flang/include/flang/Common/unwrap.h @@ -148,7 +148,7 @@ // Returns a copy of a wrapped value, if present, otherwise a vacant optional. template std::optional UnwrapCopy(const B &x) { - if (const A * p{Unwrap(x)}) { + if (const A *p{Unwrap(x)}) { return std::make_optional(*p); } else { return std::nullopt; diff --git a/flang/include/flang/Evaluate/call.h b/flang/include/flang/Evaluate/call.h --- a/flang/include/flang/Evaluate/call.h +++ b/flang/include/flang/Evaluate/call.h @@ -96,7 +96,7 @@ } const Symbol *GetAssumedTypeDummy() const { - if (const AssumedType * aType{std::get_if(&u_)}) { + if (const AssumedType *aType{std::get_if(&u_)}) { return &aType->symbol(); } else { return nullptr; diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h --- a/flang/include/flang/Evaluate/tools.h +++ b/flang/include/flang/Evaluate/tools.h @@ -331,7 +331,7 @@ if (auto dataRef{ExtractDataRef(expr, intoSubstring)}) { const DataRef *ref{&*dataRef}; if (skipComponents) { - while (const Component * component{std::get_if(&ref->u)}) { + while (const Component *component{std::get_if(&ref->u)}) { ref = &component->base(); } } @@ -380,7 +380,7 @@ return common::visit(*this, dataRef.u); } std::optional operator()(const NamedEntity &named) const { - if (const Component * component{named.UnwrapComponent()}) { + if (const Component *component{named.UnwrapComponent()}) { return (*this)(*component); } else { return std::nullopt; @@ -414,7 +414,7 @@ // extract and return that symbol, else null. template const Symbol *UnwrapWholeSymbolDataRef(const A &x) { if (auto dataRef{ExtractDataRef(x)}) { - if (const SymbolRef * p{std::get_if(&dataRef->u)}) { + if (const SymbolRef *p{std::get_if(&dataRef->u)}) { return &p->get(); } } @@ -426,9 +426,9 @@ template const Symbol *UnwrapWholeSymbolOrComponentDataRef(const A &x) { if (auto dataRef{ExtractDataRef(x)}) { - if (const SymbolRef * p{std::get_if(&dataRef->u)}) { + if (const SymbolRef *p{std::get_if(&dataRef->u)}) { return &p->get(); - } else if (const Component * c{std::get_if(&dataRef->u)}) { + } else if (const Component *c{std::get_if(&dataRef->u)}) { if (c->base().Rank() == 0) { return &c->GetLastSymbol(); } @@ -443,13 +443,13 @@ template const Symbol *UnwrapWholeSymbolOrComponentOrCoarrayRef(const A &x) { if (auto dataRef{ExtractDataRef(x)}) { - if (const SymbolRef * p{std::get_if(&dataRef->u)}) { + if (const SymbolRef *p{std::get_if(&dataRef->u)}) { return &p->get(); - } else if (const Component * c{std::get_if(&dataRef->u)}) { + } else if (const Component *c{std::get_if(&dataRef->u)}) { if (c->base().Rank() == 0) { return &c->GetLastSymbol(); } - } else if (const CoarrayRef * c{std::get_if(&dataRef->u)}) { + } else if (const CoarrayRef *c{std::get_if(&dataRef->u)}) { if (c->subscript().empty()) { return &c->GetLastSymbol(); } @@ -902,7 +902,7 @@ // its set of attributes, otherwise the empty set. Also works on variables that // are pointer results of functions. template semantics::Attrs GetAttrs(const A &x) { - if (const Symbol * symbol{GetLastSymbol(x)}) { + if (const Symbol *symbol{GetLastSymbol(x)}) { return symbol->attrs(); } else { return {}; @@ -913,7 +913,7 @@ inline semantics::Attrs GetAttrs>(const Expr &x) { if (IsVariable(x)) { if (const auto *procRef{GetProcedureRef(x)}) { - if (const Symbol * interface{procRef->proc().GetInterfaceSymbol()}) { + if (const Symbol *interface{procRef->proc().GetInterfaceSymbol()}) { if (const auto *details{ interface->detailsIf()}) { if (details->isFunction() && @@ -925,7 +925,7 @@ } } } - if (const Symbol * symbol{GetLastSymbol(x)}) { + if (const Symbol *symbol{GetLastSymbol(x)}) { return symbol->attrs(); } else { return {}; diff --git a/flang/include/flang/Evaluate/traverse.h b/flang/include/flang/Evaluate/traverse.h --- a/flang/include/flang/Evaluate/traverse.h +++ b/flang/include/flang/Evaluate/traverse.h @@ -134,7 +134,7 @@ return Combine(x.base(), x.symbol()); } Result operator()(const NamedEntity &x) const { - if (const Component * component{x.UnwrapComponent()}) { + if (const Component *component{x.UnwrapComponent()}) { return visitor_(*component); } else { return visitor_(DEREF(x.UnwrapSymbolRef())); @@ -176,9 +176,9 @@ return visitor_.Default(); } Result operator()(const ProcedureDesignator &x) const { - if (const Component * component{x.GetComponent()}) { + if (const Component *component{x.GetComponent()}) { return visitor_(*component); - } else if (const Symbol * symbol{x.GetSymbol()}) { + } else if (const Symbol *symbol{x.GetSymbol()}) { return visitor_(*symbol); } else { return visitor_(DEREF(x.GetSpecificIntrinsic())); diff --git a/flang/include/flang/Evaluate/type.h b/flang/include/flang/Evaluate/type.h --- a/flang/include/flang/Evaluate/type.h +++ b/flang/include/flang/Evaluate/type.h @@ -100,8 +100,8 @@ // When a known length is presented, resolve it to its effective // length of zero if it is negative. constexpr DynamicType(int k, std::int64_t len) - : category_{TypeCategory::Character}, kind_{k}, knownLength_{ - len >= 0 ? len : 0} { + : category_{TypeCategory::Character}, kind_{k}, + knownLength_{len >= 0 ? len : 0} { CHECK(IsValidKindOfIntrinsicType(category_, kind_)); } explicit constexpr DynamicType( diff --git a/flang/include/flang/Lower/BoxAnalyzer.h b/flang/include/flang/Lower/BoxAnalyzer.h --- a/flang/include/flang/Lower/BoxAnalyzer.h +++ b/flang/include/flang/Lower/BoxAnalyzer.h @@ -160,8 +160,8 @@ StaticArrayStaticChar(const Fortran::semantics::Symbol &sym, int64_t len, llvm::SmallVectorImpl &&lbounds, llvm::SmallVectorImpl &&shapes) - : ScalarStaticChar{sym, len}, LBoundsAndShape{std::move(lbounds), - std::move(shapes)} {} + : ScalarStaticChar{sym, len}, + LBoundsAndShape{std::move(lbounds), std::move(shapes)} {} static constexpr bool staticSize() { return ScalarStaticChar::staticSize() && LBoundsAndShape::staticSize(); @@ -174,13 +174,13 @@ const Fortran::lower::SomeExpr &len, llvm::SmallVectorImpl &&lbounds, llvm::SmallVectorImpl &&shapes) - : ScalarDynamicChar{sym, len}, LBoundsAndShape{std::move(lbounds), - std::move(shapes)} {} + : ScalarDynamicChar{sym, len}, + LBoundsAndShape{std::move(lbounds), std::move(shapes)} {} StaticArrayDynamicChar(const Fortran::semantics::Symbol &sym, llvm::SmallVectorImpl &&lbounds, llvm::SmallVectorImpl &&shapes) - : ScalarDynamicChar{sym}, LBoundsAndShape{std::move(lbounds), - std::move(shapes)} {} + : ScalarDynamicChar{sym}, + LBoundsAndShape{std::move(lbounds), std::move(shapes)} {} static constexpr bool staticSize() { return ScalarDynamicChar::staticSize() && LBoundsAndShape::staticSize(); diff --git a/flang/include/flang/Lower/OpenACC.h b/flang/include/flang/Lower/OpenACC.h --- a/flang/include/flang/Lower/OpenACC.h +++ b/flang/include/flang/Lower/OpenACC.h @@ -19,7 +19,7 @@ template class SmallVector; class StringRef; -} +} // namespace llvm namespace mlir { class Location; diff --git a/flang/include/flang/Lower/VectorSubscripts.h b/flang/include/flang/Lower/VectorSubscripts.h --- a/flang/include/flang/Lower/VectorSubscripts.h +++ b/flang/include/flang/Lower/VectorSubscripts.h @@ -81,8 +81,8 @@ llvm::SmallVector &&loweredSubscripts, llvm::SmallVector &&componentPath, MaybeSubstring substringBounds, mlir::Type elementType) - : loweredBase{std::move(loweredBase)}, loweredSubscripts{std::move( - loweredSubscripts)}, + : loweredBase{std::move(loweredBase)}, + loweredSubscripts{std::move(loweredSubscripts)}, componentPath{std::move(componentPath)}, substringBounds{substringBounds}, elementType{elementType} {}; diff --git a/flang/include/flang/Optimizer/Builder/BoxValue.h b/flang/include/flang/Optimizer/Builder/BoxValue.h --- a/flang/include/flang/Optimizer/Builder/BoxValue.h +++ b/flang/include/flang/Optimizer/Builder/BoxValue.h @@ -127,8 +127,8 @@ AbstractArrayBox() = default; AbstractArrayBox(llvm::ArrayRef extents, llvm::ArrayRef lbounds) - : extents{extents.begin(), extents.end()}, lbounds{lbounds.begin(), - lbounds.end()} {} + : extents{extents.begin(), extents.end()}, + lbounds{lbounds.begin(), lbounds.end()} {} // Every array has extents that describe its shape. const llvm::SmallVectorImpl &getExtents() const { @@ -366,8 +366,8 @@ /// in the address type. MutableBoxValue(mlir::Value addr, mlir::ValueRange lenParameters, MutableProperties mutableProperties) - : AbstractIrBox(addr), lenParams{lenParameters.begin(), - lenParameters.end()}, + : AbstractIrBox(addr), + lenParams{lenParameters.begin(), lenParameters.end()}, mutableProperties{mutableProperties} { // Currently only accepts fir.(ref/ptr/heap)> mlir::Value for // the address. This may change if we accept diff --git a/flang/include/flang/Optimizer/Support/InternalNames.h b/flang/include/flang/Optimizer/Support/InternalNames.h --- a/flang/include/flang/Optimizer/Support/InternalNames.h +++ b/flang/include/flang/Optimizer/Support/InternalNames.h @@ -55,9 +55,9 @@ DeconstructedName(llvm::ArrayRef modules, llvm::ArrayRef procs, std::int64_t blockId, llvm::StringRef name, llvm::ArrayRef kinds) - : modules{modules.begin(), modules.end()}, procs{procs.begin(), - procs.end()}, - blockId{blockId}, name{name}, kinds{kinds.begin(), kinds.end()} {} + : modules{modules.begin(), modules.end()}, + procs{procs.begin(), procs.end()}, blockId{blockId}, name{name}, + kinds{kinds.begin(), kinds.end()} {} llvm::SmallVector modules; llvm::SmallVector procs; diff --git a/flang/include/flang/Parser/format-specification.h b/flang/include/flang/Parser/format-specification.h --- a/flang/include/flang/Parser/format-specification.h +++ b/flang/include/flang/Parser/format-specification.h @@ -41,8 +41,8 @@ IntrinsicTypeDataEditDesc &operator=(IntrinsicTypeDataEditDesc &&) = default; IntrinsicTypeDataEditDesc(Kind &&k, std::optional &&w, std::optional &&d, std::optional &&e) - : kind{k}, width{std::move(w)}, digits{std::move(d)}, exponentWidth{ - std::move(e)} {} + : kind{k}, width{std::move(w)}, digits{std::move(d)}, + exponentWidth{std::move(e)} {} Kind kind; std::optional width; // w std::optional digits; // m or d diff --git a/flang/include/flang/Parser/instrumented-parser.h b/flang/include/flang/Parser/instrumented-parser.h --- a/flang/include/flang/Parser/instrumented-parser.h +++ b/flang/include/flang/Parser/instrumented-parser.h @@ -54,8 +54,8 @@ constexpr InstrumentedParser(const MessageFixedText &tag, const PA &parser) : tag_{tag}, parser_{parser} {} std::optional Parse(ParseState &state) const { - if (UserState * ustate{state.userState()}) { - if (ParsingLog * log{ustate->log()}) { + if (UserState *ustate{state.userState()}) { + if (ParsingLog *log{ustate->log()}) { const char *at{state.GetLocation()}; if (log->Fails(at, tag_, state)) { return std::nullopt; diff --git a/flang/include/flang/Parser/parse-tree.h b/flang/include/flang/Parser/parse-tree.h --- a/flang/include/flang/Parser/parse-tree.h +++ b/flang/include/flang/Parser/parse-tree.h @@ -1770,8 +1770,8 @@ BOILERPLATE(PartRef); PartRef(Name &&n, std::list &&ss, std::optional &&is) - : name{std::move(n)}, - subscripts(std::move(ss)), imageSelector{std::move(is)} {} + : name{std::move(n)}, subscripts(std::move(ss)), + imageSelector{std::move(is)} {} Name name; std::list subscripts; std::optional imageSelector; diff --git a/flang/include/flang/Runtime/array-constructor.h b/flang/include/flang/Runtime/array-constructor.h --- a/flang/include/flang/Runtime/array-constructor.h +++ b/flang/include/flang/Runtime/array-constructor.h @@ -26,8 +26,8 @@ int sourceLine, bool useValueLengthParameters) : to{to}, nextValuePosition{nextValuePosition}, actualAllocationSize{actualAllocationSize}, sourceFile{sourceFile}, - sourceLine{sourceLine}, useValueLengthParameters_{ - useValueLengthParameters} {} + sourceLine{sourceLine}, + useValueLengthParameters_{useValueLengthParameters} {} bool useValueLengthParameters() const { return useValueLengthParameters_; } diff --git a/flang/include/flang/Runtime/descriptor.h b/flang/include/flang/Runtime/descriptor.h --- a/flang/include/flang/Runtime/descriptor.h +++ b/flang/include/flang/Runtime/descriptor.h @@ -431,7 +431,7 @@ RT_API_ATTRS void Check() { assert(descriptor().rank() <= maxRank); assert(descriptor().SizeInBytes() <= byteSize); - if (DescriptorAddendum * addendum{descriptor().Addendum()}) { + if (DescriptorAddendum *addendum{descriptor().Addendum()}) { assert(hasAddendum); assert(addendum->LenParameters() <= maxLengthTypeParameters); } else { diff --git a/flang/include/flang/Semantics/scope.h b/flang/include/flang/Semantics/scope.h --- a/flang/include/flang/Semantics/scope.h +++ b/flang/include/flang/Semantics/scope.h @@ -39,8 +39,8 @@ struct EquivalenceObject { EquivalenceObject(Symbol &symbol, std::vector subscripts, std::optional 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/tools.h b/flang/include/flang/Semantics/tools.h --- a/flang/include/flang/Semantics/tools.h +++ b/flang/include/flang/Semantics/tools.h @@ -192,7 +192,7 @@ 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()}) { if (auto attrs{subp->cudaSubprogramAttrs()}) { return *attrs != common::CUDASubprogramAttrs::Host; @@ -252,7 +252,7 @@ template const Symbol *FindExternallyVisibleObject( const evaluate::Designator &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(designator.u)) { // Coindexed values are visible even if their image-local objects are not. @@ -593,8 +593,8 @@ LabelEnforce(SemanticsContext &context, std::set &&labels, parser::CharBlock constructSourcePosition, const char *construct) : context_{context}, labels_{labels}, - constructSourcePosition_{constructSourcePosition}, construct_{ - construct} {} + constructSourcePosition_{constructSourcePosition}, + construct_{construct} {} template bool Pre(const T &) { return true; } template bool Pre(const parser::Statement &statement) { currentStatementSourcePosition_ = statement.source; diff --git a/flang/lib/Evaluate/call.cpp b/flang/lib/Evaluate/call.cpp --- a/flang/lib/Evaluate/call.cpp +++ b/flang/lib/Evaluate/call.cpp @@ -67,8 +67,8 @@ SpecificIntrinsic::SpecificIntrinsic( IntrinsicProcedure n, characteristics::Procedure &&chars) - : name{n}, characteristics{ - new characteristics::Procedure{std::move(chars)}} {} + : name{n}, + characteristics{new characteristics::Procedure{std::move(chars)}} {} DEFINE_DEFAULT_CONSTRUCTORS_AND_ASSIGNMENTS(SpecificIntrinsic) @@ -99,7 +99,7 @@ } int ProcedureDesignator::Rank() const { - if (const Symbol * symbol{GetSymbol()}) { + if (const Symbol *symbol{GetSymbol()}) { // Subtle: will be zero for functions returning procedure pointers return symbol->Rank(); } @@ -117,7 +117,7 @@ } const Symbol *ProcedureDesignator::GetInterfaceSymbol() const { - if (const Symbol * symbol{GetSymbol()}) { + if (const Symbol *symbol{GetSymbol()}) { const Symbol &ultimate{symbol->GetUltimate()}; if (const auto *proc{ultimate.detailsIf()}) { return proc->procInterface(); @@ -132,9 +132,9 @@ } bool ProcedureDesignator::IsElemental() const { - if (const Symbol * interface{GetInterfaceSymbol()}) { + if (const Symbol *interface{GetInterfaceSymbol()}) { return IsElementalProcedure(*interface); - } else if (const Symbol * symbol{GetSymbol()}) { + } else if (const Symbol *symbol{GetSymbol()}) { return IsElementalProcedure(*symbol); } else if (const auto *intrinsic{std::get_if(&u)}) { return intrinsic->characteristics.value().attrs.test( @@ -146,9 +146,9 @@ } bool ProcedureDesignator::IsPure() const { - if (const Symbol * interface{GetInterfaceSymbol()}) { + if (const Symbol *interface{GetInterfaceSymbol()}) { return IsPureProcedure(*interface); - } else if (const Symbol * symbol{GetSymbol()}) { + } else if (const Symbol *symbol{GetSymbol()}) { return IsPureProcedure(*symbol); } else if (const auto *intrinsic{std::get_if(&u)}) { return intrinsic->characteristics.value().attrs.test( diff --git a/flang/lib/Evaluate/characteristics.cpp b/flang/lib/Evaluate/characteristics.cpp --- a/flang/lib/Evaluate/characteristics.cpp +++ b/flang/lib/Evaluate/characteristics.cpp @@ -97,7 +97,7 @@ if constexpr (std::is_same_v || std::is_same_v || std::is_same_v) { - if (const semantics::DeclTypeSpec * type{ultimate.GetType()}) { + if (const semantics::DeclTypeSpec *type{ultimate.GetType()}) { if (auto dyType{DynamicType::From(*type)}) { TypeAndShape result{ std::move(*dyType), GetShape(context, ultimate)}; @@ -151,7 +151,7 @@ const ActualArgument &arg, FoldingContext &context) { if (const auto *expr{arg.UnwrapExpr()}) { return Characterize(*expr, context); - } else if (const Symbol * assumed{arg.GetAssumedTypeDummy()}) { + } else if (const Symbol *assumed{arg.GetAssumedTypeDummy()}) { return Characterize(*assumed, context); } else { return std::nullopt; @@ -417,9 +417,8 @@ } bool DummyDataObject::CanBePassedViaImplicitInterface() const { - if ((attrs & - Attrs{Attr::Allocatable, Attr::Asynchronous, Attr::Optional, - Attr::Pointer, Attr::Target, Attr::Value, Attr::Volatile}) + if ((attrs &Attrs{Attr::Allocatable, Attr::Asynchronous, Attr::Optional, + Attr::Pointer, Attr::Target, Attr::Value, Attr::Volatile}) .any()) { return false; // 15.4.2.2(3)(a) } else if ((type.attrs() & @@ -493,7 +492,7 @@ } bool DummyProcedure::CanBePassedViaImplicitInterface() const { - if ((attrs & Attrs{Attr::Optional, Attr::Pointer}).any()) { + if ((attrs &Attrs{Attr::Optional, Attr::Pointer}).any()) { return false; // 15.4.2.2(3)(a) } return true; @@ -595,8 +594,8 @@ } return intrinsic; } - if (const semantics::Symbol * - interfaceSymbol{proc.procInterface()}) { + if (const semantics::Symbol *interfaceSymbol{ + proc.procInterface()}) { auto interface { CharacterizeProcedure(*interfaceSymbol, context, seenProcs) }; @@ -659,7 +658,7 @@ return CharacterizeProcedure(assoc.symbol(), context, seenProcs); }, [&](const semantics::GenericDetails &generic) { - if (const semantics::Symbol * specific{generic.specific()}) { + if (const semantics::Symbol *specific{generic.specific()}) { return CharacterizeProcedure(*specific, context, seenProcs); } else { return std::optional{}; @@ -1245,8 +1244,7 @@ const ProcedureRef &ref, FoldingContext &context) { if (auto callee{Characterize(ref.proc(), context)}) { if (callee->functionResult) { - if (const Procedure * - proc{callee->functionResult->IsProcedurePointer()}) { + if (const Procedure *proc{callee->functionResult->IsProcedurePointer()}) { return {*proc}; } } diff --git a/flang/lib/Evaluate/check-expression.cpp b/flang/lib/Evaluate/check-expression.cpp --- a/flang/lib/Evaluate/check-expression.cpp +++ b/flang/lib/Evaluate/check-expression.cpp @@ -290,7 +290,7 @@ return (*this)(x.left()); } bool operator()(const ProcedureRef &x) const { - if (const SpecificIntrinsic * intrinsic{x.proc().GetSpecificIntrinsic()}) { + if (const SpecificIntrinsic *intrinsic{x.proc().GetSpecificIntrinsic()}) { return intrinsic->characteristics.value().attrs.test( characteristics::Procedure::Attr::NullPointer); } @@ -1033,7 +1033,7 @@ sf_.name()}; } Result operator()(const ProcedureDesignator &proc) const { - if (const Symbol * symbol{proc.GetSymbol()}) { + if (const Symbol *symbol{proc.GetSymbol()}) { const Symbol &ultimate{symbol->GetUltimate()}; if (const auto *subp{ ultimate.detailsIf()}) { diff --git a/flang/lib/Evaluate/constant.cpp b/flang/lib/Evaluate/constant.cpp --- a/flang/lib/Evaluate/constant.cpp +++ b/flang/lib/Evaluate/constant.cpp @@ -202,8 +202,8 @@ template Constant>::Constant(Scalar &&str) - : values_{std::move(str)}, length_{static_cast( - values_.size())} {} + : values_{std::move(str)}, + length_{static_cast(values_.size())} {} template Constant>::Constant(ConstantSubscript len, diff --git a/flang/lib/Evaluate/expression.cpp b/flang/lib/Evaluate/expression.cpp --- a/flang/lib/Evaluate/expression.cpp +++ b/flang/lib/Evaluate/expression.cpp @@ -236,8 +236,8 @@ std::optional> StructureConstructor::CreateParentComponent( const Symbol &component) const { - if (const semantics::DerivedTypeSpec * - parentSpec{GetParentTypeSpec(derivedTypeSpec())}) { + if (const semantics::DerivedTypeSpec *parentSpec{ + GetParentTypeSpec(derivedTypeSpec())}) { StructureConstructor structureConstructor{*parentSpec}; if (const auto *parentDetails{ component.detailsIf()}) { @@ -263,7 +263,7 @@ if (symbol.test(Symbol::Flag::ParentComp)) { // we have a created parent component const auto &compObject{symbol.get()}; - if (const semantics::DeclTypeSpec * compType{compObject.type()}) { + if (const semantics::DeclTypeSpec *compType{compObject.type()}) { const semantics::DerivedTypeSpec &dtSpec{compType->derivedTypeSpec()}; const semantics::Symbol &compTypeSymbol{dtSpec.typeSymbol()}; return &compTypeSymbol; @@ -283,7 +283,7 @@ } // The component wasn't there directly, see if we're looking for the parent // component of an extended type - if (const Symbol * typeSymbol{GetParentComponentSymbol(component)}) { + if (const Symbol *typeSymbol{GetParentComponentSymbol(component)}) { return CreateParentComponent(*typeSymbol); } // Look for the component in the parent type component. The parent type diff --git a/flang/lib/Evaluate/fold-designator.cpp b/flang/lib/Evaluate/fold-designator.cpp --- a/flang/lib/Evaluate/fold-designator.cpp +++ b/flang/lib/Evaluate/fold-designator.cpp @@ -197,8 +197,8 @@ std::optional DesignatorFolder::FoldDesignator( const ProcedureDesignator &proc, ConstantSubscript which) { - if (const Symbol * symbol{proc.GetSymbol()}) { - if (const Component * component{proc.GetComponent()}) { + if (const Symbol *symbol{proc.GetSymbol()}) { + if (const Component *component{proc.GetComponent()}) { return FoldDesignator(*component, which); } else if (which > 0) { isEmpty_ = true; @@ -249,7 +249,7 @@ static const Symbol *OffsetToUniqueComponent( const semantics::DerivedTypeSpec &spec, ConstantSubscript offset) { const Symbol *result{nullptr}; - if (const semantics::Scope * scope{spec.scope()}) { + if (const semantics::Scope *scope{spec.scope()}) { for (const auto &pair : *scope) { const Symbol &component{*pair.second}; if (offset >= static_cast(component.offset()) && @@ -290,8 +290,7 @@ } if (result && type->category() == TypeCategory::Derived && size < result->GetLastSymbol().size()) { - if (const Symbol * - component{OffsetToUniqueComponent( + if (const Symbol *component{OffsetToUniqueComponent( type->GetDerivedTypeSpec(), offset)}) { offset -= component->offset(); return OffsetToDataRef(context, diff --git a/flang/lib/Evaluate/fold-implementation.h b/flang/lib/Evaluate/fold-implementation.h --- a/flang/lib/Evaluate/fold-implementation.h +++ b/flang/lib/Evaluate/fold-implementation.h @@ -160,7 +160,7 @@ return std::nullopt; } } - if (Component * component{aRef.base().UnwrapComponent()}) { + if (Component *component{aRef.base().UnwrapComponent()}) { return GetConstantComponent(*component, &subscripts); } else if (std::optional> array{ GetNamedConstant(aRef.base().GetLastSymbol())}) { diff --git a/flang/lib/Evaluate/fold-integer.cpp b/flang/lib/Evaluate/fold-integer.cpp --- a/flang/lib/Evaluate/fold-integer.cpp +++ b/flang/lib/Evaluate/fold-integer.cpp @@ -1269,10 +1269,9 @@ if (base) { // Handling "designator%typeParam". Get the value of the type parameter // from the instantiation of the base - if (const semantics::DeclTypeSpec * - declType{base->GetLastSymbol().GetType()}) { - if (const semantics::ParamValue * - paramValue{ + if (const semantics::DeclTypeSpec *declType{ + base->GetLastSymbol().GetType()}) { + if (const semantics::ParamValue *paramValue{ declType->derivedTypeSpec().FindParameter(parameterName)}) { const semantics::MaybeIntExpr ¶mExpr{paramValue->GetExplicit()}; if (paramExpr && IsConstantExpr(*paramExpr)) { @@ -1288,7 +1287,7 @@ if (const auto *pdt{context.pdtInstance()}) { auto restorer{context.WithoutPDTInstance()}; // don't loop bool isLen{false}; - if (const semantics::Scope * scope{pdt->scope()}) { + if (const semantics::Scope *scope{pdt->scope()}) { auto iter{scope->find(parameterName)}; if (iter != scope->end()) { const Symbol &symbol{*iter->second}; diff --git a/flang/lib/Evaluate/fold-logical.cpp b/flang/lib/Evaluate/fold-logical.cpp --- a/flang/lib/Evaluate/fold-logical.cpp +++ b/flang/lib/Evaluate/fold-logical.cpp @@ -79,7 +79,7 @@ // must be done here. std::optional> constArgs[2]; for (int i{0}; i <= 1; i++) { - if (BOZLiteralConstant * x{UnwrapExpr(args[i])}) { + if (BOZLiteralConstant *x{UnwrapExpr(args[i])}) { constArgs[i] = AsGenericExpr(Constant{std::move(*x)}); } else if (auto *x{UnwrapExpr>(args[i])}) { common::visit( diff --git a/flang/lib/Evaluate/fold.cpp b/flang/lib/Evaluate/fold.cpp --- a/flang/lib/Evaluate/fold.cpp +++ b/flang/lib/Evaluate/fold.cpp @@ -119,7 +119,7 @@ } NamedEntity FoldOperation(FoldingContext &context, NamedEntity &&x) { - if (Component * c{x.UnwrapComponent()}) { + if (Component *c{x.UnwrapComponent()}) { return NamedEntity{FoldOperation(context, std::move(*c))}; } else { return std::move(x); @@ -190,7 +190,7 @@ Substring FoldOperation(FoldingContext &context, Substring &&substring) { auto lower{Fold(context, substring.lower())}; auto upper{Fold(context, substring.upper())}; - if (const DataRef * dataRef{substring.GetParentIf()}) { + if (const DataRef *dataRef{substring.GetParentIf()}) { return Substring{FoldOperation(context, DataRef{*dataRef}), std::move(lower), std::move(upper)}; } else { diff --git a/flang/lib/Evaluate/shape.cpp b/flang/lib/Evaluate/shape.cpp --- a/flang/lib/Evaluate/shape.cpp +++ b/flang/lib/Evaluate/shape.cpp @@ -347,7 +347,7 @@ } template Result operator()(const Expr &expr) const { - if (const Symbol * whole{UnwrapWholeSymbolOrComponentDataRef(expr)}) { + if (const Symbol *whole{UnwrapWholeSymbolOrComponentDataRef(expr)}) { return (*this)(*whole); } else if constexpr (common::HasMember, decltype(expr.u)>) { if (const auto *con{std::get_if>(&expr.u)}) { @@ -709,7 +709,7 @@ return ScalarShape(); // no dimensions seen }, [&](const semantics::ProcEntityDetails &proc) { - if (const Symbol * interface{proc.procInterface()}) { + if (const Symbol *interface{proc.procInterface()}) { return (*this)(*interface); } else { return ScalarShape(); @@ -789,7 +789,7 @@ ++dimension; } if (shape.empty()) { - if (const Component * component{base.UnwrapComponent()}) { + if (const Component *component{base.UnwrapComponent()}) { return (*this)(component->base()); } } @@ -848,7 +848,7 @@ } } return ScalarShape(); - } else if (const Symbol * symbol{call.proc().GetSymbol()}) { + } else if (const Symbol *symbol{call.proc().GetSymbol()}) { return (*this)(*symbol); } else if (const auto *intrinsic{call.proc().GetSpecificIntrinsic()}) { if (intrinsic->name == "shape" || intrinsic->name == "lbound" || diff --git a/flang/lib/Evaluate/target.cpp b/flang/lib/Evaluate/target.cpp --- a/flang/lib/Evaluate/target.cpp +++ b/flang/lib/Evaluate/target.cpp @@ -148,8 +148,8 @@ public: SelectedRealKindVisitor(const TargetCharacteristics &targetCharacteristics, std::int64_t p, std::int64_t r) - : targetCharacteristics_{targetCharacteristics}, precision_{p}, range_{ - r} {} + : targetCharacteristics_{targetCharacteristics}, precision_{p}, + range_{r} {} using Result = std::optional; using Types = RealTypes; template Result Test() const { diff --git a/flang/lib/Evaluate/tools.cpp b/flang/lib/Evaluate/tools.cpp --- a/flang/lib/Evaluate/tools.cpp +++ b/flang/lib/Evaluate/tools.cpp @@ -96,7 +96,7 @@ } auto IsVariableHelper::operator()(const ProcedureDesignator &x) const -> Result { - if (const Symbol * symbol{x.GetSymbol()}) { + if (const Symbol *symbol{x.GetSymbol()}) { const Symbol *result{FindFunctionResult(*symbol)}; return result && IsPointer(*result) && !IsProcedurePointer(*result); } @@ -788,7 +788,7 @@ return false; } else if (const auto *funcRef{UnwrapProcedureRef(expr)}) { return IsVariable(*funcRef); - } else if (const Symbol * symbol{UnwrapWholeSymbolOrComponentDataRef(expr)}) { + } else if (const Symbol *symbol{UnwrapWholeSymbolOrComponentDataRef(expr)}) { return IsPointer(symbol->GetUltimate()); } else { return false; @@ -1164,8 +1164,8 @@ bool IsAllocatableDesignator(const Expr &expr) { // Allocatable sub-objects are not themselves allocatable (9.5.3.1 NOTE 2). - if (const semantics::Symbol * - sym{UnwrapWholeSymbolOrComponentOrCoarrayRef(expr)}) { + if (const semantics::Symbol *sym{ + UnwrapWholeSymbolOrComponentOrCoarrayRef(expr)}) { return semantics::IsAllocatable(sym->GetUltimate()); } return false; @@ -1208,7 +1208,7 @@ const Symbol &ResolveAssociations(const Symbol &original) { const Symbol &symbol{original.GetUltimate()}; if (const auto *details{symbol.detailsIf()}) { - if (const Symbol * nested{UnwrapWholeSymbolDataRef(details->expr())}) { + if (const Symbol *nested{UnwrapWholeSymbolDataRef(details->expr())}) { return ResolveAssociations(*nested); } } @@ -1219,7 +1219,7 @@ const Symbol &symbol{original.GetUltimate()}; if (const auto *details{symbol.detailsIf()}) { if (!details->rank()) { - if (const Symbol * nested{UnwrapWholeSymbolDataRef(details->expr())}) { + if (const Symbol *nested{UnwrapWholeSymbolDataRef(details->expr())}) { return ResolveAssociations(*nested); } } @@ -1234,7 +1234,7 @@ static const Symbol *GetAssociatedVariable(const AssocEntityDetails &details) { if (const auto &expr{details.expr()}) { if (IsVariable(*expr) && !HasVectorSubscript(*expr)) { - if (const Symbol * varSymbol{GetFirstSymbol(*expr)}) { + if (const Symbol *varSymbol{GetFirstSymbol(*expr)}) { return &GetAssociationRoot(*varSymbol); } } @@ -1245,7 +1245,7 @@ const Symbol &GetAssociationRoot(const Symbol &original) { const Symbol &symbol{ResolveAssociations(original)}; if (const auto *details{symbol.detailsIf()}) { - if (const Symbol * root{GetAssociatedVariable(*details)}) { + if (const Symbol *root{GetAssociatedVariable(*details)}) { return *root; } } @@ -1255,8 +1255,8 @@ const Symbol *GetMainEntry(const Symbol *symbol) { if (symbol) { if (const auto *subpDetails{symbol->detailsIf()}) { - if (const Scope * scope{subpDetails->entryScope()}) { - if (const Symbol * main{scope->symbol()}) { + if (const Scope *scope{subpDetails->entryScope()}) { + if (const Symbol *main{scope->symbol()}) { return main; } } @@ -1327,7 +1327,7 @@ // An ENTRY is elemental if its containing subprogram is const Symbol &symbol{DEREF(GetMainEntry(&original.GetUltimate()))}; if (const auto *procDetails{symbol.detailsIf()}) { - if (const Symbol * procInterface{procDetails->procInterface()}) { + if (const Symbol *procInterface{procDetails->procInterface()}) { // procedure with an elemental interface, ignoring the elemental // aspect of intrinsic functions return !procInterface->attrs().test(Attr::INTRINSIC) && @@ -1404,7 +1404,7 @@ const Symbol &symbol{original.GetUltimate()}; if (const auto *object{symbol.detailsIf()}) { if (!object->isDummy() && !IsAllocatable(symbol) && !IsPointer(symbol)) { - if (const DeclTypeSpec * type{symbol.GetType()}) { + if (const DeclTypeSpec *type{symbol.GetType()}) { // If a type parameter value is not a constant expression, the // object is automatic. if (type->category() == DeclTypeSpec::Character) { @@ -1414,7 +1414,7 @@ return true; } } - } else if (const DerivedTypeSpec * derived{type->AsDerived()}) { + } else if (const DerivedTypeSpec *derived{type->AsDerived()}) { for (const auto &pair : derived->parameters()) { if (const auto &value{pair.second.GetExplicit()}) { if (!evaluate::IsConstantExpr(*value)) { @@ -1494,7 +1494,7 @@ return true; } else if (scope.hasSAVE()) { return true; // bare SAVE statement - } else if (const Symbol * block{FindCommonBlockContaining(symbol)}; + } else if (const Symbol *block{FindCommonBlockContaining(symbol)}; block && block->attrs().test(Attr::SAVE)) { return true; // in COMMON with SAVE } else { @@ -1680,7 +1680,7 @@ common::IgnoreTKRSet result; if (const auto *object{symbol.detailsIf()}) { result = object->ignoreTKR(); - if (const Symbol * ownerSymbol{symbol.owner().symbol()}) { + if (const Symbol *ownerSymbol{symbol.owner().symbol()}) { if (const auto *ownerSubp{ownerSymbol->detailsIf()}) { if (ownerSubp->defaultIgnoreTKR()) { result |= common::ignoreTKRAll; diff --git a/flang/lib/Evaluate/type.cpp b/flang/lib/Evaluate/type.cpp --- a/flang/lib/Evaluate/type.cpp +++ b/flang/lib/Evaluate/type.cpp @@ -256,7 +256,7 @@ // TODO: Combine with semantics::DerivedTypeDetails::GetParentComponent if (auto extends{dtDetails.GetParentComponentName()}) { if (auto iter{scope->find(*extends)}; iter != scope->cend()) { - if (const semantics::Symbol & symbol{*iter->second}; + if (const semantics::Symbol &symbol{*iter->second}; symbol.test(semantics::Symbol::Flag::ParentComp)) { return &symbol; } @@ -268,7 +268,7 @@ const semantics::DerivedTypeSpec *GetParentTypeSpec( const semantics::DerivedTypeSpec &derived) { - if (const semantics::Symbol * parent{FindParentComponent(derived)}) { + if (const semantics::Symbol *parent{FindParentComponent(derived)}) { return &parent->get() .type() ->derivedTypeSpec(); @@ -341,7 +341,7 @@ const semantics::Scope &scope) { if (auto extends{details.GetParentComponentName()}) { if (auto iter{scope.find(*extends)}; iter != scope.cend()) { - if (const Symbol & symbol{*iter->second}; + if (const Symbol &symbol{*iter->second}; symbol.test(semantics::Symbol::Flag::ParentComp)) { return &symbol; } @@ -363,7 +363,7 @@ static const semantics::DerivedTypeSpec *GetParentTypeSpec( const semantics::Symbol *symbol, const semantics::Scope &scope) { - if (const Symbol * parentComponent{GetParentComponent(symbol, scope)}) { + if (const Symbol *parentComponent{GetParentComponent(symbol, scope)}) { return &parentComponent->get() .type() ->derivedTypeSpec(); diff --git a/flang/lib/Evaluate/variable.cpp b/flang/lib/Evaluate/variable.cpp --- a/flang/lib/Evaluate/variable.cpp +++ b/flang/lib/Evaluate/variable.cpp @@ -414,7 +414,7 @@ } if (rank > 0) { return rank; - } else if (const Component * component{base_.UnwrapComponent()}) { + } else if (const Component *component{base_.UnwrapComponent()}) { return component->base().Rank(); } else { return 0; @@ -613,7 +613,7 @@ return DynamicType{TypeCategory::Character, T::kind}; } } - if (const Symbol * symbol{GetLastSymbol()}) { + if (const Symbol *symbol{GetLastSymbol()}) { return DynamicType::From(*symbol); } return std::nullopt; @@ -658,7 +658,7 @@ // for Symbol references. template static bool TestVariableEquality(const A &x, const A &y) { const SymbolRef *xSymbol{std::get_if(&x.u)}; - if (const SymbolRef * ySymbol{std::get_if(&y.u)}) { + if (const SymbolRef *ySymbol{std::get_if(&y.u)}) { return xSymbol && AreSameSymbol(*xSymbol, *ySymbol); } else { return x.u == y.u; diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -950,7 +950,8 @@ res.loweringOpts.setLowerToHighLevelFIR(true); } - if (args.hasArg(clang::driver::options::OPT_flang_experimental_polymorphism)) { + if (args.hasArg( + clang::driver::options::OPT_flang_experimental_polymorphism)) { res.loweringOpts.setPolymorphicTypeImpl(true); } diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp --- a/flang/lib/Frontend/FrontendActions.cpp +++ b/flang/lib/Frontend/FrontendActions.cpp @@ -319,7 +319,7 @@ // FIXME: This should eventually be moved out of the // if, so that it also functions for host, however, // we must fix the filtering to function reasonably - // for host first. + // for host first. pm.addPass(fir::createOMPFunctionFilteringPass()); } } diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp --- a/flang/lib/Lower/ConvertCall.cpp +++ b/flang/lib/Lower/ConvertCall.cpp @@ -1280,8 +1280,9 @@ CallContext &callContext) { auto &builder = callContext.getBuilder(); const auto &loc = callContext.loc; - assert(intrinsic && Fortran::lower::intrinsicRequiresCustomOptionalHandling( - callContext.procRef, *intrinsic, callContext.converter)); + assert(intrinsic && + Fortran::lower::intrinsicRequiresCustomOptionalHandling( + callContext.procRef, *intrinsic, callContext.converter)); // helper to get a particular prepared argument auto getArgument = [&](std::size_t i, bool loadArg) -> fir::ExtendedValue { diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp --- a/flang/lib/Lower/ConvertExpr.cpp +++ b/flang/lib/Lower/ConvertExpr.cpp @@ -7368,7 +7368,7 @@ } bool Fortran::lower::isParentComponent(const Fortran::lower::SomeExpr &expr) { - if (const Fortran::semantics::Symbol * symbol{GetLastSymbol(expr)}) { + if (const Fortran::semantics::Symbol *symbol{GetLastSymbol(expr)}) { if (symbol->test(Fortran::semantics::Symbol::Flag::ParentComp)) return true; } diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -1715,11 +1715,13 @@ std::get_if(&clause.u)) { genWaitClause(converter, waitClause, waitOperands, waitDevnum, addWaitAttr, stmtCtx); - } else if(const auto *defaultClause = - std::get_if(&clause.u)) { + } else if (const auto *defaultClause = + std::get_if( + &clause.u)) { if ((defaultClause->v).v == llvm::acc::DefaultValue::ACC_Default_none) hasDefaultNone = true; - else if ((defaultClause->v).v == llvm::acc::DefaultValue::ACC_Default_present) + else if ((defaultClause->v).v == + llvm::acc::DefaultValue::ACC_Default_present) hasDefaultPresent = true; } } diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -1097,7 +1097,7 @@ for (const Fortran::parser::OmpObject &ompObject : objectList.v) { if (const auto *name{ Fortran::parser::Unwrap(ompObject)}) { - if (const Fortran::semantics::Symbol * symbol{name->symbol}) { + if (const Fortran::semantics::Symbol *symbol{name->symbol}) { mlir::Value symVal = converter.getSymbolAddress(*symbol); mlir::Type redType = symVal.getType().cast().getEleTy(); @@ -1134,7 +1134,7 @@ for (const Fortran::parser::OmpObject &ompObject : objectList.v) { if (const auto *name{ Fortran::parser::Unwrap(ompObject)}) { - if (const Fortran::semantics::Symbol * symbol{name->symbol}) { + if (const Fortran::semantics::Symbol *symbol{name->symbol}) { mlir::Value symVal = converter.getSymbolAddress(*symbol); mlir::Type redType = symVal.getType().cast().getEleTy(); @@ -3362,7 +3362,7 @@ for (const Fortran::parser::OmpObject &ompObject : objectList.v) { if (const auto *name{ Fortran::parser::Unwrap(ompObject)}) { - if (const Fortran::semantics::Symbol * symbol{name->symbol}) { + if (const Fortran::semantics::Symbol *symbol{name->symbol}) { mlir::Value reductionVal = converter.getSymbolAddress(*symbol); mlir::Type reductionType = reductionVal.getType().cast().getEleTy(); @@ -3405,7 +3405,7 @@ for (const Fortran::parser::OmpObject &ompObject : objectList.v) { if (const auto *name{Fortran::parser::Unwrap( ompObject)}) { - if (const Fortran::semantics::Symbol * symbol{name->symbol}) { + if (const Fortran::semantics::Symbol *symbol{name->symbol}) { mlir::Value reductionVal = converter.getSymbolAddress(*symbol); for (const mlir::OpOperand &reductionValUse : reductionVal.getUses()) { diff --git a/flang/lib/Lower/PFTBuilder.cpp b/flang/lib/Lower/PFTBuilder.cpp --- a/flang/lib/Lower/PFTBuilder.cpp +++ b/flang/lib/Lower/PFTBuilder.cpp @@ -1642,9 +1642,8 @@ Fortran::lower::pft::FunctionLikeUnit::FunctionLikeUnit( const parser::MainProgram &func, const lower::pft::PftNode &parent, const semantics::SemanticsContext &semanticsContext) - : ProgramUnit{func, parent}, endStmt{ - getFunctionStmt( - func)} { + : ProgramUnit{func, parent}, + endStmt{getFunctionStmt(func)} { const auto &programStmt = std::get>>(func.t); if (programStmt.has_value()) { @@ -1728,8 +1727,8 @@ Fortran::lower::pft::ModuleLikeUnit::ModuleLikeUnit( const parser::Submodule &m, const lower::pft::PftNode &parent) - : ProgramUnit{m, parent}, beginStmt{getModuleStmt( - m)}, + : ProgramUnit{m, parent}, + beginStmt{getModuleStmt(m)}, endStmt{getModuleStmt(m)} {} parser::CharBlock diff --git a/flang/lib/Parser/basic-parsers.h b/flang/lib/Parser/basic-parsers.h --- a/flang/lib/Parser/basic-parsers.h +++ b/flang/lib/Parser/basic-parsers.h @@ -854,7 +854,7 @@ : parser_{parser}, message_{msg} {} constexpr NonstandardParser(PA parser) : parser_{parser} {} std::optional Parse(ParseState &state) const { - if (UserState * ustate{state.userState()}) { + if (UserState *ustate{state.userState()}) { if (!ustate->features().IsEnabled(LF)) { return std::nullopt; } @@ -892,7 +892,7 @@ constexpr DeprecatedParser(const DeprecatedParser &) = default; constexpr DeprecatedParser(PA parser) : parser_{parser} {} std::optional Parse(ParseState &state) const { - if (UserState * ustate{state.userState()}) { + if (UserState *ustate{state.userState()}) { if (!ustate->features().IsEnabled(LF)) { return std::nullopt; } diff --git a/flang/lib/Parser/message.cpp b/flang/lib/Parser/message.cpp --- a/flang/lib/Parser/message.cpp +++ b/flang/lib/Parser/message.cpp @@ -198,13 +198,13 @@ } void Message::ResolveProvenances(const AllCookedSources &allCooked) { - if (CharBlock * cb{std::get_if(&location_)}) { + if (CharBlock *cb{std::get_if(&location_)}) { if (std::optional resolved{ allCooked.GetProvenanceRange(*cb)}) { location_ = *resolved; } } - if (Message * attachment{attachment_.get()}) { + if (Message *attachment{attachment_.get()}) { attachment->ResolveProvenances(allCooked); } } diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp --- a/flang/lib/Parser/openmp-parsers.cpp +++ b/flang/lib/Parser/openmp-parsers.cpp @@ -213,12 +213,11 @@ // 2.9.5 ORDER ([order-modifier :]concurrent) TYPE_PARSER(construct( - "REPRODUCIBLE" >> pure(OmpOrderModifier::Kind::Reproducible)) || + "REPRODUCIBLE" >> pure(OmpOrderModifier::Kind::Reproducible)) || construct( - "UNCONSTRAINED" >> pure(OmpOrderModifier::Kind::Unconstrained))) + "UNCONSTRAINED" >> pure(OmpOrderModifier::Kind::Unconstrained))) -TYPE_PARSER(construct( - maybe(Parser{} / ":"), +TYPE_PARSER(construct(maybe(Parser{} / ":"), "CONCURRENT" >> pure(OmpOrderClause::Type::Concurrent))) TYPE_PARSER( diff --git a/flang/lib/Parser/preprocessor.cpp b/flang/lib/Parser/preprocessor.cpp --- a/flang/lib/Parser/preprocessor.cpp +++ b/flang/lib/Parser/preprocessor.cpp @@ -31,8 +31,8 @@ Definition::Definition(const std::vector &argNames, const TokenSequence &repl, std::size_t firstToken, std::size_t tokens, bool isVariadic) - : isFunctionLike_{true}, - argumentCount_(argNames.size()), isVariadic_{isVariadic}, + : isFunctionLike_{true}, argumentCount_(argNames.size()), + isVariadic_{isVariadic}, replacement_{Tokenize(argNames, repl, firstToken, tokens)} {} Definition::Definition(const std::string &predefined, AllSources &sources) diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp --- a/flang/lib/Parser/prescan.cpp +++ b/flang/lib/Parser/prescan.cpp @@ -36,8 +36,8 @@ preprocessor_{that.preprocessor_}, allSources_{that.allSources_}, features_{that.features_}, inFixedForm_{that.inFixedForm_}, fixedFormColumnLimit_{that.fixedFormColumnLimit_}, - encoding_{that.encoding_}, prescannerNesting_{that.prescannerNesting_ + - 1}, + encoding_{that.encoding_}, + prescannerNesting_{that.prescannerNesting_ + 1}, skipLeadingAmpersand_{that.skipLeadingAmpersand_}, compilerDirectiveBloomFilter_{that.compilerDirectiveBloomFilter_}, compilerDirectiveSentinels_{that.compilerDirectiveSentinels_} {} @@ -915,7 +915,7 @@ llvm::raw_string_ostream error{buf}; Provenance provenance{GetProvenance(nextLine_)}; std::optional prependPath; - if (const SourceFile * currentFile{allSources_.GetSourceFile(provenance)}) { + if (const SourceFile *currentFile{allSources_.GetSourceFile(provenance)}) { prependPath = DirectoryName(currentFile->path()); } const SourceFile *included{ diff --git a/flang/lib/Parser/provenance.cpp b/flang/lib/Parser/provenance.cpp --- a/flang/lib/Parser/provenance.cpp +++ b/flang/lib/Parser/provenance.cpp @@ -593,7 +593,7 @@ std::optional AllCookedSources::GetProvenanceRange( CharBlock cb) const { - if (const CookedSource * c{Find(cb)}) { + if (const CookedSource *c{Find(cb)}) { return c->GetProvenanceRange(cb); } else { return std::nullopt; @@ -647,10 +647,10 @@ } bool AllCookedSources::Precedes(CharBlock x, CharBlock y) const { - if (const CookedSource * xSource{Find(x)}) { + if (const CookedSource *xSource{Find(x)}) { if (xSource->AsCharBlock().Contains(y)) { return x.begin() < y.begin(); - } else if (const CookedSource * ySource{Find(y)}) { + } else if (const CookedSource *ySource{Find(y)}) { return xSource->number() < ySource->number(); } else { return true; // by fiat, all cooked source < anything outside diff --git a/flang/lib/Parser/token-parsers.h b/flang/lib/Parser/token-parsers.h --- a/flang/lib/Parser/token-parsers.h +++ b/flang/lib/Parser/token-parsers.h @@ -606,8 +606,8 @@ struct SkipStuffBeforeStatement { using resultType = Success; static std::optional Parse(ParseState &state) { - if (UserState * ustate{state.userState()}) { - if (ParsingLog * log{ustate->log()}) { + if (UserState *ustate{state.userState()}) { + if (ParsingLog *log{ustate->log()}) { // Save memory: vacate the parsing log before each statement unless // we're logging the whole parse for debugging. if (!ustate->instrumentedParse()) { diff --git a/flang/lib/Parser/token-sequence.h b/flang/lib/Parser/token-sequence.h --- a/flang/lib/Parser/token-sequence.h +++ b/flang/lib/Parser/token-sequence.h @@ -42,8 +42,8 @@ } TokenSequence(TokenSequence &&that) : start_{std::move(that.start_)}, nextStart_{that.nextStart_}, - char_{std::move(that.char_)}, provenances_{ - std::move(that.provenances_)} {} + char_{std::move(that.char_)}, + provenances_{std::move(that.provenances_)} {} TokenSequence(const std::string &s, Provenance p) { Put(s, p); } TokenSequence &operator=(const TokenSequence &that) { diff --git a/flang/lib/Semantics/assignment.cpp b/flang/lib/Semantics/assignment.cpp --- a/flang/lib/Semantics/assignment.cpp +++ b/flang/lib/Semantics/assignment.cpp @@ -61,7 +61,7 @@ }; 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(stmt.t).GetSource()}; @@ -87,7 +87,7 @@ 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)); @@ -110,7 +110,7 @@ // Checks C1594(5,6); false if check fails bool CheckCopyabilityInPureScope(parser::ContextualMessages &messages, const SomeExpr &expr, const Scope &scope) { - if (const Symbol * base{GetFirstSymbol(expr)}) { + if (const Symbol *base{GetFirstSymbol(expr)}) { if (const char *why{ WhyBaseObjectIsSuspicious(base->GetUltimate(), scope)}) { if (auto pointer{GetPointerComponentDesignatorName(expr)}) { diff --git a/flang/lib/Semantics/check-allocate.cpp b/flang/lib/Semantics/check-allocate.cpp --- a/flang/lib/Semantics/check-allocate.cpp +++ b/flang/lib/Semantics/check-allocate.cpp @@ -39,14 +39,13 @@ public: AllocationCheckerHelper( const parser::Allocation &alloc, AllocateCheckerInfo &info) - : allocateInfo_{info}, allocateObject_{std::get( - alloc.t)}, + : allocateInfo_{info}, + allocateObject_{std::get(alloc.t)}, name_{parser::GetLastName(allocateObject_)}, symbol_{name_.symbol ? &name_.symbol->GetUltimate() : nullptr}, type_{symbol_ ? symbol_->GetType() : nullptr}, - allocateShapeSpecRank_{ShapeSpecRank(alloc)}, rank_{symbol_ - ? symbol_->Rank() - : 0}, + allocateShapeSpecRank_{ShapeSpecRank(alloc)}, + rank_{symbol_ ? symbol_->Rank() : 0}, allocateCoarraySpecRank_{CoarraySpecRank(alloc)}, corank_{symbol_ ? symbol_->Corank() : 0} {} @@ -78,7 +77,7 @@ 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(); } @@ -115,7 +114,7 @@ } 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 @@ -219,8 +218,8 @@ } 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 @@ -271,7 +270,7 @@ // 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 &derivedType1->typeSymbol() == &derivedType2.typeSymbol(); } else if (type1.category() == DeclTypeSpec::Category::ClassDerived) { @@ -293,13 +292,13 @@ // 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; @@ -313,7 +312,7 @@ 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; @@ -338,14 +337,14 @@ } // 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) { if (it->second.isAssumed()) { @@ -368,8 +367,8 @@ static std::optional 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; @@ -393,11 +392,11 @@ 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 { @@ -409,10 +408,10 @@ 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); @@ -614,8 +613,7 @@ if (evaluate::IsCoarray(*symbol_)) { 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(), @@ -674,8 +672,8 @@ 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-call.cpp b/flang/lib/Semantics/check-call.cpp --- a/flang/lib/Semantics/check-call.cpp +++ b/flang/lib/Semantics/check-call.cpp @@ -42,7 +42,7 @@ } else if (type->IsPolymorphic()) { messages.Say( "Polymorphic 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 argument requires an explicit interface"_err_en_US); @@ -381,10 +381,10 @@ "Actual argument associated with TYPE(*) %s may not have a parameterized derived type"_err_en_US, dummyName); } - if (const Symbol * - tbp{FindImmediateComponent(*derived, [](const Symbol &symbol) { - return symbol.has(); - })}) { // 15.5.2.4(2) + if (const Symbol *tbp{ + FindImmediateComponent(*derived, [](const Symbol &symbol) { + return symbol.has(); + })}) { // 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()); @@ -411,8 +411,8 @@ } if (auto coarrayRef{evaluate::ExtractCoarrayRef(actual)}) { // C1537 const Symbol &coarray{coarrayRef->GetLastSymbol()}; - if (const DeclTypeSpec * type{coarray.GetType()}) { - if (const DerivedTypeSpec * derived{type->AsDerived()}) { + if (const DeclTypeSpec *type{coarray.GetType()}) { + 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, @@ -850,7 +850,9 @@ parser::ContextualMessages &messages{foldingContext.messages()}; auto restorer{ messages.SetLocation(arg.sourceLocation().value_or(messages.at()))}; - 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)}; @@ -1048,8 +1050,8 @@ messages.Say( "Actual argument associated with %s is a NULL() pointer without a MOLD= to provide a character length"_err_en_US, dummyName); - } else if (const DerivedTypeSpec * - derived{GetDerivedTypeSpec(object.type.type())}) { + } else if (const DerivedTypeSpec *derived{ + GetDerivedTypeSpec(object.type.type())}) { for (const auto &[pName, pValue] : derived->parameters()) { if (pValue.isAssumed()) { messages.Say( @@ -1405,8 +1407,8 @@ } } if (arguments.size() > 2) { // SIZE= - if (const Symbol * - whole{UnwrapWholeSymbolOrComponentDataRef(arguments[2])}) { + if (const Symbol *whole{ + UnwrapWholeSymbolOrComponentDataRef(arguments[2])}) { if (IsOptional(*whole)) { messages.Say( "SIZE= argument may not be the optional dummy argument '%s'"_err_en_US, diff --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp --- a/flang/lib/Semantics/check-cuda.cpp +++ b/flang/lib/Semantics/check-cuda.cpp @@ -69,7 +69,7 @@ DeviceExprChecker() : Base(*this) {} using Base::operator(); Result operator()(const evaluate::ProcedureDesignator &x) const { - if (const Symbol * sym{x.GetInterfaceSymbol()}) { + if (const Symbol *sym{x.GetInterfaceSymbol()}) { const auto *subp{ sym->GetUltimate().detailsIf()}; if (subp) { diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp --- a/flang/lib/Semantics/check-declarations.cpp +++ b/flang/lib/Semantics/check-declarations.cpp @@ -462,7 +462,7 @@ messages_.Say( "The function result variable '%s' may not have an explicit SAVE attribute"_err_en_US, symbol.name()); - } else if (const Symbol * common{FindCommonBlockContaining(ultimate)}) { + } else if (const Symbol *common{FindCommonBlockContaining(ultimate)}) { messages_.Say( "The entity '%s' in COMMON block /%s/ may not have an explicit SAVE attribute"_err_en_US, symbol.name(), common->name()); @@ -485,7 +485,7 @@ messages_.Say( "BIND(C) function result cannot have ALLOCATABLE or POINTER attribute"_err_en_US); } - if (const DeclTypeSpec * type{symbol.GetType()}; + if (const DeclTypeSpec *type{symbol.GetType()}; type && type->category() == DeclTypeSpec::Character) { bool isConstOne{false}; // 18.3.1(1) if (const auto &len{type->characterTypeSpec().length().GetExplicit()}) { @@ -972,8 +972,8 @@ if (isComponent) { if (attr == common::CUDADataAttr::Device) { const DeclTypeSpec *type{symbol.GetType()}; - if (const DerivedTypeSpec * - derived{type ? type->AsDerived() : nullptr}) { + if (const DerivedTypeSpec *derived{ + type ? type->AsDerived() : nullptr}) { DirectComponentIterator directs{*derived}; if (auto iter{std::find_if(directs.begin(), directs.end(), [](const Symbol &) { return false; })}) { @@ -1194,7 +1194,7 @@ } if (IsPointer(symbol)) { CheckPointerInitialization(symbol); - if (const Symbol * interface{details.procInterface()}) { + if (const Symbol *interface{details.procInterface()}) { const Symbol &ultimate{interface->GetUltimate()}; if (ultimate.attrs().test(Attr::INTRINSIC)) { if (const auto intrinsic{ @@ -1314,14 +1314,14 @@ } } } - if (const MaybeExpr & stmtFunction{details.stmtFunction()}) { + if (const MaybeExpr &stmtFunction{details.stmtFunction()}) { if (auto msg{evaluate::CheckStatementFunction( symbol, *stmtFunction, context_.foldingContext())}) { SayWithDeclaration(symbol, std::move(*msg)); } else if (details.result().flags().test(Symbol::Flag::Implicit)) { // 15.6.4 p2 weird requirement - if (const Symbol * - host{symbol.owner().parent().FindSymbol(symbol.name())}) { + if (const Symbol *host{ + symbol.owner().parent().FindSymbol(symbol.name())}) { evaluate::AttachDeclaration( messages_.Say(symbol.name(), "An implicitly typed statement function should not appear when the same symbol is available in its host scope"_port_en_US), @@ -1390,7 +1390,7 @@ "A subroutine may not have LAUNCH_BOUNDS() or CLUSTER_DIMS() unless it has ATTRIBUTES(GLOBAL) or ATTRIBUTES(GRID_GLOBAL)"_err_en_US); } if (!IsStmtFunction(symbol)) { - if (const Scope * outerDevice{FindCUDADeviceContext(&symbol.owner())}; + if (const Scope *outerDevice{FindCUDADeviceContext(&symbol.owner())}; outerDevice && outerDevice->symbol()) { if (auto *msg{messages_.Say(symbol.name(), "'%s' may not be an internal procedure of CUDA device subprogram '%s'"_err_en_US, @@ -1408,8 +1408,7 @@ if (const auto *bind{symbol.GetBindName()}) { interfaceName = *bind; } - if (const Symbol * global{FindGlobal(symbol)}; - global && global != &symbol) { + if (const Symbol *global{FindGlobal(symbol)}; global && global != &symbol) { std::string definitionName{global->name().ToString()}; if (const auto *bind{global->GetBindName()}) { definitionName = *bind; @@ -2603,7 +2602,7 @@ // symbol must be interoperable (e.g., dummy argument of interoperable // procedure interface) but is not itself BIND(C). } - if (const std::string * bindName{symbol.GetBindName()}; + if (const std::string *bindName{symbol.GetBindName()}; bindName) { // has a binding name if (!bindName->empty()) { bool ok{bindName->front() == '_' || parser::IsLetter(bindName->front())}; @@ -2828,7 +2827,7 @@ if (generic.owner().IsDerivedType()) { return; } - if (const Scope * dtScope{derivedType.scope()}) { + if (const Scope *dtScope{derivedType.scope()}) { if (auto iter{dtScope->find(generic.name())}; iter != dtScope->end()) { for (auto specRef : iter->second->get().specificProcs()) { const Symbol &specific{specRef->get().symbol()}; @@ -3116,7 +3115,7 @@ symbol.attrs().test(Attr::MODULE)) && !subprogram->bindName() && !subprogram->isInterface()) { const Symbol *module{nullptr}; - if (const Scope * moduleScope{FindModuleContaining(symbol.owner())}; + if (const Scope *moduleScope{FindModuleContaining(symbol.owner())}; moduleScope && moduleScope->symbol()) { if (const auto *details{ moduleScope->symbol()->detailsIf()}) { diff --git a/flang/lib/Semantics/check-do-forall.cpp b/flang/lib/Semantics/check-do-forall.cpp --- a/flang/lib/Semantics/check-do-forall.cpp +++ b/flang/lib/Semantics/check-do-forall.cpp @@ -88,8 +88,8 @@ public: DoConcurrentBodyEnforce( SemanticsContext &context, parser::CharBlock doConcurrentSourcePosition) - : context_{context}, doConcurrentSourcePosition_{ - doConcurrentSourcePosition} {} + : context_{context}, + doConcurrentSourcePosition_{doConcurrentSourcePosition} {} std::set labels() { return labels_; } template bool Pre(const T &x) { if (const auto *expr{GetExpr(context_, x)}) { @@ -157,8 +157,8 @@ } // Check the components if (const auto *details{symbol.detailsIf()}) { - if (const DeclTypeSpec * entityType{details->type()}) { - if (const DerivedTypeSpec * derivedType{entityType->AsDerived()}) { + if (const DeclTypeSpec *entityType{details->type()}) { + if (const DerivedTypeSpec *derivedType{entityType->AsDerived()}) { UltimateComponentIterator ultimates{*derivedType}; for (const auto &ultimate : ultimates) { if (WillDeallocatePolymorphic(ultimate, WillDeallocate)) { @@ -204,7 +204,7 @@ MightDeallocatePolymorphic(entity, DeallocateAll)) { SayDeallocateOfPolymorph(endBlockStmt.source, entity, reason); } - if (const Symbol * impure{HasImpureFinal(entity)}) { + if (const Symbol *impure{HasImpureFinal(entity)}) { SayDeallocateWithImpureFinal(entity, reason, *impure); } } @@ -215,12 +215,12 @@ // Note that this case does not cause deallocation of coarray components void Post(const parser::AssignmentStmt &stmt) { const auto &variable{std::get(stmt.t)}; - if (const Symbol * entity{GetLastName(variable).symbol}) { + if (const Symbol *entity{GetLastName(variable).symbol}) { const char *reason{"assignment"}; if (MightDeallocatePolymorphic(*entity, DeallocateNonCoarray)) { SayDeallocateOfPolymorph(variable.GetSource(), *entity, reason); } - if (const Symbol * impure{HasImpureFinal(*entity)}) { + if (const Symbol *impure{HasImpureFinal(*entity)}) { SayDeallocateWithImpureFinal(*entity, reason, *impure); } } @@ -253,7 +253,7 @@ SayDeallocateOfPolymorph( currentStatementSourcePosition_, entity, reason); } - if (const Symbol * impure{HasImpureFinal(entity)}) { + if (const Symbol *impure{HasImpureFinal(entity)}) { SayDeallocateWithImpureFinal(entity, reason, *impure); } } @@ -346,7 +346,7 @@ // Check to see if the name is a variable from an enclosing scope void Post(const parser::Name &name) { - if (const Symbol * symbol{name.symbol}) { + if (const Symbol *symbol{name.symbol}) { if (IsVariableName(*symbol)) { const Scope &variableScope{symbol->owner()}; if (DoesScopeContain(&variableScope, blockScope_)) { @@ -428,8 +428,7 @@ } void Check(const parser::ForallAssignmentStmt &stmt) { - if (const evaluate::Assignment * - assignment{common::visit( + if (const evaluate::Assignment *assignment{common::visit( common::visitors{[&](const auto &x) { return GetAssignment(x); }}, stmt.u)}) { CheckForallIndexesUsed(*assignment); @@ -479,7 +478,7 @@ void CheckDoVariable(const parser::ScalarName &scalarName) { const parser::CharBlock &sourceLocation{scalarName.thing.source}; - if (const Symbol * symbol{scalarName.thing.symbol}) { + if (const Symbol *symbol{scalarName.thing.symbol}) { if (!IsVariableName(*symbol)) { context_.Say( sourceLocation, "DO control must be an INTEGER variable"_err_en_US); @@ -507,7 +506,7 @@ // Semantic checks for the limit and step expressions void CheckDoExpression(const parser::ScalarExpr &scalarExpression) { - if (const SomeExpr * expr{GetExpr(context_, scalarExpression)}) { + if (const SomeExpr *expr{GetExpr(context_, scalarExpression)}) { if (!ExprHasTypeCategory(*expr, TypeCategory::Integer)) { // No warnings or errors for type INTEGER const parser::CharBlock &loc{scalarExpression.thing.value().source}; @@ -566,7 +565,7 @@ // Loop through the names in the Local locality-spec getting their // symbols for (const parser::Name &name : names->v) { - if (const Symbol * symbol{parentScope.FindSymbol(name.source)}) { + if (const Symbol *symbol{parentScope.FindSymbol(name.source)}) { symbols.insert(ResolveAssociations(*symbol)); } } @@ -952,8 +951,8 @@ const parser::CharBlock location, SemanticsContext &context) { common::Intent intent{arg.dummyIntent()}; if (intent == common::Intent::Out || intent == common::Intent::InOut) { - if (const SomeExpr * argExpr{arg.UnwrapExpr()}) { - if (const Symbol * var{evaluate::UnwrapWholeSymbolDataRef(*argExpr)}) { + if (const SomeExpr *argExpr{arg.UnwrapExpr()}) { + if (const Symbol *var{evaluate::UnwrapWholeSymbolDataRef(*argExpr)}) { if (intent == common::Intent::Out) { context.CheckIndexVarRedefine(location, *var); } else { @@ -1028,7 +1027,7 @@ void DoForallChecker::Leave(const parser::Expr &parsedExpr) { CHECK(exprDepth_ > 0); if (--exprDepth_ == 0) { // Only check top level expressions - if (const SomeExpr * expr{GetExpr(context_, parsedExpr)}) { + if (const SomeExpr *expr{GetExpr(context_, parsedExpr)}) { ActualArgumentSet argSet{CollectActualArguments(*expr)}; for (const evaluate::ActualArgumentRef &argRef : argSet) { CheckIfArgIsDoVar(*argRef, parsedExpr.source, context_); diff --git a/flang/lib/Semantics/check-io.h b/flang/lib/Semantics/check-io.h --- a/flang/lib/Semantics/check-io.h +++ b/flang/lib/Semantics/check-io.h @@ -87,7 +87,7 @@ template std::optional GetConstExpr(const T &x) { using DefaultCharConstantType = evaluate::Ascii; - if (const SomeExpr * expr{GetExpr(context_, x)}) { + if (const SomeExpr *expr{GetExpr(context_, x)}) { const auto foldExpr{ evaluate::Fold(context_.foldingContext(), common::Clone(*expr))}; if constexpr (std::is_same_v) { diff --git a/flang/lib/Semantics/check-io.cpp b/flang/lib/Semantics/check-io.cpp --- a/flang/lib/Semantics/check-io.cpp +++ b/flang/lib/Semantics/check-io.cpp @@ -550,7 +550,7 @@ } void IoChecker::Enter(const parser::IoUnit &spec) { - if (const parser::Variable * var{std::get_if(&spec.u)}) { + if (const parser::Variable *var{std::get_if(&spec.u)}) { // Only now after generic resolution can it be known whether a function // call appearing as UNIT=f() is an integer scalar external unit number // or a character pointer for internal I/O. @@ -753,7 +753,7 @@ static const parser::Name *FindNamelist( const std::list &controls) { for (const auto &control : controls) { - if (const parser::Name * namelist{std::get_if(&control.u)}) { + if (const parser::Name *namelist{std::get_if(&control.u)}) { if (namelist->symbol && namelist->symbol->GetUltimate().has()) { return namelist; @@ -767,8 +767,8 @@ const parser::ReadStmt &readStmt, SemanticsContext &context) { const std::list &items{readStmt.items}; for (const auto &item : items) { - if (const parser::Variable * - variable{std::get_if(&item.u)}) { + if (const parser::Variable *variable{ + std::get_if(&item.u)}) { context.CheckIndexVarRedefine(*variable); } } @@ -778,7 +778,7 @@ if (!flags_.test(Flag::InternalUnit)) { CheckForPureSubprogram(); } - if (const parser::Name * namelist{FindNamelist(readStmt.controls)}) { + if (const parser::Name *namelist{FindNamelist(readStmt.controls)}) { if (namelist->symbol) { CheckNamelist(*namelist->symbol, common::DefinedIo::ReadFormatted, namelist->source); @@ -821,7 +821,7 @@ if (!flags_.test(Flag::InternalUnit)) { CheckForPureSubprogram(); } - if (const parser::Name * namelist{FindNamelist(writeStmt.controls)}) { + if (const parser::Name *namelist{FindNamelist(writeStmt.controls)}) { if (namelist->symbol) { CheckNamelist(*namelist->symbol, common::DefinedIo::WriteFormatted, namelist->source); @@ -1036,8 +1036,8 @@ void IoChecker::CheckForPureSubprogram() const { // C1597 CHECK(context_.location()); - if (const Scope * - scope{context_.globalScope().FindScope(*context_.location())}) { + if (const Scope *scope{ + context_.globalScope().FindScope(*context_.location())}) { if (FindPureProcedureContaining(*scope)) { context_.Say( "External I/O is not allowed in a pure subprogram"_err_en_US); @@ -1053,18 +1053,17 @@ if (HasDefinedIo(which, derived, &scope)) { return nullptr; } - if (const Scope * dtScope{derived.scope()}) { + if (const Scope *dtScope{derived.scope()}) { for (const auto &pair : *dtScope) { const Symbol &symbol{*pair.second}; if (IsAllocatableOrPointer(symbol)) { return &symbol; } if (const auto *details{symbol.detailsIf()}) { - if (const DeclTypeSpec * type{details->type()}) { + if (const DeclTypeSpec *type{details->type()}) { if (type->category() == DeclTypeSpec::Category::TypeDerived) { const DerivedTypeSpec &componentDerived{type->derivedTypeSpec()}; - if (const Symbol * - bad{FindUnsafeIoDirectComponent( + if (const Symbol *bad{FindUnsafeIoDirectComponent( which, componentDerived, scope)}) { return bad; } @@ -1081,8 +1080,8 @@ // in which the type was defined. static const Symbol *FindInaccessibleComponent(common::DefinedIo which, const DerivedTypeSpec &derived, const Scope &scope) { - if (const Scope * dtScope{derived.scope()}) { - if (const Scope * module{FindModuleContaining(*dtScope)}) { + if (const Scope *dtScope{derived.scope()}) { + if (const Scope *module{FindModuleContaining(*dtScope)}) { for (const auto &pair : *dtScope) { const Symbol &symbol{*pair.second}; if (IsAllocatableOrPointer(symbol)) { @@ -1090,7 +1089,7 @@ } if (const auto *details{symbol.detailsIf()}) { const DerivedTypeSpec *componentDerived{nullptr}; - if (const DeclTypeSpec * type{details->type()}) { + if (const DeclTypeSpec *type{details->type()}) { if (type->category() == DeclTypeSpec::Category::TypeDerived) { componentDerived = &type->derivedTypeSpec(); } @@ -1106,8 +1105,7 @@ } } if (componentDerived) { - if (const Symbol * - bad{FindInaccessibleComponent( + if (const Symbol *bad{FindInaccessibleComponent( which, *componentDerived, scope)}) { return bad; } @@ -1128,8 +1126,7 @@ } else if (type.category() == TypeCategory::Derived) { const auto &derived{type.GetDerivedTypeSpec()}; const Scope &scope{context_.FindScope(where)}; - if (const Symbol * - bad{FindUnsafeIoDirectComponent(which, derived, scope)}) { + if (const Symbol *bad{FindUnsafeIoDirectComponent(which, derived, scope)}) { return &context_.SayWithDecl(*bad, where, "Derived type '%s' in I/O cannot have an allocatable or pointer direct component '%s' unless using defined I/O"_err_en_US, derived.name(), bad->name()); @@ -1140,8 +1137,7 @@ "Derived type '%s' in I/O may not be polymorphic unless using defined I/O"_err_en_US, derived.name()); } - if (const Symbol * - bad{FindInaccessibleComponent(which, derived, scope)}) { + if (const Symbol *bad{FindInaccessibleComponent(which, derived, scope)}) { return &context_.Say(where, "I/O of the derived type '%s' may not be performed without defined I/O in a scope in which a direct component like '%s' is inaccessible"_err_en_US, derived.name(), bad->name()); diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -358,8 +358,7 @@ const Fortran::parser::OmpClauseList>) { ompClause = &clause; } - if (const Fortran::parser::OmpClause::Hint * - hintClause{ + if (const Fortran::parser::OmpClause::Hint *hintClause{ std::get_if(&ompClause->u)}) { std::optional hintValue = GetIntValue(hintClause->v); if (hintValue && *hintValue >= 0) { @@ -2329,7 +2328,7 @@ void OmpStructureChecker::CheckIsLoopIvPartOfClause( llvmOmpClause clause, const parser::OmpObjectList &ompObjectList) { for (const auto &ompObject : ompObjectList.v) { - if (const parser::Name * name{parser::Unwrap(ompObject)}) { + if (const parser::Name *name{parser::Unwrap(ompObject)}) { if (name->symbol == GetContext().loopIV) { context_.Say(name->source, "DO iteration variable %s is not allowed in %s clause."_err_en_US, diff --git a/flang/lib/Semantics/check-select-rank.cpp b/flang/lib/Semantics/check-select-rank.cpp --- a/flang/lib/Semantics/check-select-rank.cpp +++ b/flang/lib/Semantics/check-select-rank.cpp @@ -31,7 +31,7 @@ // R1149 select-rank-stmt checks const Symbol *saveSelSymbol{nullptr}; if (const auto selExpr{GetExprFromSelector(selectRankStmtSel)}) { - if (const Symbol * sel{evaluate::UnwrapWholeSymbolDataRef(*selExpr)}) { + if (const Symbol *sel{evaluate::UnwrapWholeSymbolDataRef(*selExpr)}) { if (!evaluate::IsAssumedRank(*sel)) { // C1150 context_.Say(parser::FindSourceLocation(selectRankStmtSel), "Selector '%s' is not an assumed-rank array variable"_err_en_US, diff --git a/flang/lib/Semantics/check-select-type.cpp b/flang/lib/Semantics/check-select-type.cpp --- a/flang/lib/Semantics/check-select-type.cpp +++ b/flang/lib/Semantics/check-select-type.cpp @@ -134,7 +134,7 @@ return false; } if (!selectorType_.IsUnlimitedPolymorphic()) { // C1162 - if (const semantics::Scope * guardScope{derived.typeSymbol().scope()}) { + if (const semantics::Scope *guardScope{derived.typeSymbol().scope()}) { if (const auto *selDerivedTypeSpec{ evaluate::GetDerivedTypeSpec(selectorType_)}) { if (!derived.Match(*selDerivedTypeSpec) && diff --git a/flang/lib/Semantics/compute-offsets.cpp b/flang/lib/Semantics/compute-offsets.cpp --- a/flang/lib/Semantics/compute-offsets.cpp +++ b/flang/lib/Semantics/compute-offsets.cpp @@ -289,8 +289,8 @@ auto result{offset * GetSizeAndAlignment(object.symbol, false).size}; if (object.substringStart) { int kind{context_.defaultKinds().GetDefaultKind(TypeCategory::Character)}; - if (const DeclTypeSpec * type{object.symbol.GetType()}) { - if (const IntrinsicTypeSpec * intrinsic{type->AsIntrinsic()}) { + if (const DeclTypeSpec *type{object.symbol.GetType()}) { + if (const IntrinsicTypeSpec *intrinsic{type->AsIntrinsic()}) { kind = ToInt64(intrinsic->kind()).value_or(kind); } } diff --git a/flang/lib/Semantics/data-to-inits.cpp b/flang/lib/Semantics/data-to-inits.cpp --- a/flang/lib/Semantics/data-to-inits.cpp +++ b/flang/lib/Semantics/data-to-inits.cpp @@ -504,7 +504,7 @@ if (object->init().has_value()) { return nullptr; // init is explicit, not default } else if (!object->isDummy() && object->type()) { - if (const DerivedTypeSpec * derived{object->type()->AsDerived()}) { + if (const DerivedTypeSpec *derived{object->type()->AsDerived()}) { DirectComponentIterator directs{*derived}; if (std::find_if( directs.begin(), directs.end(), [](const Symbol &component) { @@ -582,8 +582,8 @@ foldingContext); } } - } else if (const DeclTypeSpec * type{component.GetType()}) { - if (const DerivedTypeSpec * componentDerived{type->AsDerived()}) { + } else if (const DeclTypeSpec *type{component.GetType()}) { + if (const DerivedTypeSpec *componentDerived{type->AsDerived()}) { PopulateWithComponentDefaults(init, componentOffset, *componentDerived, foldingContext, component); } @@ -826,7 +826,7 @@ !HasDeclarationInitializer(symbol) && IsSaved(symbol) && equivalenced.find(symbol) == equivalenced.end()) { // Static object, no local storage association, no explicit initialization - if (const DerivedTypeSpec * derived{HasDefaultInitialization(symbol)}) { + if (const DerivedTypeSpec *derived{HasDefaultInitialization(symbol)}) { auto newInitIter{inits.emplace(&symbol, symbol.size())}; CHECK(newInitIter.second); auto &newInit{newInitIter.first->second}; diff --git a/flang/lib/Semantics/definable.cpp b/flang/lib/Semantics/definable.cpp --- a/flang/lib/Semantics/definable.cpp +++ b/flang/lib/Semantics/definable.cpp @@ -80,7 +80,7 @@ } } } - if (const Symbol * lastPointer{GetLastPointerSymbol(dataRef)}) { + if (const Symbol *lastPointer{GetLastPointerSymbol(dataRef)}) { return *lastPointer; } else { return dataRef.GetFirstSymbol(); @@ -118,7 +118,7 @@ return BlameSymbol( at, "'%s' is an INTENT(IN) dummy argument"_en_US, original); } - if (const Scope * pure{FindPureProcedureContaining(scope)}) { + if (const Scope *pure{FindPureProcedureContaining(scope)}) { // Additional checking for pure subprograms. if (!isTargetDefinition) { if (auto msg{CheckDefinabilityInPureScope( @@ -126,15 +126,14 @@ return msg; } } - if (const Symbol * - visible{FindExternallyVisibleObject( + if (const Symbol *visible{FindExternallyVisibleObject( ultimate, *pure, isPointerDefinition)}) { return BlameSymbol(at, "'%s' is externally visible via '%s' and not definable in a pure subprogram"_en_US, original, visible->name()); } } - if (const Scope * deviceContext{FindCUDADeviceContext(&scope)}) { + if (const Scope *deviceContext{FindCUDADeviceContext(&scope)}) { bool isOwnedByDeviceCode{deviceContext->Contains(ultimate.owner())}; if (isPointerDefinition && !acceptAllocatable) { return BlameSymbol(at, @@ -192,12 +191,12 @@ original); } } - if (const Symbol * impure{HasImpureFinal(ultimate)}) { + if (const Symbol *impure{HasImpureFinal(ultimate)}) { return BlameSymbol(at, "'%s' has an impure FINAL procedure '%s'"_because_en_US, original, impure->name()); } - if (const DerivedTypeSpec * derived{GetDerivedTypeSpec(dyType)}) { + if (const DerivedTypeSpec *derived{GetDerivedTypeSpec(dyType)}) { if (!flags.test(DefinabilityFlag::PolymorphicOkInPure)) { if (auto bad{FindPolymorphicAllocatableUltimateComponent(*derived)}) { return BlameSymbol(at, @@ -309,7 +308,7 @@ anyElemental |= ultimate.attrs().test(Attr::ELEMENTAL); if (const auto *subp{ultimate.detailsIf()}) { if (!subp->dummyArgs().empty()) { - if (const Symbol * arg{subp->dummyArgs()[0]}) { + if (const Symbol *arg{subp->dummyArgs()[0]}) { const auto *object{arg->detailsIf()}; if (arg->Rank() == rank || (object && object->IsAssumedRank())) { @@ -354,7 +353,7 @@ if (const auto *procDesignator{ std::get_if(&expr.u)}) { // Defining a procedure pointer - if (const Symbol * procSym{procDesignator->GetSymbol()}) { + if (const Symbol *procSym{procDesignator->GetSymbol()}) { if (evaluate::ExtractCoarrayRef(expr)) { // C1027 return BlameSymbol(at, "Procedure pointer '%s' may not be a coindexed object"_because_en_US, diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp --- a/flang/lib/Semantics/expression.cpp +++ b/flang/lib/Semantics/expression.cpp @@ -319,7 +319,7 @@ bool anyPossiblyEmptyDim{false}; int dim{0}; for (Subscript &ss : ref.subscript()) { - if (Triplet * triplet{std::get_if(&ss.u)}) { + if (Triplet *triplet{std::get_if(&ss.u)}) { auto expr{Fold(triplet->stride())}; auto stride{ToInt64(expr)}; triplet->set_stride(std::move(expr)); @@ -2031,10 +2031,9 @@ *symbol); continue; } - } else if (const Symbol * pointer{FindPointerComponent(*symbol)}; + } else if (const Symbol *pointer{FindPointerComponent(*symbol)}; pointer && pureContext) { // C1594(4) - if (const Symbol * - visible{semantics::FindExternallyVisibleObject( + if (const Symbol *visible{semantics::FindExternallyVisibleObject( *value, *pureContext)}) { Say(expr.source, "The externally visible object '%s' may not be used in a pure procedure as the value for component '%s' which has the pointer component '%s'"_err_en_US, @@ -2256,9 +2255,9 @@ // binding to be overridden by a PRIVATE one. CHECK(dyType && dyType->category() == TypeCategory::Derived && !dyType->IsUnlimitedPolymorphic()); - if (const Symbol * - latest{DEREF(dyType->GetDerivedTypeSpec().typeSymbol().scope()) - .FindComponent(sym->name())}) { + if (const Symbol *latest{ + DEREF(dyType->GetDerivedTypeSpec().typeSymbol().scope()) + .FindComponent(sym->name())}) { if (sym->attrs().test(semantics::Attr::PRIVATE)) { const auto *bindingModule{FindModuleContaining(generic.owner())}; const Symbol *s{latest}; @@ -2879,7 +2878,7 @@ ProcedureDesignator *proc{std::get_if(&callee->u)}; CHECK(proc); bool isKernel{false}; - if (const Symbol * procSym{proc->GetSymbol()}) { + if (const Symbol *procSym{proc->GetSymbol()}) { const Symbol &ultimate{procSym->GetUltimate()}; if (const auto *subpDetails{ ultimate.detailsIf()}) { @@ -3071,8 +3070,7 @@ specificIntrinsic); } if (procSymbol && !IsPureProcedure(*procSymbol)) { - if (const semantics::Scope * - pure{semantics::FindPureProcedureContaining( + if (const semantics::Scope *pure{semantics::FindPureProcedureContaining( context_.FindScope(callSite))}) { Say(callSite, "Procedure '%s' referenced in pure subprogram '%s' must be pure too"_err_en_US, @@ -4230,8 +4228,8 @@ if (const Symbol *binding{FindBoundOp(oprName, i, generic, true)}) { if (CheckAccessibleSymbol(scope, DEREF(generic))) { // ignore inaccessible type-bound ASSIGNMENT(=) generic - } else if (const Symbol * - resolution{GetBindingResolution(GetType(i), *binding)}) { + } else if (const Symbol *resolution{ + GetBindingResolution(GetType(i), *binding)}) { proc = resolution; } else { proc = binding; diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp --- a/flang/lib/Semantics/mod-file.cpp +++ b/flang/lib/Semantics/mod-file.cpp @@ -346,7 +346,7 @@ return; } PutAttrs(decls_ << "type", typeSymbol.attrs()); - if (const DerivedTypeSpec * extends{typeSymbol.GetParentTypeSpec()}) { + if (const DerivedTypeSpec *extends{typeSymbol.GetParentTypeSpec()}) { decls_ << ",extends(" << extends->name() << ')'; } decls_ << "::" << typeSymbol.name(); @@ -423,7 +423,7 @@ void ModFileWriter::PutSubprogram(const Symbol &symbol) { auto &details{symbol.get()}; - if (const Symbol * interface{details.moduleInterface()}) { + if (const Symbol *interface{details.moduleInterface()}) { const Scope *module{FindModuleContaining(interface->owner())}; if (module && module != &symbol.owner()) { // Interface is in ancestor module @@ -1185,7 +1185,9 @@ needed = needed || (spec && useSet_.count(*spec) > 0) || (dt && useSet_.count(*dt) > 0); } else if (const auto *subp{ultimate.detailsIf()}) { - const Symbol *interface { subp->moduleInterface() }; + const Symbol *interface { + subp->moduleInterface() + }; needed = needed || (interface && useSet_.count(*interface) > 0); } if (needed) { @@ -1248,7 +1250,7 @@ DoBound(spec.lbound()); DoBound(spec.ubound()); } - if (const Symbol * commonBlock{details.commonBlock()}) { + if (const Symbol *commonBlock{details.commonBlock()}) { DoSymbol(*commonBlock); } }, @@ -1287,9 +1289,9 @@ DoParamValue(type->characterTypeSpec().length()); break; default: - if (const DerivedTypeSpec * derived{type->AsDerived()}) { + if (const DerivedTypeSpec *derived{type->AsDerived()}) { const auto &typeSymbol{derived->typeSymbol()}; - if (const DerivedTypeSpec * extends{typeSymbol.GetParentTypeSpec()}) { + if (const DerivedTypeSpec *extends{typeSymbol.GetParentTypeSpec()}) { DoSymbol(extends->name(), extends->typeSymbol()); } for (const auto &pair : derived->parameters()) { @@ -1305,7 +1307,7 @@ } void SubprogramSymbolCollector::DoBound(const Bound &bound) { - if (const MaybeSubscriptIntExpr & expr{bound.GetExplicit()}) { + if (const MaybeSubscriptIntExpr &expr{bound.GetExplicit()}) { DoExpr(*expr); } } diff --git a/flang/lib/Semantics/pointer-assignment.cpp b/flang/lib/Semantics/pointer-assignment.cpp --- a/flang/lib/Semantics/pointer-assignment.cpp +++ b/flang/lib/Semantics/pointer-assignment.cpp @@ -42,8 +42,8 @@ public: PointerAssignmentChecker(SemanticsContext &context, const Scope &scope, parser::CharBlock source, const std::string &description) - : context_{context}, scope_{scope}, source_{source}, description_{ - description} {} + : context_{context}, scope_{scope}, source_{source}, + description_{description} {} PointerAssignmentChecker( SemanticsContext &context, const Scope &scope, const Symbol &lhs) : context_{context}, scope_{scope}, source_{lhs.name()}, @@ -177,7 +177,7 @@ } if (const auto *pureProc{FindPureProcedureContaining(scope_)}) { if (pointerComponentLHS_) { // C1594(4) is a hard error - if (const Symbol * object{FindExternallyVisibleObject(rhs, *pureProc)}) { + if (const Symbol *object{FindExternallyVisibleObject(rhs, *pureProc)}) { if (auto *msg{Say( "Externally visible object '%s' may not be associated with pointer component '%s' in a pure procedure"_err_en_US, object->name(), pointerComponentLHS_->name())}) { @@ -187,7 +187,7 @@ } return false; } - } else if (const Symbol * base{GetFirstSymbol(rhs)}) { + } else if (const Symbol *base{GetFirstSymbol(rhs)}) { if (const char *why{WhyBaseObjectIsSuspicious( base->GetUltimate(), scope_)}) { // C1594(3) evaluate::SayWithDeclaration(foldingContext_.messages(), *base, @@ -360,7 +360,7 @@ } bool PointerAssignmentChecker::Check(const evaluate::ProcedureDesignator &d) { - if (const Symbol * symbol{d.GetSymbol()}) { + if (const Symbol *symbol{d.GetSymbol()}) { if (const auto *subp{ symbol->GetUltimate().detailsIf()}) { if (subp->stmtFunction()) { diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp --- a/flang/lib/Semantics/resolve-directives.cpp +++ b/flang/lib/Semantics/resolve-directives.cpp @@ -631,7 +631,7 @@ const parser::DoConstruct &x) { using Bounds = parser::LoopControl::Bounds; if (x.GetLoopControl()) { - if (const Bounds * b{std::get_if(&x.GetLoopControl()->u)}) { + if (const Bounds *b{std::get_if(&x.GetLoopControl()->u)}) { return &b->name.thing; } else { return nullptr; @@ -1055,7 +1055,7 @@ if (symbol && !dirContext_.empty() && GetContext().withinConstruct) { if (!symbol->owner().IsDerivedType() && !symbol->has() && !IsObjectWithDSA(*symbol)) { - if (Symbol * found{currScope().FindSymbol(name.source)}) { + if (Symbol *found{currScope().FindSymbol(name.source)}) { if (symbol != found) { name.symbol = found; // adjust the symbol within region } else if (GetContext().defaultDSA == Symbol::Flag::AccNone) { @@ -1661,7 +1661,7 @@ // TODO: create a separate function to go through the rules for // predetermined, explicitly determined, and implicitly // determined data-sharing attributes (2.15.1.1). - if (Symbol * found{currScope().FindSymbol(name.source)}) { + if (Symbol *found{currScope().FindSymbol(name.source)}) { if (symbol != found) { name.symbol = found; // adjust the symbol within region } else if (GetContext().defaultDSA == Symbol::Flag::OmpNone) { diff --git a/flang/lib/Semantics/resolve-labels.cpp b/flang/lib/Semantics/resolve-labels.cpp --- a/flang/lib/Semantics/resolve-labels.cpp +++ b/flang/lib/Semantics/resolve-labels.cpp @@ -353,9 +353,9 @@ template void CheckOptionalName(const char *constructTag, const CONSTRUCT &a, const parser::Statement &stmt) { - if (const parser::CharBlock * name{GetStmtName(stmt)}) { + if (const parser::CharBlock *name{GetStmtName(stmt)}) { const auto &firstStmt{std::get>(a.t)}; - if (const parser::CharBlock * firstName{GetStmtName(firstStmt)}) { + if (const parser::CharBlock *firstName{GetStmtName(firstStmt)}) { if (*firstName != *name) { context_.Say(*name, "%s name mismatch"_err_en_US, constructTag) .Attach(*firstName, "should be"_en_US); @@ -459,9 +459,9 @@ // C1401 void Post(const parser::MainProgram &mainProgram) { - if (const parser::CharBlock * - endName{GetStmtName(std::get>( - mainProgram.t))}) { + if (const parser::CharBlock *endName{ + GetStmtName(std::get>( + mainProgram.t))}) { if (const auto &program{ std::get>>( mainProgram.t)}) { @@ -674,7 +674,7 @@ const auto &constructStmt{std::get>(a.t)}; const auto &endStmt{std::get>(a.t)}; const parser::CharBlock *endName{GetStmtName(endStmt)}; - if (const parser::CharBlock * constructName{GetStmtName(constructStmt)}) { + if (const parser::CharBlock *constructName{GetStmtName(constructStmt)}) { if (endName) { if (*constructName != *endName) { context_ diff --git a/flang/lib/Semantics/resolve-names-utils.cpp b/flang/lib/Semantics/resolve-names-utils.cpp --- a/flang/lib/Semantics/resolve-names-utils.cpp +++ b/flang/lib/Semantics/resolve-names-utils.cpp @@ -734,9 +734,9 @@ std::function predicate) { if (!type) { return false; - } else if (const IntrinsicTypeSpec * intrinsic{type->AsIntrinsic()}) { + } else if (const IntrinsicTypeSpec *intrinsic{type->AsIntrinsic()}) { return predicate(*intrinsic); - } else if (const DerivedTypeSpec * derived{type->AsDerived()}) { + } else if (const DerivedTypeSpec *derived{type->AsDerived()}) { for (const auto &pair : *derived->typeSymbol().scope()) { const Symbol &component{*pair.second}; if (IsAllocatableOrPointer(component) || @@ -815,20 +815,20 @@ } }, [&](ProcEntityDetails &proc) { - if (const Symbol * - mappedSymbol{MapInterface(proc.procInterface())}) { + if (const Symbol *mappedSymbol{ + MapInterface(proc.procInterface())}) { proc.set_procInterface(*mappedSymbol); - } else if (const DeclTypeSpec * mappedType{MapType(proc.type())}) { + } else if (const DeclTypeSpec *mappedType{MapType(proc.type())}) { proc.set_type(*mappedType); } if (proc.init()) { - if (const Symbol * mapped{MapSymbol(*proc.init())}) { + if (const Symbol *mapped{MapSymbol(*proc.init())}) { proc.set_init(*mapped); } } }, [&](const HostAssocDetails &hostAssoc) { - if (const Symbol * mapped{MapSymbol(hostAssoc.symbol())}) { + if (const Symbol *mapped{MapSymbol(hostAssoc.symbol())}) { symbol.set_details(HostAssocDetails{*mapped}); } }, diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp --- a/flang/lib/Semantics/resolve-names.cpp +++ b/flang/lib/Semantics/resolve-names.cpp @@ -1752,7 +1752,7 @@ } symbol.SetBindName(std::move(*label)); if (!oldBindName.empty()) { - if (const std::string * newBindName{symbol.GetBindName()}) { + if (const std::string *newBindName{symbol.GetBindName()}) { if (oldBindName != *newBindName) { Say(symbol.name(), "The entity '%s' has multiple BIND names"_err_en_US); } @@ -1869,7 +1869,7 @@ // expression semantics if the DeclTypeSpec is a valid TypeSpec. // The grammar ensures that it's an intrinsic or derived type spec, // not TYPE(*) or CLASS(*) or CLASS(T). - if (const DeclTypeSpec * spec{state_.declTypeSpec}) { + if (const DeclTypeSpec *spec{state_.declTypeSpec}) { switch (spec->category()) { case DeclTypeSpec::Numeric: case DeclTypeSpec::Logical: @@ -1877,7 +1877,7 @@ typeSpec.declTypeSpec = spec; break; case DeclTypeSpec::TypeDerived: - if (const DerivedTypeSpec * derived{spec->AsDerived()}) { + if (const DerivedTypeSpec *derived{spec->AsDerived()}) { CheckForAbstractType(derived->typeSymbol()); // C703 typeSpec.declTypeSpec = spec; } @@ -2148,7 +2148,7 @@ // Called from ConvertTo{Object/Proc}Entity to cope with any appearance // of the function result in a specification expression. void FuncResultStack::CompleteTypeIfFunctionResult(Symbol &symbol) { - if (FuncInfo * info{Top()}) { + if (FuncInfo *info{Top()}) { if (info->resultSymbol == &symbol) { CompleteFunctionResultType(); } @@ -2336,7 +2336,7 @@ } Symbol *ScopeHandler::FindSymbol(const Scope &scope, const parser::Name &name) { if (scope.IsDerivedType()) { - if (Symbol * symbol{scope.FindComponent(name.source)}) { + if (Symbol *symbol{scope.FindComponent(name.source)}) { if (symbol->has()) { return Resolve(name, symbol); } @@ -2353,7 +2353,7 @@ Symbol &ScopeHandler::MakeSymbol( Scope &scope, const SourceName &name, Attrs attrs) { - if (Symbol * symbol{FindInScope(scope, name)}) { + if (Symbol *symbol{FindInScope(scope, name)}) { CheckDuplicatedAttrs(name, *symbol, attrs); SetExplicitAttrs(*symbol, attrs); return *symbol; @@ -2414,12 +2414,12 @@ } Symbol *ScopeHandler::FindInScopeOrBlockConstructs( const Scope &scope, SourceName name) { - if (Symbol * symbol{FindInScope(scope, name)}) { + if (Symbol *symbol{FindInScope(scope, name)}) { return symbol; } for (const Scope &child : scope.children()) { if (child.kind() == Scope::Kind::BlockConstruct) { - if (Symbol * symbol{FindInScopeOrBlockConstructs(child, name)}) { + if (Symbol *symbol{FindInScopeOrBlockConstructs(child, name)}) { return symbol; } } @@ -2454,7 +2454,7 @@ if (context().HasError(symbol) || !NeedsType(symbol)) { return; } - if (const DeclTypeSpec * type{GetImplicitType(symbol)}) { + if (const DeclTypeSpec *type{GetImplicitType(symbol)}) { symbol.set(Symbol::Flag::Implicit); symbol.SetType(*type); return; @@ -2554,7 +2554,7 @@ const auto *type{implicitRulesMap_->at(scope).GetType( symbol.name(), respectImplicitNoneType)}; if (type) { - if (const DerivedTypeSpec * derived{type->AsDerived()}) { + if (const DerivedTypeSpec *derived{type->AsDerived()}) { // Resolve any forward-referenced derived type; a quick no-op else. auto &instantiatable{*const_cast(derived)}; instantiatable.Instantiate(currScope()); @@ -2926,7 +2926,7 @@ return; } const SourceName &name{useSymbol->name()}; - if (const Symbol * symbol{FindInScope(name)}) { + if (const Symbol *symbol{FindInScope(name)}) { if (const auto *useDetails{symbol->detailsIf()}) { const Symbol &moduleSymbol{useDetails->symbol()}; if (moduleSymbol.name() == name && @@ -3052,10 +3052,10 @@ // it can be locally extended without corrupting the original. GenericDetails generic; generic.CopyFrom(*localGeneric); - if (Symbol * spec{localGeneric->specific()}; + if (Symbol *spec{localGeneric->specific()}; spec && !spec->attrs().test(Attr::PRIVATE)) { generic.set_specific(*spec); - } else if (Symbol * dt{generic.derivedType()}; + } else if (Symbol *dt{generic.derivedType()}; dt && dt->attrs().test(Attr::PRIVATE)) { generic.clear_derivedType(); } @@ -3073,7 +3073,7 @@ localSymbol.flags() = useSymbol.flags(); AddGenericUse(*localGeneric, localName, useUltimate); localGeneric->CopyFrom(*useGeneric); - if (const Symbol * useSpec{useGeneric->specific()}; + if (const Symbol *useSpec{useGeneric->specific()}; useSpec && !useSpec->attrs().test(Attr::PRIVATE)) { if (localGeneric->derivedType()) { msg = @@ -3085,7 +3085,7 @@ msg = "Cannot use-associate generic interface '%s' with specific procedure of the same name when another such interface and procedure are in scope"_err_en_US; } - } else if (const Symbol * useDT{useGeneric->derivedType()}; + } else if (const Symbol *useDT{useGeneric->derivedType()}; useDT && !useDT->attrs().test(Attr::PRIVATE)) { if (localGeneric->specific()) { msg = @@ -3503,7 +3503,7 @@ bool SubprogramVisitor::Pre(const parser::Suffix &suffix) { if (suffix.resultName) { if (IsFunction(currScope())) { - if (FuncResultStack::FuncInfo * info{funcResultStack().Top()}) { + if (FuncResultStack::FuncInfo *info{funcResultStack().Top()}) { if (info->inFunctionStmt) { info->resultName = &suffix.resultName.value(); } else { @@ -3513,7 +3513,7 @@ } else { Message &msg{Say(*suffix.resultName, "RESULT(%s) may appear only in a function"_err_en_US)}; - if (const Symbol * subprogram{InclusiveScope().symbol()}) { + if (const Symbol *subprogram{InclusiveScope().symbol()}) { msg.Attach(subprogram->name(), "Containing subprogram"_en_US); } } @@ -3805,7 +3805,7 @@ bool hasGlobalBindingName{outer.IsGlobal() && suffix && suffix->binding && suffix->binding->v.has_value()}; if (!hasGlobalBindingName) { - if (Symbol * extant{FindSymbol(outer, entryName)}) { + if (Symbol *extant{FindSymbol(outer, entryName)}) { if (!HandlePreviousCalls(entryName, *extant, subpFlag)) { if (outer.IsTopLevel()) { Say2(entryName, @@ -3830,7 +3830,7 @@ "RESULT(%s) may not have the same name as the function"_err_en_US, subprogram, "Containing function"_en_US); badResultName = true; - } else if (const Symbol * extant{FindSymbol(outer, resultName)}) { // C1574 + } else if (const Symbol *extant{FindSymbol(outer, resultName)}) { // C1574 if (const auto *details{extant->detailsIf()}) { if (details->entryScope() == &currScope()) { Say2(resultName.source, @@ -3973,7 +3973,7 @@ SetBindNameOn(entrySymbol); for (const auto &dummyArg : std::get>(stmt.t)) { if (const auto *dummyName{std::get_if(&dummyArg.u)}) { - if (Symbol * dummy{FindInScope(*dummyName)}) { + if (Symbol *dummy{FindInScope(*dummyName)}) { if (dummy->test(Symbol::Flag::EntryDummyArgument)) { const auto *subp{dummy->detailsIf()}; if (subp && subp->isInterface()) { // ok @@ -4005,7 +4005,7 @@ symbol = generic->specific(); } } - if (const Symbol * defnIface{FindSeparateModuleSubprogramInterface(symbol)}) { + if (const Symbol *defnIface{FindSeparateModuleSubprogramInterface(symbol)}) { // Error recovery in case of multiple definitions symbol = const_cast(defnIface); } @@ -4061,8 +4061,8 @@ if (moduleInterface && &moduleInterface->owner() == &currScope()) { // Subprogram is MODULE FUNCTION or MODULE SUBROUTINE with an interface // previously defined in the same scope. - if (GenericDetails * - generic{DEREF(FindSymbol(name)).detailsIf()}) { + if (GenericDetails *generic{ + DEREF(FindSymbol(name)).detailsIf()}) { generic->clear_specific(); } else { EraseSymbol(name); @@ -4219,7 +4219,7 @@ } set_inheritFromParent(false); } - if (Symbol * found{FindSymbol(name)}; + if (Symbol *found{FindSymbol(name)}; found && found->has()) { found->set(subpFlag); // PushScope() created symbol } @@ -4991,9 +4991,9 @@ vectorDerivedType.CookParameters(GetFoldingContext()); } - if (const DeclTypeSpec * - extant{ppcBuiltinTypesScope->FindInstantiatedDerivedType( - vectorDerivedType, DeclTypeSpec::Category::TypeDerived)}) { + if (const DeclTypeSpec *extant{ + ppcBuiltinTypesScope->FindInstantiatedDerivedType( + vectorDerivedType, DeclTypeSpec::Category::TypeDerived)}) { // This derived type and parameter expressions (if any) are already present // in the __ppc_intrinsics scope. SetDeclTypeSpec(*extant); @@ -5015,7 +5015,7 @@ void DeclarationVisitor::Post(const parser::DeclarationTypeSpec::Type &type) { const parser::Name &derivedName{std::get(type.derived.t)}; - if (const Symbol * derivedSymbol{derivedName.symbol}) { + if (const Symbol *derivedSymbol{derivedName.symbol}) { CheckForAbstractType(*derivedSymbol); // C706 } } @@ -5084,8 +5084,8 @@ if (!spec->MightBeParameterized()) { spec->EvaluateParameters(context()); } - if (const DeclTypeSpec * - extant{currScope().FindInstantiatedDerivedType(*spec, category)}) { + if (const DeclTypeSpec *extant{ + currScope().FindInstantiatedDerivedType(*spec, category)}) { // This derived type and parameter expressions (if any) are already present // in this scope. SetDeclTypeSpec(*extant); @@ -5116,8 +5116,7 @@ if (auto spec{ResolveDerivedType(typeName)}) { spec->CookParameters(GetFoldingContext()); spec->EvaluateParameters(context()); - if (const DeclTypeSpec * - extant{currScope().FindInstantiatedDerivedType( + if (const DeclTypeSpec *extant{currScope().FindInstantiatedDerivedType( *spec, DeclTypeSpec::TypeDerived)}) { SetDeclTypeSpec(*extant); } else { @@ -5240,7 +5239,7 @@ auto attr{std::get(x.t)}; for (auto &decl : std::get>(x.t)) { auto &name{std::get(decl.t)}; - if (Symbol * symbol{MakeTypeSymbol(name, TypeParamDetails{attr})}) { + if (Symbol *symbol{MakeTypeSymbol(name, TypeParamDetails{attr})}) { SetType(name, *type); if (auto &init{ std::get>(decl.t)}) { @@ -5431,7 +5430,7 @@ } auto attrs{HandleSaveName(name.source, GetAttrs())}; DerivedTypeDetails *dtDetails{nullptr}; - if (Symbol * symbol{currScope().symbol()}) { + if (Symbol *symbol{currScope().symbol()}) { dtDetails = symbol->detailsIf(); } if (!dtDetails) { @@ -5519,7 +5518,7 @@ CHECK(currScope().IsDerivedType()); for (auto &declaration : tbps.declarations) { auto &bindingName{std::get(declaration.t)}; - if (Symbol * binding{FindInScope(bindingName)}) { + if (Symbol *binding{FindInScope(bindingName)}) { if (auto *details{binding->detailsIf()}) { const Symbol &ultimate{details->symbol().GetUltimate()}; const Symbol &procedure{BypassGeneric(ultimate)}; @@ -5551,7 +5550,7 @@ if (!GetAttrs().test(Attr::DEFERRED)) { // C783 Say("DEFERRED is required when an interface-name is provided"_err_en_US); } - if (Symbol * interface{NoteInterfaceName(x.interfaceName)}) { + if (Symbol *interface{NoteInterfaceName(x.interfaceName)}) { for (auto &bindingName : x.bindingNames) { if (auto *s{ MakeTypeSymbol(bindingName, ProcBindingDetails{*interface})}) { @@ -5600,7 +5599,7 @@ } else { // look in ancestor types for a generic of the same name for (const auto &name : GetAllNames(context(), symbolName)) { - if (Symbol * inherited{currScope().FindComponent(SourceName{name})}) { + if (Symbol *inherited{currScope().FindComponent(SourceName{name})}) { if (inherited->has()) { CheckAccessibility(symbolName, isPrivate, *inherited); // C771 } else { @@ -5775,7 +5774,7 @@ } const parser::ObjectName &pointeeName{std::get<1>(bp.t)}; DeclareObjectEntity(pointeeName); - if (Symbol * pointee{pointeeName.symbol}) { + if (Symbol *pointee{pointeeName.symbol}) { if (!ConvertToObjectEntity(*pointee)) { return; } @@ -6025,7 +6024,7 @@ } else if (symbol->IsFuncResult()) { Say(name, "Function result '%s' may not appear in a COMMON block"_err_en_US); - } else if (const DeclTypeSpec * type{symbol->GetType()}) { + } else if (const DeclTypeSpec *type{symbol->GetType()}) { if (type->category() == DeclTypeSpec::ClassStar) { Say(name, "Unlimited polymorphic pointer '%s' may not appear in a COMMON block"_err_en_US); @@ -6176,7 +6175,7 @@ name, symbol, "Coarray '%s' not allowed in a locality-spec"_err_en_US); return false; } - if (const DeclTypeSpec * type{symbol.GetType()}) { + if (const DeclTypeSpec *type{symbol.GetType()}) { if (type->IsPolymorphic() && IsDummy(symbol) && !IsPointer(symbol)) { // C1128 SayWithDecl(name, symbol, @@ -6316,7 +6315,7 @@ Symbol *ultimate{symbol ? &symbol->GetUltimate() : nullptr}; auto *generic{ultimate ? ultimate->detailsIf() : nullptr}; if (generic) { - if (Symbol * genDT{generic->derivedType()}) { + if (Symbol *genDT{generic->derivedType()}) { symbol = genDT; generic = nullptr; } @@ -6377,7 +6376,7 @@ } void DeclarationVisitor::CheckExplicitInterface(const parser::Name &name) { - if (const Symbol * symbol{name.symbol}) { + if (const Symbol *symbol{name.symbol}) { const Symbol &ultimate{symbol->GetUltimate()}; if (!context().HasError(*symbol) && !context().HasError(ultimate) && !ultimate.HasExplicitInterface()) { @@ -6675,7 +6674,7 @@ auto &mutableData{const_cast(data)}; if (auto *elem{parser::Unwrap(mutableData)}) { if (const auto *name{std::get_if(&elem->base.u)}) { - if (const Symbol * symbol{FindSymbol(*name)}) { + if (const Symbol *symbol{FindSymbol(*name)}) { const Symbol &ultimate{symbol->GetUltimate()}; if (ultimate.has()) { mutableData.u = elem->ConvertToStructureConstructor( @@ -6813,15 +6812,15 @@ } } } else { - if (const Symbol * - whole{UnwrapWholeSymbolDataRef(association.selector.expr)}) { + if (const Symbol *whole{ + UnwrapWholeSymbolDataRef(association.selector.expr)}) { ConvertToObjectEntity(const_cast(*whole)); if (!IsVariableName(*whole)) { Say(association.selector.source, // C901 "Selector is not a variable"_err_en_US); association = {}; } - if (const DeclTypeSpec * type{whole->GetType()}) { + if (const DeclTypeSpec *type{whole->GetType()}) { if (!type->IsPolymorphic()) { // C1159 Say(association.selector.source, "Selector '%s' in SELECT TYPE statement must be " @@ -6906,11 +6905,11 @@ if (x && !x->symbol) { // Construct names are not scoped by BLOCK in the standard, but many, // but not all, compilers do treat them as if they were so scoped. - if (Symbol * inner{FindInScope(currScope(), *x)}) { + if (Symbol *inner{FindInScope(currScope(), *x)}) { SayAlreadyDeclared(*x, *inner); } else { - if (Symbol * - other{FindInScopeOrBlockConstructs(InclusiveScope(), x->source)}) { + if (Symbol *other{ + FindInScopeOrBlockConstructs(InclusiveScope(), x->source)}) { SayWithDecl(*x, *other, "The construct name '%s' should be distinct at the subprogram level"_port_en_US); } @@ -6938,8 +6937,8 @@ "The associate name '%s' is already used in this associate statement"_err_en_US); return nullptr; } - } else if (const Symbol * - whole{UnwrapWholeSymbolDataRef(association.selector.expr)}) { + } else if (const Symbol *whole{ + UnwrapWholeSymbolDataRef(association.selector.expr)}) { symbol = &MakeSymbol(whole->name()); } else { return nullptr; @@ -6983,7 +6982,7 @@ void ConstructVisitor::SetAttrsFromAssociation(Symbol &symbol) { Attrs attrs{evaluate::GetAttrs(GetCurrentAssociation().selector.expr)}; symbol.attrs() |= - attrs & Attrs{Attr::TARGET, Attr::ASYNCHRONOUS, Attr::VOLATILE}; + attrs &Attrs{Attr::TARGET, Attr::ASYNCHRONOUS, Attr::VOLATILE}; if (attrs.test(Attr::POINTER)) { SetImplicitAttr(symbol, Attr::TARGET); } @@ -7112,9 +7111,9 @@ Say(std::move(*error)); } for (auto &name : x.names) { - if (Symbol * outer{FindSymbol(scope.parent(), name)}) { + if (Symbol *outer{FindSymbol(scope.parent(), name)}) { scope.add_importName(name.source); - if (Symbol * symbol{FindInScope(name)}) { + if (Symbol *symbol{FindInScope(name)}) { if (outer->GetUltimate() == symbol->GetUltimate()) { Say(name, "The same '%s' is already present in this scope"_port_en_US); @@ -7188,7 +7187,7 @@ NotePossibleBadForwardRef(name); return &name; } - if (Symbol * symbol{name.symbol}) { + if (Symbol *symbol{name.symbol}) { if (CheckUseError(name)) { return nullptr; // reported an error } @@ -7313,7 +7312,7 @@ if (!type) { return nullptr; // should have already reported error } - if (const IntrinsicTypeSpec * intrinsic{type->AsIntrinsic()}) { + if (const IntrinsicTypeSpec *intrinsic{type->AsIntrinsic()}) { auto category{intrinsic->category()}; MiscDetails::Kind miscKind{MiscDetails::Kind::None}; if (component.source == "kind") { @@ -7333,9 +7332,9 @@ MakePlaceholder(component, miscKind); return &component; } - } else if (DerivedTypeSpec * derived{type->AsDerived()}) { + } else if (DerivedTypeSpec *derived{type->AsDerived()}) { derived->Instantiate(currScope()); // in case of forward referenced type - if (const Scope * scope{derived->scope()}) { + if (const Scope *scope{derived->scope()}) { if (Resolve(component, scope->FindComponent(component.source))) { if (auto msg{CheckAccessibleSymbol(currScope(), *component.symbol)}) { context().Say(component.source, *msg); @@ -7496,7 +7495,7 @@ [&](const parser::ProcComponentRef &x) { Walk(x); const parser::Name &name{x.v.thing.component}; - if (Symbol * symbol{name.symbol}) { + if (Symbol *symbol{name.symbol}) { if (IsProcedure(*symbol)) { SetProcFlag(name, *symbol, procFlag); } @@ -7598,7 +7597,7 @@ // Subtlety: The symbol pointers in the parse tree are not set, because // they might end up resolving elsewhere (e.g., construct entities in // SELECT TYPE). - if (Symbol * symbol{currScope().FindSymbol(name->source)}) { + if (Symbol *symbol{currScope().FindSymbol(name->source)}) { Symbol::Flag other{flag == Symbol::Flag::Subroutine ? Symbol::Flag::Function : Symbol::Flag::Subroutine}; @@ -8020,11 +8019,11 @@ ResolveDataRef(dataRef); Walk(bounds); // Resolve unrestricted specific intrinsic procedures as in "p => cos". - if (const parser::Name * name{parser::Unwrap(expr)}) { + if (const parser::Name *name{parser::Unwrap(expr)}) { if (NameIsKnownOrIntrinsic(*name)) { // If the name is known because it is an object entity from a host // procedure, create a host associated symbol. - if (Symbol * symbol{name->symbol}; symbol && + if (Symbol *symbol{name->symbol}; symbol && symbol->GetUltimate().has() && IsUplevelReference(*symbol)) { MakeHostAssocSymbol(*name, *symbol); @@ -8117,8 +8116,8 @@ } if (tkr->empty()) { Symbol *symbol{currScope().symbol()}; - if (SubprogramDetails * - subp{symbol ? symbol->detailsIf() : nullptr}) { + if (SubprogramDetails *subp{ + symbol ? symbol->detailsIf() : nullptr}) { subp->set_defaultIgnoreTKR(true); } } else { @@ -8358,7 +8357,7 @@ // will result in calls to the result pointer. // A function cannot be called recursively if RESULT was not used to define a // distinct result name (15.6.2.2 point 4.). - if (Symbol * symbol{scope.symbol()}) { + if (Symbol *symbol{scope.symbol()}) { if (auto *details{symbol->detailsIf()}) { if (details->isFunction()) { ConvertToObjectEntity(const_cast(details->result())); @@ -8490,8 +8489,8 @@ void Post(const parser::DerivedTypeStmt &x) { const auto &name{std::get(x.t)}; - if (Symbol * symbol{name.symbol}) { - if (Scope * scope{symbol->scope()}) { + if (Symbol *symbol{name.symbol}) { + if (Scope *scope{symbol->scope()}) { if (scope->IsDerivedType()) { resolver_.PushScope(*scope); pushedScope_ = true; @@ -8583,10 +8582,10 @@ // Validation is done later in declaration checking. void ResolveNamesVisitor::FinishDerivedTypeInstantiation(Scope &scope) { CHECK(scope.IsDerivedType() && !scope.symbol()); - if (DerivedTypeSpec * spec{scope.derivedTypeSpec()}) { + if (DerivedTypeSpec *spec{scope.derivedTypeSpec()}) { spec->Instantiate(currScope()); const Symbol &origTypeSymbol{spec->typeSymbol()}; - if (const Scope * origTypeScope{origTypeSymbol.scope()}) { + if (const Scope *origTypeScope{origTypeSymbol.scope()}) { CHECK(origTypeScope->IsDerivedType() && origTypeScope->symbol() == &origTypeSymbol); auto &foldingContext{GetFoldingContext()}; @@ -8597,7 +8596,7 @@ if (IsPointer(comp)) { if (auto *details{comp.detailsIf()}) { auto origDetails{origComp.get()}; - if (const MaybeExpr & init{origDetails.init()}) { + if (const MaybeExpr &init{origDetails.init()}) { SomeExpr newInit{*init}; MaybeExpr folded{FoldExpr(std::move(newInit))}; details->set_init(std::move(folded)); diff --git a/flang/lib/Semantics/rewrite-parse-tree.cpp b/flang/lib/Semantics/rewrite-parse-tree.cpp --- a/flang/lib/Semantics/rewrite-parse-tree.cpp +++ b/flang/lib/Semantics/rewrite-parse-tree.cpp @@ -79,7 +79,7 @@ } static bool ReturnsDataPointer(const Symbol &symbol) { - if (const Symbol * funcRes{FindFunctionResult(symbol)}) { + if (const Symbol *funcRes{FindFunctionResult(symbol)}) { return IsPointer(*funcRes) && !IsProcedure(*funcRes); } else if (const auto *generic{symbol.detailsIf()}) { for (auto ref : generic->specificProcs()) { @@ -97,8 +97,8 @@ for (auto it{list.begin()}; it != list.end();) { bool isAssignment{false}; if (auto *stmt{std::get_if(&it->u)}) { - if (const Symbol * - symbol{std::get(stmt->statement.value().t).symbol}) { + if (const Symbol *symbol{ + std::get(stmt->statement.value().t).symbol}) { const Symbol &ultimate{symbol->GetUltimate()}; isAssignment = ultimate.has() || ReturnsDataPointer(ultimate); @@ -137,7 +137,7 @@ void FixMisparsedUntaggedNamelistName(READ_OR_WRITE &x) { if (x.iounit && x.format && std::holds_alternative(x.format->u)) { - if (const parser::Name * name{parser::Unwrap(x.format)}) { + if (const parser::Name *name{parser::Unwrap(x.format)}) { if (name->symbol && name->symbol->GetUltimate().has()) { x.controls.emplace_front(parser::IoControlSpec{std::move(*name)}); x.format.reset(); diff --git a/flang/lib/Semantics/runtime-type-info.cpp b/flang/lib/Semantics/runtime-type-info.cpp --- a/flang/lib/Semantics/runtime-type-info.cpp +++ b/flang/lib/Semantics/runtime-type-info.cpp @@ -116,7 +116,7 @@ } if (expr) { if (parameters) { - if (const Symbol * lenParam{evaluate::ExtractBareLenParameter(*expr)}) { + if (const Symbol *lenParam{evaluate::ExtractBareLenParameter(*expr)}) { return PackageIntValue( lenParameterEnum_, FindLenParameterIndex(*parameters, *lenParam)); } @@ -206,7 +206,7 @@ const auto &derivedType{dyType.GetDerivedTypeSpec()}; ObjectEntityDetails object; DeclTypeSpec typeSpec{DeclTypeSpec::TypeDerived, derivedType}; - if (const DeclTypeSpec * spec{scope.FindType(typeSpec)}) { + if (const DeclTypeSpec *spec{scope.FindType(typeSpec)}) { object.set_type(*spec); } else { object.set_type(scope.MakeDerivedType( @@ -388,7 +388,7 @@ } const Symbol *RuntimeTableBuilder::DescribeType(Scope &dtScope) { - if (const Symbol * info{dtScope.runtimeDerivedTypeDescription()}) { + if (const Symbol *info{dtScope.runtimeDerivedTypeDescription()}) { return info; } const DerivedTypeSpec *derivedTypeSpec{dtScope.derivedTypeSpec()}; @@ -401,8 +401,8 @@ // a module but used only by clients and submodules, enabling the // run-time "no initialization needed here" flag to work. DerivedTypeSpec derived{dtScope.symbol()->name(), *dtScope.symbol()}; - if (const SymbolVector * - lenParameters{GetTypeParameters(*dtScope.symbol())}) { + if (const SymbolVector *lenParameters{ + GetTypeParameters(*dtScope.symbol())}) { // Create dummy deferred values for the length parameters so that the // DerivedTypeSpec is complete and can be used in helpers. for (SymbolRef lenParam : *lenParameters) { @@ -752,8 +752,8 @@ AddValue(values, componentSchema_, "offset"s, IntExpr<8>(symbol.offset())); // CHARACTER length auto len{typeAndShape->LEN()}; - if (const semantics::DerivedTypeSpec * - pdtInstance{dtScope.derivedTypeSpec()}) { + if (const semantics::DerivedTypeSpec *pdtInstance{ + dtScope.derivedTypeSpec()}) { auto restorer{foldingContext.WithPDTInstance(*pdtInstance)}; len = Fold(foldingContext, std::move(len)); } @@ -785,11 +785,11 @@ evaluate::Designator{ DEREF(derivedDescription)}})); // Package values of LEN parameters, if any - if (const SymbolVector * specParams{GetTypeParameters(spec.typeSymbol())}) { + if (const SymbolVector *specParams{GetTypeParameters(spec.typeSymbol())}) { for (SymbolRef ref : *specParams) { const auto &tpd{ref->get()}; if (tpd.attr() == common::TypeParamAttr::Len) { - if (const ParamValue * paramValue{spec.FindParameter(ref->name())}) { + if (const ParamValue *paramValue{spec.FindParameter(ref->name())}) { lenParams.emplace_back(GetValue(*paramValue, parameters)); } else { lenParams.emplace_back(GetValue(tpd.init(), parameters)); @@ -972,7 +972,7 @@ binding->set_numPrivatesNotOverridden(0); } } - if (const Scope * parentScope{dtScope.GetDerivedTypeParent()}) { + if (const Scope *parentScope{dtScope.GetDerivedTypeParent()}) { result = CollectBindings(*parentScope); // Apply overrides from the local bindings of the extended type for (auto iter{result.begin()}; iter != result.end(); ++iter) { @@ -1020,7 +1020,7 @@ RuntimeTableBuilder::DescribeSpecialGenerics(const Scope &dtScope, const Scope &thisScope, const DerivedTypeSpec *derivedTypeSpec) const { std::map specials; - if (const Scope * parentScope{dtScope.GetDerivedTypeParent()}) { + if (const Scope *parentScope{dtScope.GetDerivedTypeParent()}) { specials = DescribeSpecialGenerics(*parentScope, thisScope, derivedTypeSpec); } @@ -1234,16 +1234,18 @@ // dummy argument. Returns a non-null DeclTypeSpec pointer only if that // dtv argument exists and is a derived type. static const DeclTypeSpec *GetDefinedIoSpecificArgType(const Symbol &specific) { - const Symbol *interface{&specific.GetUltimate()}; + const Symbol *interface { + &specific.GetUltimate() + }; if (const auto *procEntity{specific.detailsIf()}) { interface = procEntity->procInterface(); } if (interface) { - if (const SubprogramDetails * - subprogram{interface->detailsIf()}; + if (const SubprogramDetails *subprogram{ + interface->detailsIf()}; subprogram && !subprogram->dummyArgs().empty()) { - if (const Symbol * dtvArg{subprogram->dummyArgs().at(0)}) { - if (const DeclTypeSpec * declType{dtvArg->GetType()}) { + if (const Symbol *dtvArg{subprogram->dummyArgs().at(0)}) { + if (const DeclTypeSpec *declType{dtvArg->GetType()}) { return declType->AsDerived() ? declType : nullptr; } } @@ -1256,7 +1258,7 @@ // defined I/O. static const Symbol *FindGenericDefinedIo( const Scope &scope, common::DefinedIo which) { - if (const Symbol * symbol{scope.FindSymbol(GenericKind::AsFortran(which))}) { + if (const Symbol *symbol{scope.FindSymbol(GenericKind::AsFortran(which))}) { const Symbol &generic{symbol->GetUltimate()}; const auto &genericDetails{generic.get()}; CHECK(std::holds_alternative(genericDetails.kind().u)); @@ -1282,13 +1284,12 @@ {common::DefinedIo::ReadFormatted, common::DefinedIo::ReadUnformatted, common::DefinedIo::WriteFormatted, common::DefinedIo::WriteUnformatted}) { - if (const Symbol * generic{FindGenericDefinedIo(scope, which)}) { + if (const Symbol *generic{FindGenericDefinedIo(scope, which)}) { for (auto specific : generic->get().specificProcs()) { - if (const DeclTypeSpec * - declType{GetDefinedIoSpecificArgType(*specific)}) { + if (const DeclTypeSpec *declType{ + GetDefinedIoSpecificArgType(*specific)}) { const DerivedTypeSpec &derived{DEREF(declType->AsDerived())}; - if (const Symbol * - dtDesc{derived.scope() + if (const Symbol *dtDesc{derived.scope() ? derived.scope()->runtimeDerivedTypeDescription() : nullptr}) { if (useRuntimeTypeInfoEntries && @@ -1344,11 +1345,10 @@ static const Symbol *FindSpecificDefinedIo(const Scope &scope, const evaluate::DynamicType &derived, common::DefinedIo which) { - if (const Symbol * generic{FindGenericDefinedIo(scope, which)}) { + if (const Symbol *generic{FindGenericDefinedIo(scope, which)}) { for (auto ref : generic->get().specificProcs()) { const Symbol &specific{*ref}; - if (const DeclTypeSpec * - thisType{GetDefinedIoSpecificArgType(specific)}) { + if (const DeclTypeSpec *thisType{GetDefinedIoSpecificArgType(specific)}) { if (evaluate::DynamicType{DEREF(thisType->AsDerived()), true} .IsTkCompatibleWith(derived)) { return &specific.GetUltimate(); @@ -1371,8 +1371,8 @@ {common::DefinedIo::ReadFormatted, common::DefinedIo::ReadUnformatted, common::DefinedIo::WriteFormatted, common::DefinedIo::WriteUnformatted}) { - if (const Symbol * - specific{FindSpecificDefinedIo(typeScope, dyType, which)}) { + if (const Symbol *specific{ + FindSpecificDefinedIo(typeScope, dyType, which)}) { // There's a non-TBP defined I/O procedure in the scope of the type's // definition that applies to this type. It will appear in the type's // runtime information. Determine whether it still applies in the diff --git a/flang/lib/Semantics/scope.cpp b/flang/lib/Semantics/scope.cpp --- a/flang/lib/Semantics/scope.cpp +++ b/flang/lib/Semantics/scope.cpp @@ -104,7 +104,7 @@ auto found{find(name)}; if (found != end()) { return &*found->second; - } else if (const Scope * parent{GetDerivedTypeParent()}) { + } else if (const Scope *parent{GetDerivedTypeParent()}) { return parent->FindComponent(name); } else { return nullptr; @@ -219,7 +219,7 @@ case TypeCategory::Complex: return &MakeNumericType(dyType->category(), KindExpr{dyType->kind()}); case TypeCategory::Character: - if (const ParamValue * lenParam{dyType->charLengthParamValue()}) { + if (const ParamValue *lenParam{dyType->charLengthParamValue()}) { return &MakeCharacterType( ParamValue{*lenParam}, KindExpr{dyType->kind()}); } else { @@ -344,8 +344,8 @@ const auto describe{[&](parser::CharBlock src) { if (auto range{allCookedSources.GetProvenanceRange(src)}) { std::size_t offset; - if (const parser::SourceFile * - file{allSources.GetSourceFile(range->start(), &offset)}) { + if (const parser::SourceFile *file{ + allSources.GetSourceFile(range->start(), &offset)}) { return "'"s + file->path() + "' at " + std::to_string(offset) + " for " + std::to_string(range->size()); } else { @@ -420,7 +420,7 @@ template static bool IsParameterizedDerivedTypeHelper(const Scope &scope) { if (scope.IsDerivedType()) { - if (const Scope * parent{scope.GetDerivedTypeParent()}) { + if (const Scope *parent{scope.GetDerivedTypeParent()}) { if (IsParameterizedDerivedTypeHelper(*parent)) { return true; } @@ -457,8 +457,8 @@ } const Scope *Scope::GetDerivedTypeParent() const { - if (const Symbol * symbol{GetSymbol()}) { - if (const DerivedTypeSpec * parent{symbol->GetParentTypeSpec(this)}) { + if (const Symbol *symbol{GetSymbol()}) { + if (const DerivedTypeSpec *parent{symbol->GetParentTypeSpec(this)}) { return parent->scope(); } } diff --git a/flang/lib/Semantics/semantics.cpp b/flang/lib/Semantics/semantics.cpp --- a/flang/lib/Semantics/semantics.cpp +++ b/flang/lib/Semantics/semantics.cpp @@ -406,13 +406,13 @@ } void SemanticsContext::CheckIndexVarRedefine(const parser::Variable &variable) { - if (const Symbol * entity{GetLastName(variable).symbol}) { + if (const Symbol *entity{GetLastName(variable).symbol}) { CheckIndexVarRedefine(variable.GetSource(), *entity); } } void SemanticsContext::CheckIndexVarRedefine(const parser::Name &name) { - if (const Symbol * entity{name.symbol}) { + if (const Symbol *entity{name.symbol}) { CheckIndexVarRedefine(name.source, *entity); } } @@ -420,14 +420,14 @@ void SemanticsContext::ActivateIndexVar( const parser::Name &name, IndexVarKind kind) { CheckIndexVarRedefine(name); - if (const Symbol * indexVar{name.symbol}) { + if (const Symbol *indexVar{name.symbol}) { activeIndexVars_.emplace( ResolveAssociations(*indexVar), IndexVarInfo{name.source, kind}); } } void SemanticsContext::DeactivateIndexVar(const parser::Name &name) { - if (Symbol * indexVar{name.symbol}) { + if (Symbol *indexVar{name.symbol}) { auto it{activeIndexVars_.find(ResolveAssociations(*indexVar))}; if (it != activeIndexVars_.end() && it->second.location == name.source) { activeIndexVars_.erase(it); diff --git a/flang/lib/Semantics/symbol.cpp b/flang/lib/Semantics/symbol.cpp --- a/flang/lib/Semantics/symbol.cpp +++ b/flang/lib/Semantics/symbol.cpp @@ -455,7 +455,7 @@ DumpOptional(os, "bindName", x.bindName()); DumpOptional(os, "passName", x.passName()); if (x.init()) { - if (const Symbol * target{*x.init()}) { + if (const Symbol *target{*x.init()}) { os << " => " << target->name(); } else { os << " => NULL()"; @@ -656,7 +656,7 @@ } const DerivedTypeSpec *Symbol::GetParentTypeSpec(const Scope *scope) const { - if (const Symbol * parentComponent{GetParentComponent(scope)}) { + if (const Symbol *parentComponent{GetParentComponent(scope)}) { const auto &object{parentComponent->get()}; return &object.type()->derivedTypeSpec(); } else { @@ -666,7 +666,7 @@ const Symbol *Symbol::GetParentComponent(const Scope *scope) const { if (const auto *dtDetails{detailsIf()}) { - if (const Scope * localScope{scope ? scope : scope_}) { + if (const Scope *localScope{scope ? scope : scope_}) { return dtDetails->GetParentComponent(DEREF(localScope)); } } @@ -683,7 +683,7 @@ const Symbol *DerivedTypeDetails::GetParentComponent(const Scope &scope) const { if (auto extends{GetParentComponentName()}) { if (auto iter{scope.find(*extends)}; iter != scope.cend()) { - if (const Symbol & symbol{*iter->second}; + if (const Symbol &symbol{*iter->second}; symbol.test(Symbol::Flag::ParentComp)) { return &symbol; } @@ -697,7 +697,7 @@ const Symbol &symbol{*pair.second}; if (const auto *details{symbol.detailsIf()}) { if (details->dummyArgs().size() == 1) { - if (const Symbol * arg{details->dummyArgs().at(0)}) { + if (const Symbol *arg{details->dummyArgs().at(0)}) { if (const auto *object{arg->detailsIf()}) { if (rank == object->shape().Rank() || object->IsAssumedRank() || IsElementalProcedure(symbol)) { diff --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp --- a/flang/lib/Semantics/tools.cpp +++ b/flang/lib/Semantics/tools.cpp @@ -260,7 +260,7 @@ } bool IsInStmtFunction(const Symbol &symbol) { - if (const Symbol * function{symbol.owner().symbol()}) { + if (const Symbol *function{symbol.owner().symbol()}) { return IsStmtFunction(*function); } return false; @@ -290,7 +290,7 @@ } bool IsBindCProcedure(const Scope &scope) { - if (const Symbol * symbol{scope.GetSymbol()}) { + if (const Symbol *symbol{scope.GetSymbol()}) { return IsBindCProcedure(*symbol); } else { return false; @@ -316,11 +316,10 @@ for (const auto &pair : scope) { const Symbol &symbol{*pair.second}; if (const auto *details{symbol.detailsIf()}) { - if (const DeclTypeSpec * type{details->type()}) { - if (const DerivedTypeSpec * derived{type->AsDerived()}) { - if (const Scope * nested{derived->scope()}) { - if (const Symbol * - pointer{FindPointerComponent(*nested, visited)}) { + if (const DeclTypeSpec *type{details->type()}) { + if (const DerivedTypeSpec *derived{type->AsDerived()}) { + if (const Scope *nested{derived->scope()}) { + if (const Symbol *pointer{FindPointerComponent(*nested, visited)}) { return pointer; } } @@ -337,7 +336,7 @@ } const Symbol *FindPointerComponent(const DerivedTypeSpec &derived) { - if (const Scope * scope{derived.scope()}) { + if (const Scope *scope{derived.scope()}) { return FindPointerComponent(*scope); } else { return nullptr; @@ -345,7 +344,7 @@ } const Symbol *FindPointerComponent(const DeclTypeSpec &type) { - if (const DerivedTypeSpec * derived{type.AsDerived()}) { + if (const DerivedTypeSpec *derived{type.AsDerived()}) { return FindPointerComponent(*derived); } else { return nullptr; @@ -379,7 +378,7 @@ } else if (&GetProgramUnitContaining(ultimate) != &GetProgramUnitContaining(scope)) { return &object; - } else if (const Symbol * block{FindCommonBlockContaining(ultimate)}) { + } else if (const Symbol *block{FindCommonBlockContaining(ultimate)}) { return block; } return nullptr; @@ -388,7 +387,7 @@ const Symbol &BypassGeneric(const Symbol &symbol) { const Symbol &ultimate{symbol.GetUltimate()}; if (const auto *generic{ultimate.detailsIf()}) { - if (const Symbol * specific{generic->specific()}) { + if (const Symbol *specific{generic->specific()}) { return *specific; } } @@ -512,11 +511,11 @@ const Symbol *FindOverriddenBinding(const Symbol &symbol) { if (symbol.has()) { - if (const DeclTypeSpec * parentType{FindParentTypeSpec(symbol.owner())}) { - if (const DerivedTypeSpec * parentDerived{parentType->AsDerived()}) { - if (const Scope * parentScope{parentDerived->typeSymbol().scope()}) { - if (const Symbol * - overridden{parentScope->FindComponent(symbol.name())}) { + if (const DeclTypeSpec *parentType{FindParentTypeSpec(symbol.owner())}) { + if (const DerivedTypeSpec *parentDerived{parentType->AsDerived()}) { + if (const Scope *parentScope{parentDerived->typeSymbol().scope()}) { + if (const Symbol *overridden{ + parentScope->FindComponent(symbol.name())}) { // 7.5.7.3 p1: only accessible bindings are overridden if (!overridden->attrs().test(Attr::PRIVATE) || (FindModuleContaining(overridden->owner()) == @@ -566,7 +565,7 @@ } const DeclTypeSpec *FindParentTypeSpec(const DeclTypeSpec &decl) { - if (const DerivedTypeSpec * derived{decl.AsDerived()}) { + if (const DerivedTypeSpec *derived{decl.AsDerived()}) { return FindParentTypeSpec(*derived); } else { return nullptr; @@ -583,9 +582,9 @@ } const DeclTypeSpec *FindParentTypeSpec(const Symbol &symbol) { - if (const Scope * scope{symbol.scope()}) { + if (const Scope *scope{symbol.scope()}) { if (const auto *details{symbol.detailsIf()}) { - if (const Symbol * parent{details->GetParentComponent(*scope)}) { + if (const Symbol *parent{details->GetParentComponent(*scope)}) { return parent->GetType(); } } @@ -608,8 +607,8 @@ bool IsOrContainsEventOrLockComponent(const Symbol &original) { const Symbol &symbol{ResolveAssociations(original)}; if (const auto *details{symbol.detailsIf()}) { - if (const DeclTypeSpec * type{details->type()}) { - if (const DerivedTypeSpec * derived{type->AsDerived()}) { + if (const DeclTypeSpec *type{details->type()}) { + if (const DerivedTypeSpec *derived{type->AsDerived()}) { return IsEventTypeOrLockType(derived) || FindEventOrLockPotentialComponent(*derived); } @@ -725,8 +724,8 @@ // in check-declarations.cpp. if (const auto *subprog{subr.detailsIf()}; subprog && subprog->dummyArgs().size() == 1) { - if (const Symbol * arg{subprog->dummyArgs()[0]}) { - if (const DeclTypeSpec * type{arg->GetType()}) { + if (const Symbol *arg{subprog->dummyArgs()[0]}) { + if (const DeclTypeSpec *type{arg->GetType()}) { if (type->category() == DeclTypeSpec::TypeDerived && evaluate::AreSameDerivedType(spec, type->derivedTypeSpec())) { result.emplace_back(subr); @@ -749,7 +748,7 @@ return nullptr; } const DeclTypeSpec *type{object->type()}; - if (const DerivedTypeSpec * typeSpec{type ? type->AsDerived() : nullptr}) { + if (const DerivedTypeSpec *typeSpec{type ? type->AsDerived() : nullptr}) { return IsFinalizable( *typeSpec, inProgress, withImpureFinalizer, symbol.Rank()); } @@ -774,8 +773,8 @@ elemental = symbol; } else { if (rank) { - if (const SubprogramDetails * - subp{symbol->detailsIf()}) { + if (const SubprogramDetails *subp{ + symbol->detailsIf()}) { if (const auto &args{subp->dummyArgs()}; !args.empty() && args.at(0) && !evaluate::IsAssumedRank(*args.at(0)) && args.at(0)->Rank() != *rank) { @@ -824,8 +823,8 @@ const Symbol *HasImpureFinal(const Symbol &original) { const Symbol &symbol{ResolveAssociations(original)}; if (symbol.has()) { - if (const DeclTypeSpec * symType{symbol.GetType()}) { - if (const DerivedTypeSpec * derived{symType->AsDerived()}) { + if (const DeclTypeSpec *symType{symbol.GetType()}) { + if (const DerivedTypeSpec *derived{symType->AsDerived()}) { // finalizable assumed-rank not allowed (C839) return evaluate::IsAssumedRank(symbol) ? nullptr @@ -837,7 +836,7 @@ } bool IsAssumedLengthCharacter(const Symbol &symbol) { - if (const DeclTypeSpec * type{symbol.GetType()}) { + if (const DeclTypeSpec *type{symbol.GetType()}) { return type->category() == DeclTypeSpec::Character && type->characterTypeSpec().length().isAssumed(); } else { @@ -1042,21 +1041,21 @@ } bool IsAssumedType(const Symbol &symbol) { - if (const DeclTypeSpec * type{symbol.GetType()}) { + if (const DeclTypeSpec *type{symbol.GetType()}) { return type->IsAssumedType(); } return false; } bool IsPolymorphic(const Symbol &symbol) { - if (const DeclTypeSpec * type{symbol.GetType()}) { + if (const DeclTypeSpec *type{symbol.GetType()}) { return type->IsPolymorphic(); } return false; } bool IsUnlimitedPolymorphic(const Symbol &symbol) { - if (const DeclTypeSpec * type{symbol.GetType()}) { + if (const DeclTypeSpec *type{symbol.GetType()}) { return type->IsUnlimitedPolymorphic(); } return false; @@ -1085,8 +1084,7 @@ // Don't enforce component accessibility checks in module files; // there may be forward-substituted named constants of derived type // whose structure constructors reference private components. - } else if (const Scope * - moduleScope{FindModuleContaining(symbol.owner())}) { + } else if (const Scope *moduleScope{FindModuleContaining(symbol.owner())}) { if (!moduleScope->Contains(scope)) { return parser::MessageFormattedText{ "PRIVATE name '%s' is only accessible within module '%s'"_err_en_US, @@ -1099,7 +1097,7 @@ std::list OrderParameterNames(const Symbol &typeSymbol) { std::list result; - if (const DerivedTypeSpec * spec{typeSymbol.GetParentTypeSpec()}) { + if (const DerivedTypeSpec *spec{typeSymbol.GetParentTypeSpec()}) { result = OrderParameterNames(spec->typeSymbol()); } const auto ¶mNames{typeSymbol.get().paramNames()}; @@ -1109,7 +1107,7 @@ SymbolVector OrderParameterDeclarations(const Symbol &typeSymbol) { SymbolVector result; - if (const DerivedTypeSpec * spec{typeSymbol.GetParentTypeSpec()}) { + if (const DerivedTypeSpec *spec{typeSymbol.GetParentTypeSpec()}) { result = OrderParameterDeclarations(spec->typeSymbol()); } const auto ¶mDecls{typeSymbol.get().paramDecls()}; @@ -1120,8 +1118,8 @@ const DeclTypeSpec &FindOrInstantiateDerivedType( Scope &scope, DerivedTypeSpec &&spec, DeclTypeSpec::Category category) { spec.EvaluateParameters(scope.context()); - if (const DeclTypeSpec * - type{scope.FindInstantiatedDerivedType(spec, category)}) { + if (const DeclTypeSpec *type{ + scope.FindInstantiatedDerivedType(spec, category)}) { return *type; } // Create a new instantiation of this parameterized derived type @@ -1134,7 +1132,7 @@ const Symbol *FindSeparateModuleSubprogramInterface(const Symbol *proc) { if (proc) { if (const auto *subprogram{proc->detailsIf()}) { - if (const Symbol * iface{subprogram->moduleInterface()}) { + if (const Symbol *iface{subprogram->moduleInterface()}) { return iface; } } @@ -1162,7 +1160,7 @@ case SubprogramKind::Internal: return ProcedureDefinitionClass::Internal; } - } else if (const Symbol * subp{FindSubprogram(symbol)}) { + } else if (const Symbol *subp{FindSubprogram(symbol)}) { if (const auto *subpDetails{subp->detailsIf()}) { if (subpDetails->stmtFunction()) { return ProcedureDefinitionClass::StatementFunction; @@ -1201,7 +1199,7 @@ ComponentIterator::const_iterator::PlanComponentTraversal( const Symbol &component) const { if (const auto *details{component.detailsIf()}) { - if (const DeclTypeSpec * type{details->type()}) { + if (const DeclTypeSpec *type{details->type()}) { if (const auto *derived{type->AsDerived()}) { bool traverse{false}; if constexpr (componentKind == ComponentKind::Ordered) { @@ -1271,8 +1269,8 @@ if (deepest.component()) { if (!deepest.descended()) { deepest.set_descended(true); - if (const DerivedTypeSpec * - derived{PlanComponentTraversal(*deepest.component())}) { + if (const DerivedTypeSpec *derived{ + PlanComponentTraversal(*deepest.component())}) { componentPath_.emplace_back(*derived); continue; } @@ -1398,7 +1396,7 @@ const Symbol *FindImmediateComponent(const DerivedTypeSpec &type, const std::function &predicate) { - if (const Scope * scope{type.scope()}) { + if (const Scope *scope{type.scope()}) { const Symbol *parent{nullptr}; for (const auto &pair : *scope) { const Symbol *symbol{&*pair.second}; @@ -1424,7 +1422,7 @@ const Symbol *IsFunctionResultWithSameNameAsFunction(const Symbol &symbol) { if (IsFunctionResult(symbol)) { - if (const Symbol * function{symbol.owner().symbol()}) { + if (const Symbol *function{symbol.owner().symbol()}) { if (symbol.name() == function->name()) { return function; } @@ -1574,7 +1572,7 @@ bool HasDefinedIo(common::DefinedIo which, const DerivedTypeSpec &derived, const Scope *scope) { - if (const Scope * dtScope{derived.scope()}) { + if (const Scope *dtScope{derived.scope()}) { for (const auto &pair : *dtScope) { const Symbol &symbol{*pair.second}; if (const auto *generic{symbol.detailsIf()}) { @@ -1596,7 +1594,7 @@ const auto &generic{iter->second->GetUltimate().get()}; for (auto ref : generic.specificProcs()) { const Symbol &procSym{ref->GetUltimate()}; - if (const DeclTypeSpec * dtSpec{GetDtvArgTypeSpec(procSym)}) { + if (const DeclTypeSpec *dtSpec{GetDtvArgTypeSpec(procSym)}) { if (auto dyDummy{evaluate::DynamicType::From(*dtSpec)}) { if (dyDummy->IsTkCompatibleWith(dyDerived)) { return true; // GENERIC or INTERFACE not in type @@ -1614,10 +1612,10 @@ const SomeExpr *expr, parser::CharBlock at, const char *what) { if (context.languageFeatures().ShouldWarn( common::UsageWarning::F202XAllocatableBreakingChange)) { - if (const Symbol * - symbol{evaluate::UnwrapWholeSymbolOrComponentDataRef(expr)}) { + if (const Symbol *symbol{ + evaluate::UnwrapWholeSymbolOrComponentDataRef(expr)}) { const Symbol &ultimate{ResolveAssociations(*symbol)}; - if (const DeclTypeSpec * type{ultimate.GetType()}; type && + if (const DeclTypeSpec *type{ultimate.GetType()}; type && type->category() == DeclTypeSpec::Category::Character && type->characterTypeSpec().length().isDeferred() && IsAllocatable(ultimate) && ultimate.Rank() == 0) { @@ -1632,7 +1630,7 @@ bool CouldBeDataPointerValuedFunction(const Symbol *original) { if (original) { const Symbol &ultimate{original->GetUltimate()}; - if (const Symbol * result{FindFunctionResult(ultimate)}) { + if (const Symbol *result{FindFunctionResult(ultimate)}) { return IsPointer(*result) && !IsProcedure(*result); } if (const auto *generic{ultimate.detailsIf()}) { diff --git a/flang/lib/Semantics/type.cpp b/flang/lib/Semantics/type.cpp --- a/flang/lib/Semantics/type.cpp +++ b/flang/lib/Semantics/type.cpp @@ -118,8 +118,8 @@ auto parameterDecls{OrderParameterDeclarations(typeSymbol_)}; for (const Symbol &symbol : parameterDecls) { const SourceName &name{symbol.name()}; - if (ParamValue * paramValue{FindParameter(name)}) { - if (const MaybeIntExpr & expr{paramValue->GetExplicit()}) { + if (ParamValue *paramValue{FindParameter(name)}) { + if (const MaybeIntExpr &expr{paramValue->GetExplicit()}) { if (auto converted{evaluate::ConvertToType(symbol, SomeExpr{*expr})}) { SomeExpr folded{ evaluate::Fold(foldingContext, std::move(*converted))}; @@ -267,8 +267,8 @@ auto &foldingContext{context.foldingContext()}; for (auto &pair : typeScope) { Symbol &symbol{*pair.second}; - if (DeclTypeSpec * type{symbol.GetType()}) { - if (DerivedTypeSpec * derived{type->AsDerived()}) { + if (DeclTypeSpec *type{symbol.GetType()}) { + if (DerivedTypeSpec *derived{type->AsDerived()}) { if (!(derived->IsForwardReferenced() && IsAllocatableOrPointer(symbol))) { derived->Instantiate(containingScope); @@ -277,7 +277,7 @@ } if (!IsPointer(symbol)) { if (auto *object{symbol.detailsIf()}) { - if (MaybeExpr & init{object->init()}) { + if (MaybeExpr &init{object->init()}) { auto restorer{foldingContext.messages().SetLocation(symbol.name())}; init = evaluate::NonPointerInitializationExpr( symbol, std::move(*init), foldingContext); @@ -332,11 +332,11 @@ // when there is one, into the new scope as the initialization value // for the parameter. And when there is no explicit value, add an // uninitialized type parameter to forestall use of any default. - if (ParamValue * paramValue{FindParameter(name)}) { + if (ParamValue *paramValue{FindParameter(name)}) { const TypeParamDetails &details{symbol.get()}; paramValue->set_attr(details.attr()); TypeParamDetails instanceDetails{details.attr()}; - if (const DeclTypeSpec * type{details.type()}) { + if (const DeclTypeSpec *type{details.type()}) { instanceDetails.set_type(*type); } desc += sep; @@ -426,7 +426,7 @@ } newSymbol.flags() = oldSymbol.flags(); if (auto *details{newSymbol.detailsIf()}) { - if (const DeclTypeSpec * newType{InstantiateType(newSymbol)}) { + if (const DeclTypeSpec *newType{InstantiateType(newSymbol)}) { details->ReplaceType(*newType); } for (ShapeSpec &dim : details->shape()) { @@ -457,7 +457,7 @@ // instantiation-specific expressions. parser::Walk(*parsedExpr, resetter); } - if (MaybeExpr & init{details->init()}) { + if (MaybeExpr &init{details->init()}) { // Non-pointer components with default initializers are // processed now so that those default initializers can be used // in PARAMETER structure constructors. @@ -469,7 +469,7 @@ } } else if (auto *procDetails{newSymbol.detailsIf()}) { // We have a procedure pointer. Instantiate its return type - if (const DeclTypeSpec * returnType{InstantiateType(newSymbol)}) { + if (const DeclTypeSpec *returnType{InstantiateType(newSymbol)}) { if (!procDetails->procInterface()) { procDetails->ReplaceType(*returnType); } @@ -481,7 +481,7 @@ const DeclTypeSpec *type{symbol.GetType()}; if (!type) { return nullptr; // error has occurred - } else if (const DerivedTypeSpec * spec{type->AsDerived()}) { + } else if (const DerivedTypeSpec *spec{type->AsDerived()}) { return &FindOrInstantiateDerivedType(scope_, CreateDerivedTypeSpec(*spec, symbol.test(Symbol::Flag::ParentComp)), type->category()); @@ -800,7 +800,7 @@ return category_ == Numeric && numericTypeSpec().category() == tc; } bool DeclTypeSpec::IsSequenceType() const { - if (const DerivedTypeSpec * derivedType{AsDerived()}) { + if (const DerivedTypeSpec *derivedType{AsDerived()}) { const auto *typeDetails{ derivedType->typeSymbol().detailsIf()}; return typeDetails && typeDetails->sequence(); diff --git a/flang/runtime/allocatable.cpp b/flang/runtime/allocatable.cpp --- a/flang/runtime/allocatable.cpp +++ b/flang/runtime/allocatable.cpp @@ -154,7 +154,7 @@ } int stat{ReturnError(terminator, descriptor.Allocate(), errMsg, hasStat)}; if (stat == StatOk) { - if (const DescriptorAddendum * addendum{descriptor.Addendum()}) { + if (const DescriptorAddendum *addendum{descriptor.Addendum()}) { if (const auto *derived{addendum->derivedType()}) { if (!derived->noInitializationNeeded()) { stat = Initialize(descriptor, *derived, terminator, hasStat, errMsg); diff --git a/flang/runtime/assign.cpp b/flang/runtime/assign.cpp --- a/flang/runtime/assign.cpp +++ b/flang/runtime/assign.cpp @@ -90,9 +90,9 @@ to.raw().elem_len = from.ElementBytes(); } const typeInfo::DerivedType *derived{nullptr}; - if (const DescriptorAddendum * fromAddendum{from.Addendum()}) { + if (const DescriptorAddendum *fromAddendum{from.Addendum()}) { derived = fromAddendum->derivedType(); - if (DescriptorAddendum * toAddendum{to.Addendum()}) { + if (DescriptorAddendum *toAddendum{to.Addendum()}) { toAddendum->set_derivedType(derived); std::size_t lenParms{derived ? derived->LenParameters() : 0}; for (std::size_t j{0}; j < lenParms; ++j) { @@ -379,8 +379,8 @@ "bytes != from %zd bytes)", toElementBytes, fromElementBytes); } - if (const typeInfo::DerivedType * - updatedToDerived{toAddendum ? toAddendum->derivedType() : nullptr}) { + if (const typeInfo::DerivedType *updatedToDerived{ + toAddendum ? toAddendum->derivedType() : nullptr}) { // Derived type intrinsic assignment, which is componentwise and elementwise // for all components, including parent components (10.2.1.2-3). // The target is first finalized if still necessary (7.5.6.3(1)) @@ -566,7 +566,7 @@ const char *sourceFile, int sourceLine) { Terminator terminator{sourceFile, sourceLine}; // Initialize the "to" if it is of derived type that needs initialization. - if (const DescriptorAddendum * addendum{to.Addendum()}) { + if (const DescriptorAddendum *addendum{to.Addendum()}) { if (const auto *derived{addendum->derivedType()}) { // Do not invoke the initialization, if the descriptor is unallocated. // AssignTemporary() is used for component-by-component assignments, @@ -596,7 +596,7 @@ Terminator terminator{sourceFile, sourceLine}; // Initialize the "to" if it is of derived type that needs initialization. if (!skipToInit) { - if (const DescriptorAddendum * addendum{to.Addendum()}) { + if (const DescriptorAddendum *addendum{to.Addendum()}) { if (const auto *derived{addendum->derivedType()}) { if (!derived->noInitializationNeeded()) { if (ReturnError(terminator, Initialize(to, *derived, terminator)) != diff --git a/flang/runtime/derived-api.cpp b/flang/runtime/derived-api.cpp --- a/flang/runtime/derived-api.cpp +++ b/flang/runtime/derived-api.cpp @@ -19,7 +19,7 @@ void RTNAME(Initialize)( const Descriptor &descriptor, const char *sourceFile, int sourceLine) { - if (const DescriptorAddendum * addendum{descriptor.Addendum()}) { + if (const DescriptorAddendum *addendum{descriptor.Addendum()}) { if (const auto *derived{addendum->derivedType()}) { if (!derived->noInitializationNeeded()) { Terminator terminator{sourceFile, sourceLine}; @@ -30,7 +30,7 @@ } void RTNAME(Destroy)(const Descriptor &descriptor) { - if (const DescriptorAddendum * addendum{descriptor.Addendum()}) { + if (const DescriptorAddendum *addendum{descriptor.Addendum()}) { if (const auto *derived{addendum->derivedType()}) { if (!derived->noDestructionNeeded()) { // TODO: Pass source file & line information to the API @@ -43,7 +43,7 @@ bool RTNAME(ClassIs)( const Descriptor &descriptor, const typeInfo::DerivedType &derivedType) { - if (const DescriptorAddendum * addendum{descriptor.Addendum()}) { + if (const DescriptorAddendum *addendum{descriptor.Addendum()}) { if (const auto *derived{addendum->derivedType()}) { if (derived == &derivedType) { return true; @@ -80,7 +80,7 @@ } static const typeInfo::DerivedType *GetDerivedType(const Descriptor &desc) { - if (const DescriptorAddendum * addendum{desc.Addendum()}) { + if (const DescriptorAddendum *addendum{desc.Addendum()}) { if (const auto *derived{addendum->derivedType()}) { return derived; } @@ -159,7 +159,7 @@ } void RTNAME(DestroyWithoutFinalization)(const Descriptor &descriptor) { - if (const DescriptorAddendum * addendum{descriptor.Addendum()}) { + if (const DescriptorAddendum *addendum{descriptor.Addendum()}) { if (const auto *derived{addendum->derivedType()}) { if (!derived->noDestructionNeeded()) { Destroy(descriptor, /*finalize=*/false, *derived, nullptr); diff --git a/flang/runtime/derived.cpp b/flang/runtime/derived.cpp --- a/flang/runtime/derived.cpp +++ b/flang/runtime/derived.cpp @@ -37,7 +37,7 @@ if (comp.genre() == typeInfo::Component::Genre::Automatic) { stat = ReturnError(terminator, allocDesc.Allocate(), errMsg, hasStat); if (stat == StatOk) { - if (const DescriptorAddendum * addendum{allocDesc.Addendum()}) { + if (const DescriptorAddendum *addendum{allocDesc.Addendum()}) { if (const auto *derived{addendum->derivedType()}) { if (!derived->noInitializationNeeded()) { stat = Initialize( @@ -211,7 +211,7 @@ *componentDesc.ZeroBasedIndexedElement(k)}; if (comp.genre() == typeInfo::Component::Genre::Allocatable || comp.genre() == typeInfo::Component::Genre::Automatic) { - if (const typeInfo::DerivedType * compType{comp.derivedType()}) { + if (const typeInfo::DerivedType *compType{comp.derivedType()}) { if (!compType->noFinalizationNeeded()) { for (std::size_t j{0}; j < elements; ++j) { const Descriptor &compDesc{*descriptor.OffsetElement( @@ -281,7 +281,7 @@ } bool HasDynamicComponent(const Descriptor &descriptor) { - if (const DescriptorAddendum * addendum{descriptor.Addendum()}) { + if (const DescriptorAddendum *addendum{descriptor.Addendum()}) { if (const auto *derived = addendum->derivedType()) { const Descriptor &componentDesc{derived->component()}; std::size_t myComponents{componentDesc.Elements()}; diff --git a/flang/runtime/descriptor-io.h b/flang/runtime/descriptor-io.h --- a/flang/runtime/descriptor-io.h +++ b/flang/runtime/descriptor-io.h @@ -326,10 +326,10 @@ } } } - if (const typeInfo::SpecialBinding * - special{type->FindSpecialBinding(DIR == Direction::Input - ? typeInfo::SpecialBinding::Which::ReadFormatted - : typeInfo::SpecialBinding::Which::WriteFormatted)}) { + if (const typeInfo::SpecialBinding *special{ + type->FindSpecialBinding(DIR == Direction::Input + ? typeInfo::SpecialBinding::Which::ReadFormatted + : typeInfo::SpecialBinding::Which::WriteFormatted)}) { if (!table || !table->ignoreNonTbpEntries || special->isTypeBound()) { if (std::optional wasDefined{ DefinedFormattedIo(io, descriptor, *type, *special)}) { @@ -349,8 +349,8 @@ const Descriptor &descriptor, const NonTbpDefinedIoTable *table = nullptr) { IoErrorHandler &handler{io.GetIoErrorHandler()}; const DescriptorAddendum *addendum{descriptor.Addendum()}; - if (const typeInfo::DerivedType * - type{addendum ? addendum->derivedType() : nullptr}) { + if (const typeInfo::DerivedType *type{ + addendum ? addendum->derivedType() : nullptr}) { // derived type unformatted I/O if (table) { if (const auto *definedIo{table->Find(*type, @@ -371,10 +371,10 @@ } } } - if (const typeInfo::SpecialBinding * - special{type->FindSpecialBinding(DIR == Direction::Input - ? typeInfo::SpecialBinding::Which::ReadUnformatted - : typeInfo::SpecialBinding::Which::WriteUnformatted)}) { + if (const typeInfo::SpecialBinding *special{ + type->FindSpecialBinding(DIR == Direction::Input + ? typeInfo::SpecialBinding::Which::ReadUnformatted + : typeInfo::SpecialBinding::Which::WriteUnformatted)}) { if (!table || !table->ignoreNonTbpEntries || special->isTypeBound()) { // defined derived type unformatted I/O return DefinedUnformattedIo(io, descriptor, *type, *special); diff --git a/flang/runtime/descriptor.cpp b/flang/runtime/descriptor.cpp --- a/flang/runtime/descriptor.cpp +++ b/flang/runtime/descriptor.cpp @@ -250,7 +250,7 @@ std::fprintf(f, " sm %jd\n", static_cast(raw_.dim[j].sm)); } - if (const DescriptorAddendum * addendum{Addendum()}) { + if (const DescriptorAddendum *addendum{Addendum()}) { addendum->Dump(f); } } diff --git a/flang/runtime/emit-encoded.h b/flang/runtime/emit-encoded.h --- a/flang/runtime/emit-encoded.h +++ b/flang/runtime/emit-encoded.h @@ -25,7 +25,7 @@ connection.internalIoCharKind == 0) { // Stream output: treat newlines as record advancements so that the left tab // limit is correctly managed - while (const CHAR * nl{FindCharacter(data, CHAR{'\n'}, chars)}) { + while (const CHAR *nl{FindCharacter(data, CHAR{'\n'}, chars)}) { auto pos{static_cast(nl - data)}; if (!EmitEncoded(to, data, pos)) { return false; diff --git a/flang/runtime/io-api.cpp b/flang/runtime/io-api.cpp --- a/flang/runtime/io-api.cpp +++ b/flang/runtime/io-api.cpp @@ -170,8 +170,7 @@ static ExternalFileUnit *GetOrCreateUnit(int unitNumber, Direction direction, std::optional isUnformatted, const Terminator &terminator, Cookie &errorCookie) { - if (ExternalFileUnit * - unit{ExternalFileUnit::LookUpOrCreateAnonymous( + if (ExternalFileUnit *unit{ExternalFileUnit::LookUpOrCreateAnonymous( unitNumber, direction, isUnformatted, terminator)}) { errorCookie = nullptr; return unit; @@ -201,7 +200,7 @@ if (*unit->isUnformatted) { iostat = IostatFormattedIoOnUnformattedUnit; } - if (ChildIo * child{unit->GetChildIo()}) { + if (ChildIo *child{unit->GetChildIo()}) { if (iostat == IostatOk) { iostat = child->CheckFormattingAndDirection(false, DIR); } @@ -262,7 +261,7 @@ if (*unit->isUnformatted) { iostat = IostatFormattedIoOnUnformattedUnit; } - if (ChildIo * child{unit->GetChildIo()}) { + if (ChildIo *child{unit->GetChildIo()}) { if (iostat == IostatOk) { iostat = child->CheckFormattingAndDirection(false, DIR); } @@ -320,7 +319,7 @@ if (!*unit->isUnformatted) { iostat = IostatUnformattedIoOnFormattedUnit; } - if (ChildIo * child{unit->GetChildIo()}) { + if (ChildIo *child{unit->GetChildIo()}) { if (iostat == IostatOk) { iostat = child->CheckFormattingAndDirection(true, DIR); } @@ -371,10 +370,9 @@ ExternalUnit unitNumber, const char *sourceFile, int sourceLine) { Terminator terminator{sourceFile, sourceLine}; bool wasExtant{false}; - if (ExternalFileUnit * - unit{ExternalFileUnit::LookUpOrCreate( + if (ExternalFileUnit *unit{ExternalFileUnit::LookUpOrCreate( unitNumber, terminator, wasExtant)}) { - if (ChildIo * child{unit->GetChildIo()}) { + if (ChildIo *child{unit->GetChildIo()}) { return &child->BeginIoStatement( IostatBadOpOnChildUnit, nullptr /* no unit */, sourceFile, sourceLine); @@ -400,7 +398,7 @@ Cookie IONAME(BeginWait)(ExternalUnit unitNumber, AsynchronousId id, const char *sourceFile, int sourceLine) { Terminator terminator{sourceFile, sourceLine}; - if (ExternalFileUnit * unit{ExternalFileUnit::LookUp(unitNumber)}) { + if (ExternalFileUnit *unit{ExternalFileUnit::LookUp(unitNumber)}) { if (unit->Wait(id)) { return &unit->BeginIoStatement(terminator, *unit, ExternalMiscIoStatementState::Wait, sourceFile, sourceLine); @@ -421,14 +419,14 @@ Cookie IONAME(BeginClose)( ExternalUnit unitNumber, const char *sourceFile, int sourceLine) { Terminator terminator{sourceFile, sourceLine}; - if (ExternalFileUnit * unit{ExternalFileUnit::LookUp(unitNumber)}) { - if (ChildIo * child{unit->GetChildIo()}) { + if (ExternalFileUnit *unit{ExternalFileUnit::LookUp(unitNumber)}) { + if (ChildIo *child{unit->GetChildIo()}) { return &child->BeginIoStatement( IostatBadOpOnChildUnit, nullptr /* no unit */, sourceFile, sourceLine); } } - if (ExternalFileUnit * unit{ExternalFileUnit::LookUpForClose(unitNumber)}) { + if (ExternalFileUnit *unit{ExternalFileUnit::LookUpForClose(unitNumber)}) { return &unit->BeginIoStatement( terminator, *unit, sourceFile, sourceLine); } else { @@ -440,8 +438,8 @@ Cookie IONAME(BeginFlush)( ExternalUnit unitNumber, const char *sourceFile, int sourceLine) { Terminator terminator{sourceFile, sourceLine}; - if (ExternalFileUnit * unit{ExternalFileUnit::LookUp(unitNumber)}) { - if (ChildIo * child{unit->GetChildIo()}) { + if (ExternalFileUnit *unit{ExternalFileUnit::LookUp(unitNumber)}) { + if (ChildIo *child{unit->GetChildIo()}) { return &child->BeginIoStatement( *unit, ExternalMiscIoStatementState::Flush, sourceFile, sourceLine); } else { @@ -458,8 +456,8 @@ Cookie IONAME(BeginBackspace)( ExternalUnit unitNumber, const char *sourceFile, int sourceLine) { Terminator terminator{sourceFile, sourceLine}; - if (ExternalFileUnit * unit{ExternalFileUnit::LookUp(unitNumber)}) { - if (ChildIo * child{unit->GetChildIo()}) { + if (ExternalFileUnit *unit{ExternalFileUnit::LookUp(unitNumber)}) { + if (ChildIo *child{unit->GetChildIo()}) { return &child->BeginIoStatement( IostatBadOpOnChildUnit, nullptr /* no unit */, sourceFile, sourceLine); @@ -477,10 +475,9 @@ ExternalUnit unitNumber, const char *sourceFile, int sourceLine) { Terminator terminator{sourceFile, sourceLine}; Cookie errorCookie{nullptr}; - if (ExternalFileUnit * - unit{GetOrCreateUnit(unitNumber, Direction::Output, std::nullopt, - terminator, errorCookie)}) { - if (ChildIo * child{unit->GetChildIo()}) { + if (ExternalFileUnit *unit{GetOrCreateUnit(unitNumber, Direction::Output, + std::nullopt, terminator, errorCookie)}) { + if (ChildIo *child{unit->GetChildIo()}) { return &child->BeginIoStatement( IostatBadOpOnChildUnit, nullptr /* no unit */, sourceFile, sourceLine); @@ -497,10 +494,9 @@ ExternalUnit unitNumber, const char *sourceFile, int sourceLine) { Terminator terminator{sourceFile, sourceLine}; Cookie errorCookie{nullptr}; - if (ExternalFileUnit * - unit{GetOrCreateUnit(unitNumber, Direction::Input, std::nullopt, - terminator, errorCookie)}) { - if (ChildIo * child{unit->GetChildIo()}) { + if (ExternalFileUnit *unit{GetOrCreateUnit(unitNumber, Direction::Input, + std::nullopt, terminator, errorCookie)}) { + if (ChildIo *child{unit->GetChildIo()}) { return &child->BeginIoStatement( IostatBadOpOnChildUnit, nullptr /* no unit */, sourceFile, sourceLine); @@ -516,8 +512,8 @@ Cookie IONAME(BeginInquireUnit)( ExternalUnit unitNumber, const char *sourceFile, int sourceLine) { Terminator terminator{sourceFile, sourceLine}; - if (ExternalFileUnit * unit{ExternalFileUnit::LookUp(unitNumber)}) { - if (ChildIo * child{unit->GetChildIo()}) { + if (ExternalFileUnit *unit{ExternalFileUnit::LookUp(unitNumber)}) { + if (ChildIo *child{unit->GetChildIo()}) { return &child->BeginIoStatement( *unit, sourceFile, sourceLine); } else { @@ -538,11 +534,10 @@ Terminator terminator{sourceFile, sourceLine}; auto trimmed{SaveDefaultCharacter( path, TrimTrailingSpaces(path, pathLength), terminator)}; - if (ExternalFileUnit * - unit{ExternalFileUnit::LookUp( + if (ExternalFileUnit *unit{ExternalFileUnit::LookUp( trimmed.get(), std::strlen(trimmed.get()))}) { // INQUIRE(FILE=) to a connected unit - if (ChildIo * child{unit->GetChildIo()}) { + if (ChildIo *child{unit->GetChildIo()}) { return &child->BeginIoStatement( *unit, sourceFile, sourceLine); } else { diff --git a/flang/runtime/io-stmt.cpp b/flang/runtime/io-stmt.cpp --- a/flang/runtime/io-stmt.cpp +++ b/flang/runtime/io-stmt.cpp @@ -150,16 +150,16 @@ std::size_t formatLength, const Descriptor *formatDescriptor, const char *sourceFile, int sourceLine) : InternalIoStatementState{buffer, length, sourceFile, sourceLine}, - ioStatementState_{*this}, format_{*this, format, formatLength, - formatDescriptor} {} + ioStatementState_{*this}, + format_{*this, format, formatLength, formatDescriptor} {} template InternalFormattedIoStatementState::InternalFormattedIoStatementState( const Descriptor &d, const CharType *format, std::size_t formatLength, const Descriptor *formatDescriptor, const char *sourceFile, int sourceLine) : InternalIoStatementState{d, sourceFile, sourceLine}, - ioStatementState_{*this}, format_{*this, format, formatLength, - formatDescriptor} {} + ioStatementState_{*this}, + format_{*this, format, formatLength, formatDescriptor} {} template void InternalFormattedIoStatementState::CompleteOperation() { @@ -194,7 +194,7 @@ : IoStatementBase{sourceFile, sourceLine}, unit_{unit} {} MutableModes &ExternalIoStatementBase::mutableModes() { - if (const ChildIo * child{unit_.GetChildIo()}) { + if (const ChildIo *child{unit_.GetChildIo()}) { return child->parent().mutableModes(); } return unit_.modes; @@ -314,8 +314,8 @@ template ExternalIoStatementState::ExternalIoStatementState( ExternalFileUnit &unit, const char *sourceFile, int sourceLine) - : ExternalIoStatementBase{unit, sourceFile, sourceLine}, mutableModes_{ - unit.modes} { + : ExternalIoStatementBase{unit, sourceFile, sourceLine}, + mutableModes_{unit.modes} { if constexpr (DIR == Direction::Output) { // If the last statement was a non-advancing IO input statement, the unit // furthestPositionInRecord was not advanced, but the positionInRecord may @@ -879,9 +879,8 @@ ChildIo &child, const CHAR *format, std::size_t formatLength, const Descriptor *formatDescriptor, const char *sourceFile, int sourceLine) : ChildIoStatementState{child, sourceFile, sourceLine}, - mutableModes_{child.parent().mutableModes()}, format_{*this, format, - formatLength, - formatDescriptor} {} + mutableModes_{child.parent().mutableModes()}, + format_{*this, format, formatLength, formatDescriptor} {} template void ChildFormattedIoStatementState::CompleteOperation() { @@ -1316,8 +1315,8 @@ InquireUnconnectedFileState::InquireUnconnectedFileState( OwningPtr &&path, const char *sourceFile, int sourceLine) - : NoUnitIoStatementState{*this, sourceFile, sourceLine}, path_{std::move( - path)} {} + : NoUnitIoStatementState{*this, sourceFile, sourceLine}, + path_{std::move(path)} {} bool InquireUnconnectedFileState::Inquire( InquiryKeywordHash inquiry, char *result, std::size_t length) { diff --git a/flang/runtime/misc-intrinsic.cpp b/flang/runtime/misc-intrinsic.cpp --- a/flang/runtime/misc-intrinsic.cpp +++ b/flang/runtime/misc-intrinsic.cpp @@ -25,7 +25,7 @@ if (resultExtent) { result.GetDimension(0).SetBounds(1, *resultExtent); } - if (const DescriptorAddendum * addendum{mold.Addendum()}) { + if (const DescriptorAddendum *addendum{mold.Addendum()}) { *result.Addendum() = *addendum; } if (int stat{result.Allocate()}) { diff --git a/flang/runtime/namelist.cpp b/flang/runtime/namelist.cpp --- a/flang/runtime/namelist.cpp +++ b/flang/runtime/namelist.cpp @@ -314,10 +314,10 @@ char compName[nameBufferSize]; if (GetLowerCaseName(io, compName, sizeof compName)) { const DescriptorAddendum *addendum{source.Addendum()}; - if (const typeInfo::DerivedType * - type{addendum ? addendum->derivedType() : nullptr}) { - if (const typeInfo::Component * - comp{type->FindDataComponent(compName, std::strlen(compName))}) { + if (const typeInfo::DerivedType *type{ + addendum ? addendum->derivedType() : nullptr}) { + if (const typeInfo::Component *comp{ + type->FindDataComponent(compName, std::strlen(compName))}) { bool createdDesc{false}; if (comp->rank() > 0 && source.rank() > 0) { // If base and component are both arrays, the component name diff --git a/flang/runtime/numeric.cpp b/flang/runtime/numeric.cpp --- a/flang/runtime/numeric.cpp +++ b/flang/runtime/numeric.cpp @@ -270,7 +270,7 @@ BTy result{1}; BTy origBase{base}; while (true) { - if (exp & ETy{1}) { + if (exp &ETy{1}) { result *= base; } exp >>= 1; diff --git a/flang/runtime/pointer.cpp b/flang/runtime/pointer.cpp --- a/flang/runtime/pointer.cpp +++ b/flang/runtime/pointer.cpp @@ -140,7 +140,7 @@ } int stat{ReturnError(terminator, pointer.Allocate(), errMsg, hasStat)}; if (stat == StatOk) { - if (const DescriptorAddendum * addendum{pointer.Addendum()}) { + if (const DescriptorAddendum *addendum{pointer.Addendum()}) { if (const auto *derived{addendum->derivedType()}) { if (!derived->noInitializationNeeded()) { stat = Initialize(pointer, *derived, terminator, hasStat, errMsg); diff --git a/flang/runtime/type-info.cpp b/flang/runtime/type-info.cpp --- a/flang/runtime/type-info.cpp +++ b/flang/runtime/type-info.cpp @@ -54,7 +54,7 @@ std::size_t Component::GetElements(const Descriptor &instance) const { std::size_t elements{1}; if (int rank{rank_}) { - if (const Value * boundValues{bounds()}) { + if (const Value *boundValues{bounds()}) { for (int j{0}; j < rank; ++j) { TypeParameterValue lb{ boundValues[2 * j].GetValue(&instance).value_or(0)}; @@ -103,7 +103,7 @@ descriptor.Establish( kind_, lengthInChars, nullptr, rank_, nullptr, attribute); } else if (cat == TypeCategory::Derived) { - if (const DerivedType * type{derivedType()}) { + if (const DerivedType *type{derivedType()}) { descriptor.Establish(*type, nullptr, rank_, nullptr, attribute); } else { // unlimited polymorphic descriptor.Establish(TypeCode{TypeCategory::Derived, 0}, 0, nullptr, diff --git a/flang/runtime/unit-map.cpp b/flang/runtime/unit-map.cpp --- a/flang/runtime/unit-map.cpp +++ b/flang/runtime/unit-map.cpp @@ -88,13 +88,13 @@ { CriticalSection critical{lock_}; for (int j{0}; j < buckets_; ++j) { - while (Chain * p{bucket_[j].get()}) { + while (Chain *p{bucket_[j].get()}) { bucket_[j].swap(p->next); // pops p from head of bucket list closeList.swap(p->next); // pushes p to closeList } } } - while (Chain * p{closeList.get()}) { + while (Chain *p{closeList.get()}) { closeList.swap(p->next); // pops p from head of closeList p->unit.CloseUnit(CloseStatus::Keep, handler); p->unit.~ExternalFileUnit(); diff --git a/flang/tools/fir-opt/fir-opt.cpp b/flang/tools/fir-opt/fir-opt.cpp --- a/flang/tools/fir-opt/fir-opt.cpp +++ b/flang/tools/fir-opt/fir-opt.cpp @@ -34,6 +34,6 @@ #endif DialectRegistry registry; fir::support::registerDialects(registry); - return failed(MlirOptMain(argc, argv, "FIR modular optimizer driver\n", - registry)); + return failed( + MlirOptMain(argc, argv, "FIR modular optimizer driver\n", registry)); } diff --git a/flang/unittests/Optimizer/InternalNamesTest.cpp b/flang/unittests/Optimizer/InternalNamesTest.cpp --- a/flang/unittests/Optimizer/InternalNamesTest.cpp +++ b/flang/unittests/Optimizer/InternalNamesTest.cpp @@ -20,9 +20,9 @@ DeconstructedName(llvm::ArrayRef modules, llvm::ArrayRef procs, std::int64_t blockId, llvm::StringRef name, llvm::ArrayRef kinds) - : modules{modules.begin(), modules.end()}, procs{procs.begin(), - procs.end()}, - blockId{blockId}, name{name}, kinds{kinds.begin(), kinds.end()} {} + : modules{modules.begin(), modules.end()}, + procs{procs.begin(), procs.end()}, blockId{blockId}, name{name}, + kinds{kinds.begin(), kinds.end()} {} bool isObjEqual(const NameUniquer::DeconstructedName &actualObj) { return actualObj.modules == modules && actualObj.procs == procs && diff --git a/flang/unittests/Runtime/Transformational.cpp b/flang/unittests/Runtime/Transformational.cpp --- a/flang/unittests/Runtime/Transformational.cpp +++ b/flang/unittests/Runtime/Transformational.cpp @@ -26,8 +26,8 @@ std::function; template -constexpr CppTypeFor - besselEpsilon = CppTypeFor(1e-4); +constexpr CppTypeFor besselEpsilon = + CppTypeFor(1e-4); template static void testBesselJn(BesselFuncType rtFunc, int32_t n1, int32_t n2,