aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorAndrzej Warzynski <andrzej.warzynski@arm.com>2021-02-23 17:59:17 +0000
committerAndrzej Warzynski <andrzej.warzynski@arm.com>2021-03-10 12:09:16 +0000
commit523d7bc6f427f9ae32e54dbf1764826cfb269d21 (patch)
tree0b384bb7d6aa24471b1c42e7055180cfffb56fc1 /flang/lib/Frontend/CompilerInvocation.cpp
parenta776942ba1aa0e381dd41a01de4b54fc5dc431cd (diff)
downloadllvm-523d7bc6f427f9ae32e54dbf1764826cfb269d21.zip
llvm-523d7bc6f427f9ae32e54dbf1764826cfb269d21.tar.gz
llvm-523d7bc6f427f9ae32e54dbf1764826cfb269d21.tar.bz2
[flang][driver] Add `-fdebug-dump-parsing-log`
This patch adds `-fdebug-dump-parsing-log` in the new driver. This option is semantically identical to `-fdebug-instrumented-parse` in `f18` (the former is added as an alias in `f18`). As dumping the parsing log makes only sense for instrumented parses, we set Fortran::parser::Options::instrumentedParse to `True` when `-fdebug-dump-parsing-log` is used. This is consistent with `f18`. To facilitate tweaking the configuration of the frontend based on the action being requested, `setUpFrontendBasedOnAction` is introduced in CompilerInvocation.cpp. Differential Revision: https://reviews.llvm.org/D97457
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 0dc7e7c..1764970 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -85,6 +85,15 @@ bool Fortran::frontend::ParseDiagnosticArgs(clang::DiagnosticOptions &opts,
return true;
}
+// 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;
+}
+
static InputKind ParseFrontendArgs(FrontendOptions &opts,
llvm::opt::ArgList &args, clang::DiagnosticsEngine &diags) {
@@ -125,6 +134,9 @@ static InputKind ParseFrontendArgs(FrontendOptions &opts,
case clang::driver::options::OPT_fdebug_dump_provenance:
opts.programAction_ = DebugDumpProvenance;
break;
+ case clang::driver::options::OPT_fdebug_dump_parsing_log:
+ opts.programAction_ = DebugDumpParsingLog;
+ break;
case clang::driver::options::OPT_fdebug_measure_parse_tree:
opts.programAction_ = DebugMeasureParseTree;
break;
@@ -264,6 +276,9 @@ static InputKind ParseFrontendArgs(FrontendOptions &opts,
<< arg->getAsString(args) << argValue;
}
}
+
+ setUpFrontendBasedOnAction(opts);
+
return dashX;
}
@@ -484,6 +499,9 @@ void CompilerInvocation::setFortranOpts() {
// directories
if (moduleDirJ.compare(".") != 0)
fortranOptions.searchDirectories.emplace_back(moduleDirJ);
+
+ if (frontendOptions.instrumentedParse_)
+ fortranOptions.instrumentedParse = true;
}
void CompilerInvocation::setSemanticsOpts(