diff options
author | Andrzej Warzynski <andrzej.warzynski@arm.com> | 2022-04-22 10:59:31 +0000 |
---|---|---|
committer | Andrzej Warzynski <andrzej.warzynski@arm.com> | 2022-04-27 09:20:07 +0000 |
commit | d902dd011c9403ff746613a73c5d83e13db93fe5 (patch) | |
tree | f06adf69e5971b9d63ca383c08a49087a211885c /flang/lib/FrontendTool | |
parent | ca3cd345a0d0046ef15e6806494099b017cb1b31 (diff) | |
download | llvm-d902dd011c9403ff746613a73c5d83e13db93fe5.zip llvm-d902dd011c9403ff746613a73c5d83e13db93fe5.tar.gz llvm-d902dd011c9403ff746613a73c5d83e13db93fe5.tar.bz2 |
[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
Diffstat (limited to 'flang/lib/FrontendTool')
-rw-r--r-- | flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index bc2bf1d..8f5b313 100644 --- a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -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) { |