diff options
author | Andrzej Warzynski <andrzej.warzynski@arm.com> | 2021-02-02 09:07:33 +0000 |
---|---|---|
committer | Andrzej Warzynski <andrzej.warzynski@arm.com> | 2021-02-02 10:03:45 +0000 |
commit | 760e6c4ce58324856d8f105b37bb974564e0f170 (patch) | |
tree | 6f3cd38402f9a64e21f32a9168a1ee2f278f7048 /flang/lib/Frontend/CompilerInvocation.cpp | |
parent | d4d4ceeb8f3be67be94781ed718ceb103213df74 (diff) | |
download | llvm-760e6c4ce58324856d8f105b37bb974564e0f170.zip llvm-760e6c4ce58324856d8f105b37bb974564e0f170.tar.gz llvm-760e6c4ce58324856d8f105b37bb974564e0f170.tar.bz2 |
[flang][driver] Disallow non-existent input files in the frontend driver
This patch adds a check that verifies that the input file used when
calling the frontend driver (i.e. `flang-new -fc1`) actually exists.
This was not required for the compiler driver, `flang-new`, as that's
already handled in libclangDriver.
Once all input/output file management is moved to the driver, we should
also check that for input from `stdin` the corresponding file descriptor
was successfully acquired.
This patch also makes sure that the default action in the frontend is
`ParseSyntaxOnly`. This is consistent with Clang. Before this change
`flang-new -fc1` would do nothing, which makes testing changes like the
one introduced here a bit tricky.
Reviewed By: SouraVX
Differential Revision: https://reviews.llvm.org/D95127
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | flang/lib/Frontend/CompilerInvocation.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index b34b47a..5077d06 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -84,6 +84,10 @@ bool Fortran::frontend::ParseDiagnosticArgs(clang::DiagnosticOptions &opts, static InputKind ParseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args, clang::DiagnosticsEngine &diags) { + + // By default the frontend driver creates a ParseSyntaxOnly action. + opts.programAction_ = ParseSyntaxOnly; + // Identify the action (i.e. opts.ProgramAction) if (const llvm::opt::Arg *a = args.getLastArg(clang::driver::options::OPT_Action_Group)) { |