forked from OSchip/llvm-project
[flang][driver] NFC: Make code more in line with LLVM style
This patch basically implements [1] in ExecuteCompilerInvocation.cpp. It also: * replaces `CreateFrontendBaseAction` with `CreateFrontendAction` (only one method is needed ATM, this change removes the extra indirection) * removes `InvalidAction` from the `ActionKind` enum (I don't think it adds much and keeping it would mean adding a new void case in `CreateFrontendAction`) * sets the default frontend action in FrontendOptions.h to `ParseSyntaxOnly` (note that this is still overridden independently in `ParseFrontendArg` in CompilerInvocation.cpp) No new functionality is added, hence no tests. [1] https://llvm.org/docs/CodingStandards.html#don-t-use-default-labels-in-fully-covered-switches-over-enumerations Differential Revision: https://reviews.llvm.org/D124245
This commit is contained in:
parent
ca3cd345a0
commit
d902dd011c
|
@ -20,8 +20,6 @@
|
|||
namespace Fortran::frontend {
|
||||
|
||||
enum ActionKind {
|
||||
InvalidAction = 0,
|
||||
|
||||
/// -test-io mode
|
||||
InputOutputTest,
|
||||
|
||||
|
@ -244,7 +242,7 @@ struct FrontendOptions {
|
|||
std::string outputFile;
|
||||
|
||||
/// The frontend action to perform.
|
||||
frontend::ActionKind programAction;
|
||||
frontend::ActionKind programAction = ParseSyntaxOnly;
|
||||
|
||||
// The form to process files in, if specified.
|
||||
FortranForm fortranForm = FortranForm::Unknown;
|
||||
|
|
|
@ -17,13 +17,6 @@
|
|||
namespace Fortran::frontend {
|
||||
|
||||
class CompilerInstance;
|
||||
class FrontendAction;
|
||||
|
||||
/// Construct the FrontendAction of a compiler invocation based on the
|
||||
/// options specified for the compiler invocation.
|
||||
///
|
||||
/// \return - The created FrontendAction object
|
||||
std::unique_ptr<FrontendAction> CreateFrontendAction(CompilerInstance &ci);
|
||||
|
||||
/// ExecuteCompilerInvocation - Execute the given actions described by the
|
||||
/// compiler invocation object in the given compiler instance.
|
||||
|
|
|
@ -98,9 +98,6 @@ static void ParseTargetArgs(TargetOptions &opts, llvm::opt::ArgList &args) {
|
|||
|
||||
// Tweak the frontend configuration based on the frontend action
|
||||
static void setUpFrontendBasedOnAction(FrontendOptions &opts) {
|
||||
assert(opts.programAction != Fortran::frontend::InvalidAction &&
|
||||
"Fortran frontend action not set!");
|
||||
|
||||
if (opts.programAction == DebugDumpParsingLog)
|
||||
opts.instrumentedParse = true;
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "flang/Frontend/FrontendActions.h"
|
||||
#include "flang/Frontend/FrontendOptions.h"
|
||||
#include "flang/Frontend/FrontendPluginRegistry.h"
|
||||
#include "flang/FrontendTool/Utils.h"
|
||||
#include "clang/Basic/DiagnosticFrontend.h"
|
||||
#include "llvm/Support/Errc.h"
|
||||
#include "llvm/Support/VirtualFileSystem.h"
|
||||
|
|
|
@ -24,11 +24,10 @@
|
|||
|
||||
namespace Fortran::frontend {
|
||||
|
||||
static std::unique_ptr<FrontendAction> CreateFrontendBaseAction(
|
||||
static std::unique_ptr<FrontendAction> CreateFrontendAction(
|
||||
CompilerInstance &ci) {
|
||||
|
||||
ActionKind ak = ci.frontendOpts().programAction;
|
||||
switch (ak) {
|
||||
switch (ci.frontendOpts().programAction) {
|
||||
case InputOutputTest:
|
||||
return std::make_unique<InputOutputTestAction>();
|
||||
case PrintPreprocessedInput:
|
||||
|
@ -90,25 +89,9 @@ static std::unique_ptr<FrontendAction> CreateFrontendBaseAction(
|
|||
ci.diagnostics().Report(diagID) << ci.frontendOpts().ActionName;
|
||||
return nullptr;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
// TODO:
|
||||
// case ParserSyntaxOnly:
|
||||
// case EmitLLVM:
|
||||
// case EmitLLVMOnly:
|
||||
// case EmitCodeGenOnly:
|
||||
// (...)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::unique_ptr<FrontendAction> CreateFrontendAction(CompilerInstance &ci) {
|
||||
// Create the underlying action.
|
||||
std::unique_ptr<FrontendAction> act = CreateFrontendBaseAction(ci);
|
||||
if (!act)
|
||||
return nullptr;
|
||||
|
||||
return act;
|
||||
llvm_unreachable("Invalid program action!");
|
||||
}
|
||||
|
||||
bool ExecuteCompilerInvocation(CompilerInstance *flang) {
|
||||
|
|
Loading…
Reference in New Issue