diff --git a/flang/include/flang/Evaluate/expression.h b/flang/include/flang/Evaluate/expression.h --- a/flang/include/flang/Evaluate/expression.h +++ b/flang/include/flang/Evaluate/expression.h @@ -749,7 +749,7 @@ public: using Result = SomeKind; EVALUATE_UNION_CLASS_BOILERPLATE(Expr) - int GetKind() const; + int kind() const; common::MapTemplate> u; }; @@ -757,7 +757,7 @@ public: using Result = SomeCharacter; EVALUATE_UNION_CLASS_BOILERPLATE(Expr) - int GetKind() const; + int kind() const; std::optional> LEN() const; common::MapTemplate> u; }; diff --git a/flang/include/flang/Frontend/CompilerInstance.h b/flang/include/flang/Frontend/CompilerInstance.h --- a/flang/include/flang/Frontend/CompilerInstance.h +++ b/flang/include/flang/Frontend/CompilerInstance.h @@ -58,7 +58,7 @@ /// @name Compiler Invocation /// { - CompilerInvocation &GetInvocation() { + CompilerInvocation &invocation() { assert(invocation_ && "Compiler instance has no invocation!"); return *invocation_; }; @@ -71,7 +71,7 @@ /// { /// Return the current allSources. - Fortran::parser::AllSources &GetAllSources() const { return *allSources_; } + Fortran::parser::AllSources &allSources() const { return *allSources_; } bool HasAllSources() const { return allSources_ != nullptr; } @@ -96,9 +96,9 @@ return invocation_->GetDiagnosticOpts(); } - FrontendOptions &GetFrontendOpts() { return invocation_->GetFrontendOpts(); } - const FrontendOptions &GetFrontendOpts() const { - return invocation_->GetFrontendOpts(); + FrontendOptions &frontendOpts() { return invocation_->frontendOpts(); } + const FrontendOptions &frontendOpts() const { + return invocation_->frontendOpts(); } /// } diff --git a/flang/include/flang/Frontend/CompilerInvocation.h b/flang/include/flang/Frontend/CompilerInvocation.h --- a/flang/include/flang/Frontend/CompilerInvocation.h +++ b/flang/include/flang/Frontend/CompilerInvocation.h @@ -46,8 +46,8 @@ public: CompilerInvocation() = default; - FrontendOptions &GetFrontendOpts() { return frontendOpts_; } - const FrontendOptions &GetFrontendOpts() const { return frontendOpts_; } + FrontendOptions &frontendOpts() { return frontendOpts_; } + const FrontendOptions &frontendOpts() const { return frontendOpts_; } /// Create a compiler invocation from a list of input options. /// \returns true on success. diff --git a/flang/include/flang/Frontend/FrontendAction.h b/flang/include/flang/Frontend/FrontendAction.h --- a/flang/include/flang/Frontend/FrontendAction.h +++ b/flang/include/flang/Frontend/FrontendAction.h @@ -48,31 +48,31 @@ /// @name Compiler Instance Access /// @{ - CompilerInstance &GetCompilerInstance() const { + CompilerInstance &instance() const { assert(instance_ && "Compiler instance not registered!"); return *instance_; } - void SetCompilerInstance(CompilerInstance *value) { instance_ = value; } + void set_instance(CompilerInstance *value) { instance_ = value; } /// @} /// @name Current File Information /// @{ - const FrontendInputFile &GetCurrentInput() const { return currentInput_; } + const FrontendInputFile ¤tInput() const { return currentInput_; } llvm::StringRef GetCurrentFile() const { assert(!currentInput_.IsEmpty() && "No current file!"); - return currentInput_.GetFile(); + return currentInput_.file(); } llvm::StringRef GetCurrentFileOrBufferName() const { assert(!currentInput_.IsEmpty() && "No current file!"); return currentInput_.IsFile() - ? currentInput_.GetFile() - : currentInput_.GetBuffer()->getBufferIdentifier(); + ? currentInput_.file() + : currentInput_.buffer()->getBufferIdentifier(); } - void SetCurrentInput(const FrontendInputFile ¤tInput); + void set_currentInput(const FrontendInputFile ¤tInput); /// @} /// @name Public Action Interface diff --git a/flang/include/flang/Frontend/FrontendOptions.h b/flang/include/flang/Frontend/FrontendOptions.h --- a/flang/include/flang/Frontend/FrontendOptions.h +++ b/flang/include/flang/Frontend/FrontendOptions.h @@ -91,18 +91,18 @@ FrontendInputFile(const llvm::MemoryBuffer *buffer, InputKind kind) : buffer_(buffer), kind_(kind) {} - InputKind GetKind() const { return kind_; } + InputKind kind() const { return kind_; } bool IsEmpty() const { return file_.empty() && buffer_ == nullptr; } bool IsFile() const { return !IsBuffer(); } bool IsBuffer() const { return buffer_ != nullptr; } - llvm::StringRef GetFile() const { + llvm::StringRef file() const { assert(IsFile()); return file_; } - const llvm::MemoryBuffer *GetBuffer() const { + const llvm::MemoryBuffer *buffer() const { assert(IsBuffer() && "Requested buffer_, but it is empty!"); return buffer_; } 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 @@ -298,13 +298,13 @@ delete p; } -template int Expr>::GetKind() const { +template int Expr>::kind() const { return std::visit( [](const auto &kx) { return std::decay_t::Result::kind; }, u); } -int Expr::GetKind() const { +int Expr::kind() const { return std::visit( [](const auto &kx) { return std::decay_t::Result::kind; }, u); diff --git a/flang/lib/Frontend/CompilerInstance.cpp b/flang/lib/Frontend/CompilerInstance.cpp --- a/flang/lib/Frontend/CompilerInstance.cpp +++ b/flang/lib/Frontend/CompilerInstance.cpp @@ -69,7 +69,7 @@ // Get the path of the output file std::string outputFilePath = - GetOutputFilePath(GetFrontendOpts().outputFile_, baseName, extension); + GetOutputFilePath(frontendOpts().outputFile_, baseName, extension); // Create the output file std::unique_ptr os = @@ -120,7 +120,7 @@ bool CompilerInstance::ExecuteAction(FrontendAction &act) { // Connect Input to a CompileInstance - for (const FrontendInputFile &fif : GetFrontendOpts().inputs_) { + for (const FrontendInputFile &fif : frontendOpts().inputs_) { if (act.BeginSourceFile(*this, fif)) { if (llvm::Error err = act.Execute()) { consumeError(std::move(err)); 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 @@ -176,7 +176,7 @@ } // Parse the frontend args - ParseFrontendArgs(res.GetFrontendOpts(), args, diags); + ParseFrontendArgs(res.frontendOpts(), args, diags); return success; } diff --git a/flang/lib/Frontend/FrontendAction.cpp b/flang/lib/Frontend/FrontendAction.cpp --- a/flang/lib/Frontend/FrontendAction.cpp +++ b/flang/lib/Frontend/FrontendAction.cpp @@ -13,7 +13,7 @@ using namespace Fortran::frontend; -void FrontendAction::SetCurrentInput(const FrontendInputFile ¤tInput) { +void FrontendAction::set_currentInput(const FrontendInputFile ¤tInput) { this->currentInput_ = currentInput; } @@ -21,8 +21,8 @@ // Deallocate compiler instance, input and output descriptors static void BeginSourceFileCleanUp(FrontendAction &fa, CompilerInstance &ci) { ci.ClearOutputFiles(/*EraseFiles=*/true); - fa.SetCurrentInput(FrontendInputFile()); - fa.SetCompilerInstance(nullptr); + fa.set_currentInput(FrontendInputFile()); + fa.set_instance(nullptr); } bool FrontendAction::BeginSourceFile( @@ -31,8 +31,8 @@ FrontendInputFile input(realInput); assert(!instance_ && "Already processing a source file!"); assert(!realInput.IsEmpty() && "Unexpected empty filename!"); - SetCurrentInput(realInput); - SetCompilerInstance(&ci); + set_currentInput(realInput); + set_instance(&ci); if (!ci.HasAllSources()) { BeginSourceFileCleanUp(*this, ci); return false; @@ -41,7 +41,7 @@ } bool FrontendAction::ShouldEraseOutputFiles() { - return GetCompilerInstance().getDiagnostics().hasErrorOccurred(); + return instance().getDiagnostics().hasErrorOccurred(); } llvm::Error FrontendAction::Execute() { @@ -50,12 +50,12 @@ } void FrontendAction::EndSourceFile() { - CompilerInstance &ci = GetCompilerInstance(); + CompilerInstance &ci = instance(); // Cleanup the output streams, and erase the output files if instructed by the // FrontendAction. ci.ClearOutputFiles(/*EraseFiles=*/ShouldEraseOutputFiles()); - SetCompilerInstance(nullptr); - SetCurrentInput(FrontendInputFile()); + set_instance(nullptr); + set_currentInput(FrontendInputFile()); } 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 @@ -23,8 +23,8 @@ bool binaryMode = true; // Set/store input file info into CompilerInstance. - CompilerInstance &ci = GetCompilerInstance(); - Fortran::parser::AllSources &allSources{ci.GetAllSources()}; + CompilerInstance &ci = instance(); + Fortran::parser::AllSources &allSources{ci.allSources()}; const Fortran::parser::SourceFile *sf; sf = allSources.Open(path, error_stream); llvm::ArrayRef fileContent = sf->content(); diff --git a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp --- a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -24,7 +24,7 @@ static std::unique_ptr CreateFrontendBaseAction( CompilerInstance &ci) { - ActionKind ak = ci.GetFrontendOpts().programAction_; + ActionKind ak = ci.frontendOpts().programAction_; switch (ak) { case InputOutputTest: return std::make_unique(); @@ -52,7 +52,7 @@ } bool ExecuteCompilerInvocation(CompilerInstance *flang) { // Honor -help. - if (flang->GetFrontendOpts().showHelp_) { + if (flang->frontendOpts().showHelp_) { clang::driver::getDriverOptTable().PrintHelp(llvm::outs(), "flang-new -fc1 [options] file...", "LLVM 'Flang' Compiler", /*Include=*/clang::driver::options::FC1Option, @@ -62,7 +62,7 @@ } // Honor -version. - if (flang->GetFrontendOpts().showVersion_) { + if (flang->frontendOpts().showVersion_) { llvm::cl::PrintVersionMessage(); return true; } diff --git a/flang/lib/Semantics/program-tree.h b/flang/lib/Semantics/program-tree.h --- a/flang/lib/Semantics/program-tree.h +++ b/flang/lib/Semantics/program-tree.h @@ -56,7 +56,7 @@ : name_{name}, spec_{spec}, exec_{exec} {} const parser::Name &name() const { return name_; } - Kind GetKind() const; + Kind kind() const; const Stmt &stmt() const { return stmt_; } bool isSpecificationPartResolved() const { return isSpecificationPartResolved_; diff --git a/flang/lib/Semantics/program-tree.cpp b/flang/lib/Semantics/program-tree.cpp --- a/flang/lib/Semantics/program-tree.cpp +++ b/flang/lib/Semantics/program-tree.cpp @@ -123,12 +123,12 @@ } bool ProgramTree::IsModule() const { - auto kind{GetKind()}; + auto kind{kind()}; return kind == Kind::Module || kind == Kind::Submodule; } Symbol::Flag ProgramTree::GetSubpFlag() const { - return GetKind() == Kind::Function ? Symbol::Flag::Function + return kind() == Kind::Function ? Symbol::Flag::Function : Symbol::Flag::Subroutine; } @@ -155,7 +155,7 @@ return false; } -ProgramTree::Kind ProgramTree::GetKind() const { +ProgramTree::Kind ProgramTree::kind() const { return std::visit( common::visitors{ [](const parser::Statement *) { 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 @@ -371,7 +371,7 @@ DeclTypeSpec::Category GetDeclTypeSpecCategory() const { return state_.derived.category; } - KindExpr GetKindParamExpr( + KindExpr kindParamExpr( TypeCategory, const std::optional &); void CheckForAbstractType(const Symbol &typeSymbol); @@ -1676,7 +1676,7 @@ state_.declTypeSpec = &declTypeSpec; } -KindExpr DeclTypeSpecVisitor::GetKindParamExpr( +KindExpr DeclTypeSpecVisitor::kindParamExpr( TypeCategory category, const std::optional &kind) { return AnalyzeKindSelector(context(), category, kind); } @@ -2176,7 +2176,7 @@ const DeclTypeSpec &ScopeHandler::MakeNumericType( TypeCategory category, const std::optional &kind) { - KindExpr value{GetKindParamExpr(category, kind)}; + KindExpr value{kindParamExpr(category, kind)}; if (auto known{evaluate::ToInt64(value)}) { return context().MakeNumericType(category, static_cast(*known)); } else { @@ -2186,7 +2186,7 @@ const DeclTypeSpec &ScopeHandler::MakeLogicalType( const std::optional &kind) { - KindExpr value{GetKindParamExpr(TypeCategory::Logical, kind)}; + KindExpr value{kindParamExpr(TypeCategory::Logical, kind)}; if (auto known{evaluate::ToInt64(value)}) { return context().MakeLogicalType(static_cast(*known)); } else { @@ -6367,7 +6367,7 @@ // Push a new scope for this node or return false on error. bool ResolveNamesVisitor::BeginScopeForNode(const ProgramTree &node) { - switch (node.GetKind()) { + switch (node.kind()) { SWITCH_COVERS_ALL_CASES case ProgramTree::Kind::Program: PushScope(Scope::Kind::MainProgram, diff --git a/flang/tools/flang-driver/fc1_main.cpp b/flang/tools/flang-driver/fc1_main.cpp --- a/flang/tools/flang-driver/fc1_main.cpp +++ b/flang/tools/flang-driver/fc1_main.cpp @@ -46,7 +46,7 @@ new clang::DiagnosticOptions(); clang::DiagnosticsEngine diags(diagID, &*diagOpts, diagsBuffer); bool success = - CompilerInvocation::CreateFromArgs(flang->GetInvocation(), argv, diags); + CompilerInvocation::CreateFromArgs(flang->invocation(), argv, diags); diagsBuffer->FlushDiagnostics(flang->getDiagnostics()); diff --git a/flang/unittests/Frontend/CompilerInstanceTest.cpp b/flang/unittests/Frontend/CompilerInstanceTest.cpp --- a/flang/unittests/Frontend/CompilerInstanceTest.cpp +++ b/flang/unittests/Frontend/CompilerInstanceTest.cpp @@ -47,7 +47,7 @@ llvm::raw_string_ostream error_stream{buf}; CompilerInstance compInst; const Fortran::parser::SourceFile *sf = - compInst.GetAllSources().Open(testFilePath, error_stream); + compInst.allSources().Open(testFilePath, error_stream); // 3. Verify the content of the input file // This is just a sanity check to make sure that CompilerInstance is capable diff --git a/flang/unittests/Frontend/InputOutputTest.cpp b/flang/unittests/Frontend/InputOutputTest.cpp --- a/flang/unittests/Frontend/InputOutputTest.cpp +++ b/flang/unittests/Frontend/InputOutputTest.cpp @@ -45,9 +45,9 @@ CompilerInstance compInst; compInst.CreateDiagnostics(); auto invocation = std::make_shared(); - invocation->GetFrontendOpts().programAction_ = InputOutputTest; + invocation->frontendOpts().programAction_ = InputOutputTest; compInst.SetInvocation(std::move(invocation)); - compInst.GetFrontendOpts().inputs_.push_back( + compInst.frontendOpts().inputs_.push_back( FrontendInputFile(/*File=*/testFilePath, Language::Fortran)); // 3. Set-up the output stream. Using output buffer wrapped as an output