[flang][driver] Fine-tune `-fdebug-dump-symbols`

When generating output for `-fdebug-dump-symbols`, make sure that
BuildRuntimeDerivedTypeTables is also run. This change is needed in
order to make the implementation of `-fdebug-dump-symbols` in
`flang-new` consistent with `f18`. It also allows us to port more tests
to use the new driver whenever it is enabled.

Differential Revision: https://reviews.llvm.org/D100649
This commit is contained in:
Andrzej Warzynski 2021-04-16 14:07:09 +00:00
parent 3c9bcf0e35
commit 499f1ed548
2 changed files with 18 additions and 5 deletions

View File

@ -50,7 +50,6 @@ bool PrescanAction::BeginSourceFileAction(CompilerInstance &c1) {
std::string currentInputPath{GetCurrentFileOrBufferName()}; std::string currentInputPath{GetCurrentFileOrBufferName()};
Fortran::parser::Options parserOptions = ci.invocation().fortranOpts(); Fortran::parser::Options parserOptions = ci.invocation().fortranOpts();
// Prescan. In case of failure, report and return. // Prescan. In case of failure, report and return.
ci.parsing().Prescan(currentInputPath, parserOptions); ci.parsing().Prescan(currentInputPath, parserOptions);
@ -283,13 +282,27 @@ void DebugUnparseWithSymbolsAction::ExecuteAction() {
} }
void DebugDumpSymbolsAction::ExecuteAction() { void DebugDumpSymbolsAction::ExecuteAction() {
CompilerInstance &ci = this->instance();
auto &semantics = this->semantics(); auto &semantics = this->semantics();
auto tables{Fortran::semantics::BuildRuntimeDerivedTypeTables(
instance().invocation().semanticsContext())};
// The runtime derived type information table builder may find and report
// semantic errors. So it is important that we report them _after_
// BuildRuntimeDerivedTypeTables is run.
reportFatalSemanticErrors(
semantics, this->instance().diagnostics(), GetCurrentFileOrBufferName());
if (!tables.schemata) {
unsigned DiagID =
ci.diagnostics().getCustomDiagID(clang::DiagnosticsEngine::Error,
"could not find module file for __fortran_type_info");
ci.diagnostics().Report(DiagID);
llvm::errs() << "\n";
}
// Dump symbols // Dump symbols
semantics.DumpSymbols(llvm::outs()); semantics.DumpSymbols(llvm::outs());
// Report fatal semantic errors
reportFatalSemanticErrors(
semantics, this->instance().diagnostics(), GetCurrentFileOrBufferName());
} }
void DebugDumpParseTreeNoSemaAction::ExecuteAction() { void DebugDumpParseTreeNoSemaAction::ExecuteAction() {

View File

@ -1,4 +1,4 @@
!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s !RUN: %flang_fc1 -fdebug-dump-symbols %s | FileCheck %s
! Tests for derived type runtime descriptions ! Tests for derived type runtime descriptions
module m01 module m01