[flang] Add -fdebug-dump-parse-tree and -fdebug-resolve-names
"f18 -fdebug-resolve-names -fparse-only ..." is equivalent to what test-type used to do, so the test-type executable can be eliminated. -fdebug-dump-parse-tree does the parse-tree dumping that test-sema does, but test-sema does more so I have left it alone. Original-commit: flang-compiler/f18@8b3816528e Reviewed-on: https://github.com/flang-compiler/f18/pull/55
This commit is contained in:
parent
632855d02a
commit
c9d838e8a7
|
@ -111,6 +111,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
bool Pre(const parser::Name &x) { return Pre(x.ToString()); }
|
||||
|
||||
bool Pre(const std::string &x) {
|
||||
if (emptyline ) {
|
||||
out_indent();
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "resolve-names.h"
|
||||
#include "attr.h"
|
||||
#include "scope.h"
|
||||
#include "symbol.h"
|
||||
|
|
10
flang/lib/semantics/resolve-names.h
Normal file
10
flang/lib/semantics/resolve-names.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#include <iosfwd>
|
||||
|
||||
namespace Fortran::parser {
|
||||
class Program;
|
||||
class CookedSource;
|
||||
} // namespace Fortran::parser
|
||||
|
||||
namespace Fortran::semantics {
|
||||
void ResolveNames(const parser::Program &, const parser::CookedSource &);
|
||||
} // namespace Fortran::semantics
|
|
@ -5,19 +5,9 @@ add_executable( f18
|
|||
f18.cc
|
||||
)
|
||||
target_link_libraries( f18
|
||||
FortranParser
|
||||
)
|
||||
|
||||
######## test-type ##########
|
||||
|
||||
add_executable( test-type
|
||||
test-type.cc
|
||||
)
|
||||
|
||||
target_link_libraries( test-type
|
||||
FortranParser
|
||||
FlangSemantics
|
||||
)
|
||||
)
|
||||
|
||||
######## test-sema ##########
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "../../lib/parser/parsing.h"
|
||||
#include "../../lib/parser/provenance.h"
|
||||
#include "../../lib/parser/unparse.h"
|
||||
#include "../../lib/semantics/ParseTreeDump.h"
|
||||
#include "../../lib/semantics/resolve-names.h"
|
||||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
@ -68,6 +70,8 @@ struct DriverOptions {
|
|||
bool dumpProvenance{false};
|
||||
bool dumpCookedChars{false};
|
||||
bool dumpUnparse{false};
|
||||
bool dumpParseTree{false};
|
||||
bool debugResolveNames{false};
|
||||
bool measureTree{false};
|
||||
std::vector<std::string> pgf90Args;
|
||||
const char *prefix{nullptr};
|
||||
|
@ -172,6 +176,13 @@ std::string CompileFortran(std::string path, Fortran::parser::Options options,
|
|||
if (driver.measureTree) {
|
||||
MeasureParseTree(*parsing.parseTree());
|
||||
}
|
||||
if (driver.debugResolveNames) {
|
||||
Fortran::semantics::ResolveNames(
|
||||
*parsing.parseTree(), parsing.messages().cooked());
|
||||
}
|
||||
if (driver.dumpParseTree) {
|
||||
Fortran::parser::DumpTree(*parsing.parseTree());
|
||||
}
|
||||
if (driver.dumpUnparse) {
|
||||
Unparse(std::cout, *parsing.parseTree(), driver.encoding,
|
||||
true /*capitalize*/);
|
||||
|
@ -306,6 +317,10 @@ int main(int argc, char *const argv[]) {
|
|||
driver.dumpCookedChars = true;
|
||||
} else if (arg == "-fdebug-dump-provenance") {
|
||||
driver.dumpProvenance = true;
|
||||
} else if (arg == "-fdebug-dump-parse-tree") {
|
||||
driver.dumpParseTree = true;
|
||||
} else if (arg == "-fdebug-resolve-names") {
|
||||
driver.debugResolveNames = true;
|
||||
} else if (arg == "-fdebug-measure-parse-tree") {
|
||||
driver.measureTree = true;
|
||||
} else if (arg == "-funparse") {
|
||||
|
@ -341,6 +356,8 @@ int main(int argc, char *const argv[]) {
|
|||
<< " -funparse parse & reformat only, no code generation\n"
|
||||
<< " -fdebug-measure-parse-tree\n"
|
||||
<< " -fdebug-dump-provenance\n"
|
||||
<< " -fdebug-dump-parse-tree\n"
|
||||
<< " -fdebug-resolve-names\n"
|
||||
<< " -v -c -o -I -D -U have their usual meanings\n"
|
||||
<< " -help print this again\n"
|
||||
<< "Other options are passed through to the compiler.\n";
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
#include "../../lib/parser/parsing.h"
|
||||
#include "../../lib/semantics/make-types.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using namespace Fortran;
|
||||
using namespace parser;
|
||||
|
||||
int main(int argc, char *const argv[]) {
|
||||
if (argc != 2) {
|
||||
std::cerr << "Expected 1 source file, got " << (argc - 1) << "\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
std::string path{argv[1]};
|
||||
parser::Parsing parsing;
|
||||
if (parsing.ForTesting(path, std::cerr)) {
|
||||
semantics::MakeTypes(*parsing.parseTree(), parsing.messages().cooked());
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
return EXIT_FAILURE;
|
||||
}
|
Loading…
Reference in a new issue