Skip to content

Commit bbfbc0e

Browse files
committed
[flang] Fix ParserActions style & formatting
1 parent 1dab2b9 commit bbfbc0e

File tree

7 files changed

+53
-55
lines changed

7 files changed

+53
-55
lines changed

flang/include/flang/Frontend/CompilerInstance.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
#include "flang/Frontend/CompilerInvocation.h"
1717
#include "flang/Frontend/FrontendAction.h"
18-
#include "flang/Frontend/PreprocessorOptions.h"
1918
#include "flang/Frontend/ParserActions.h"
19+
#include "flang/Frontend/PreprocessorOptions.h"
2020
#include "flang/Semantics/runtime-type-info.h"
2121
#include "flang/Semantics/semantics.h"
2222
#include "flang/Support/StringOstream.h"

flang/include/flang/Frontend/ParserActions.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,42 @@
1616
#include <string>
1717

1818
namespace llvm {
19-
class raw_string_ostream;
20-
class raw_ostream;
21-
class StringRef;
19+
class raw_string_ostream;
20+
class raw_ostream;
21+
class StringRef;
2222
} // namespace llvm
2323

2424
namespace Fortran::lower {
25-
class LoweringBridge;
25+
class LoweringBridge;
2626
} // namespace Fortran::lower
2727

2828
namespace Fortran::parser {
29-
class Parsing;
30-
class AllCookedSources;
29+
class Parsing;
30+
class AllCookedSources;
3131
} // namespace Fortran::parser
3232

3333
namespace lower::pft {
34-
class Program;
34+
class Program;
3535
} // namespace lower::pft
3636

3737
//=== Frontend Parser helpers ===
3838

3939
namespace Fortran::frontend {
4040
class CompilerInstance;
4141

42-
Fortran::parser::AllCookedSources& getAllCooked(CompilerInstance &ci);
42+
parser::AllCookedSources &getAllCooked(CompilerInstance &ci);
4343

44-
void parseAndLowerTree(CompilerInstance &ci, Fortran::lower::LoweringBridge &lb);
44+
void parseAndLowerTree(CompilerInstance &ci, lower::LoweringBridge &lb);
4545

4646
void dumpTree(CompilerInstance &ci);
4747

4848
void dumpProvenance(CompilerInstance &ci);
4949

5050
void dumpPreFIRTree(CompilerInstance &ci);
5151

52-
void formatOrDumpPrescanner(std::string &buf, llvm::raw_string_ostream &outForPP, CompilerInstance &ci);
52+
void formatOrDumpPrescanner(std::string &buf,
53+
llvm::raw_string_ostream &outForPP,
54+
CompilerInstance &ci);
5355

5456
void debugMeasureParseTree(CompilerInstance &ci, llvm::StringRef filename);
5557

flang/include/flang/Parser/options.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
#ifndef FORTRAN_PARSER_OPTIONS_H_
1010
#define FORTRAN_PARSER_OPTIONS_H_
1111

12+
#include "characters.h"
13+
#include "flang/Support/Fortran-features.h"
14+
1215
#include <optional>
1316
#include <string>
1417
#include <vector>
1518

16-
#include "characters.h"
17-
#include "flang/Support/Fortran-features.h"
18-
1919
namespace Fortran::parser {
2020

2121
struct Options {

flang/include/flang/Parser/parsing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
#include "instrumented-parser.h"
1313
#include "message.h"
14+
#include "options.h"
1415
#include "parse-tree.h"
1516
#include "provenance.h"
16-
#include "options.h"
1717
#include "flang/Parser/preprocessor.h"
1818
#include "llvm/Support/raw_ostream.h"
1919
#include <optional>

flang/lib/Frontend/FrontendAction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#include "flang/Frontend/FrontendActions.h"
1616
#include "flang/Frontend/FrontendOptions.h"
1717
#include "flang/Frontend/FrontendPluginRegistry.h"
18+
#include "flang/Parser/parsing.h"
1819
#include "clang/Basic/DiagnosticFrontend.h"
1920
#include "llvm/Support/Errc.h"
20-
#include "flang/Parser/parsing.h"
2121
#include "llvm/Support/VirtualFileSystem.h"
2222

2323
using namespace Fortran::frontend;

flang/lib/Frontend/FrontendActions.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,9 @@ bool CodeGenAction::beginSourceFileAction() {
310310
lower::LoweringBridge lb = Fortran::lower::LoweringBridge::create(
311311
*mlirCtx, ci.getSemanticsContext(), defKinds,
312312
ci.getSemanticsContext().intrinsics(),
313-
ci.getSemanticsContext().targetCharacteristics(),
314-
Fortran::frontend::getAllCooked(ci), ci.getInvocation().getTargetOpts().triple,
315-
kindMap, ci.getInvocation().getLoweringOpts(),
313+
ci.getSemanticsContext().targetCharacteristics(), getAllCooked(ci),
314+
ci.getInvocation().getTargetOpts().triple, kindMap,
315+
ci.getInvocation().getLoweringOpts(),
316316
ci.getInvocation().getFrontendOpts().envDefaults,
317317
ci.getInvocation().getFrontendOpts().features, targetMachine,
318318
ci.getInvocation().getTargetOpts(), ci.getInvocation().getCodeGenOpts());
@@ -326,7 +326,7 @@ bool CodeGenAction::beginSourceFileAction() {
326326
}
327327

328328
// Create a parse tree and lower it to FIR
329-
Fortran::frontend::parseAndLowerTree(ci, lb);
329+
parseAndLowerTree(ci, lb);
330330

331331
// Fetch module from lb, so we can set
332332
mlirModule = lb.getModuleAndRelease();
@@ -424,7 +424,7 @@ void PrintPreprocessedAction::executeAction() {
424424
llvm::raw_string_ostream outForPP{buf};
425425

426426
CompilerInstance &ci = this->getInstance();
427-
Fortran::frontend::formatOrDumpPrescanner(buf, outForPP, ci);
427+
formatOrDumpPrescanner(buf, outForPP, ci);
428428

429429
// If a pre-defined output stream exists, dump the preprocessed content there
430430
if (!ci.isOutputStreamNull()) {
@@ -444,31 +444,31 @@ void PrintPreprocessedAction::executeAction() {
444444
}
445445

446446
void DebugDumpProvenanceAction::executeAction() {
447-
Fortran::frontend::dumpProvenance(this->getInstance());
447+
dumpProvenance(this->getInstance());
448448
}
449449

450450
void ParseSyntaxOnlyAction::executeAction() {}
451451

452452
void DebugUnparseNoSemaAction::executeAction() {
453-
Fortran::frontend::debugUnparseNoSema(this->getInstance(), llvm::outs());
453+
debugUnparseNoSema(this->getInstance(), llvm::outs());
454454
}
455455

456456
void DebugUnparseAction::executeAction() {
457457
CompilerInstance &ci = this->getInstance();
458458
auto os{ci.createDefaultOutputFile(
459459
/*Binary=*/false, /*InFile=*/getCurrentFileOrBufferName())};
460460

461-
Fortran::frontend::debugUnparseNoSema(ci, *os);
461+
debugUnparseNoSema(ci, *os);
462462
reportFatalSemanticErrors();
463463
}
464464

465465
void DebugUnparseWithSymbolsAction::executeAction() {
466-
Fortran::frontend::debugUnparseWithSymbols(this->getInstance());
466+
debugUnparseWithSymbols(this->getInstance());
467467
reportFatalSemanticErrors();
468468
}
469469

470470
void DebugUnparseWithModulesAction::executeAction() {
471-
Fortran::frontend::debugUnparseWithModules(this->getInstance());
471+
debugUnparseWithModules(this->getInstance());
472472
reportFatalSemanticErrors();
473473
}
474474

@@ -492,7 +492,7 @@ void DebugDumpAllAction::executeAction() {
492492
CompilerInstance &ci = this->getInstance();
493493

494494
// Dump parse tree
495-
Fortran::frontend::dumpTree(ci);
495+
dumpTree(ci);
496496

497497
if (!ci.getRtTyTables().schemata) {
498498
unsigned diagID = ci.getDiagnostics().getCustomDiagID(
@@ -511,19 +511,19 @@ void DebugDumpAllAction::executeAction() {
511511
}
512512

513513
void DebugDumpParseTreeNoSemaAction::executeAction() {
514-
Fortran::frontend::dumpTree(this->getInstance());
514+
dumpTree(this->getInstance());
515515
}
516516

517517
void DebugDumpParseTreeAction::executeAction() {
518-
Fortran::frontend::dumpTree(this->getInstance());
518+
dumpTree(this->getInstance());
519519

520520
// Report fatal semantic errors
521521
reportFatalSemanticErrors();
522522
}
523523

524524
void DebugMeasureParseTreeAction::executeAction() {
525525
CompilerInstance &ci = this->getInstance();
526-
Fortran::frontend::debugMeasureParseTree(ci, getCurrentFileOrBufferName());
526+
debugMeasureParseTree(ci, getCurrentFileOrBufferName());
527527
}
528528

529529
void DebugPreFIRTreeAction::executeAction() {
@@ -532,11 +532,11 @@ void DebugPreFIRTreeAction::executeAction() {
532532
return;
533533
}
534534

535-
Fortran::frontend::dumpPreFIRTree(this->getInstance());
535+
dumpPreFIRTree(this->getInstance());
536536
}
537537

538538
void DebugDumpParsingLogAction::executeAction() {
539-
Fortran::frontend::debugDumpParsingLog(this->getInstance());
539+
debugDumpParsingLog(this->getInstance());
540540
}
541541

542542
void GetDefinitionAction::executeAction() {
@@ -1368,7 +1368,7 @@ void InitOnlyAction::executeAction() {
13681368
void PluginParseTreeAction::executeAction() {}
13691369

13701370
void DebugDumpPFTAction::executeAction() {
1371-
Fortran::frontend::dumpPreFIRTree(this->getInstance());
1371+
dumpPreFIRTree(this->getInstance());
13721372
}
13731373

13741374
Fortran::parser::Parsing &PluginParseTreeAction::getParsing() {

flang/lib/Frontend/ParserActions.cpp

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,33 @@
1212

1313
#include "flang/Frontend/ParserActions.h"
1414
#include "flang/Frontend/CompilerInstance.h"
15+
#include "flang/Lower/Bridge.h"
16+
#include "flang/Lower/PFTBuilder.h"
1517
#include "flang/Parser/dump-parse-tree.h"
1618
#include "flang/Parser/parsing.h"
17-
#include "flang/Parser/unparse.h"
18-
#include "flang/Parser/source.h"
1919
#include "flang/Parser/provenance.h"
20+
#include "flang/Parser/source.h"
21+
#include "flang/Parser/unparse.h"
2022
#include "flang/Semantics/unparse-with-symbols.h"
21-
#include "flang/Lower/Bridge.h"
22-
#include "flang/Lower/PFTBuilder.h"
2323
#include "llvm/Support/raw_ostream.h"
2424

2525
namespace Fortran::frontend {
2626

27-
Fortran::parser::AllCookedSources&
28-
getAllCooked(Fortran::frontend::CompilerInstance &ci) {
27+
parser::AllCookedSources &getAllCooked(CompilerInstance &ci) {
2928
return ci.getParsing().allCooked();
3029
}
3130

32-
void parseAndLowerTree(Fortran::frontend::CompilerInstance &ci,
33-
Fortran::lower::LoweringBridge &lb) {
34-
Fortran::parser::Program &parseTree{*ci.getParsing().parseTree()};
31+
void parseAndLowerTree(CompilerInstance &ci, lower::LoweringBridge &lb) {
32+
parser::Program &parseTree{*ci.getParsing().parseTree()};
3533
lb.lower(parseTree, ci.getSemanticsContext());
3634
}
3735

38-
void dumpTree(Fortran::frontend::CompilerInstance &ci) {
36+
void dumpTree(CompilerInstance &ci) {
3937
auto &parseTree{ci.getParsing().parseTree()};
4038
llvm::outs() << "========================";
4139
llvm::outs() << " Flang: parse tree dump ";
4240
llvm::outs() << "========================\n";
43-
Fortran::parser::DumpTree(llvm::outs(), parseTree,
44-
&ci.getInvocation().getAsFortran());
41+
parser::DumpTree(llvm::outs(), parseTree, &ci.getInvocation().getAsFortran());
4542
}
4643

4744
void dumpProvenance(CompilerInstance &ci) {
@@ -51,9 +48,8 @@ void dumpProvenance(CompilerInstance &ci) {
5148
void dumpPreFIRTree(CompilerInstance &ci) {
5249
auto &parseTree{*ci.getParsing().parseTree()};
5350

54-
if (auto ast{
55-
Fortran::lower::createPFT(parseTree, ci.getSemanticsContext())}) {
56-
Fortran::lower::dumpPFT(llvm::outs(), *ast);
51+
if (auto ast{lower::createPFT(parseTree, ci.getSemanticsContext())}) {
52+
lower::dumpPFT(llvm::outs(), *ast);
5753
} else {
5854
unsigned diagID = ci.getDiagnostics().getCustomDiagID(
5955
clang::DiagnosticsEngine::Error, "Pre FIR Tree is NULL.");
@@ -112,7 +108,7 @@ void debugMeasureParseTree(CompilerInstance &ci, llvm::StringRef filename) {
112108

113109
auto &parseTree{ci.getParsing().parseTree()};
114110
MeasurementVisitor visitor;
115-
Fortran::parser::Walk(parseTree, visitor);
111+
parser::Walk(parseTree, visitor);
116112
llvm::outs() << "Parse tree comprises " << visitor.objects
117113
<< " objects and occupies " << visitor.bytes
118114
<< " total bytes.\n";
@@ -124,7 +120,7 @@ void debugUnparseNoSema(CompilerInstance &ci, llvm::raw_ostream &out) {
124120

125121
// TODO: Options should come from CompilerInvocation
126122
Unparse(out, *parseTree,
127-
/*encoding=*/Fortran::parser::Encoding::UTF_8,
123+
/*encoding=*/parser::Encoding::UTF_8,
128124
/*capitalizeKeywords=*/true, /*backslashEscapes=*/false,
129125
/*preStatement=*/nullptr,
130126
invoc.getUseAnalyzedObjectsForUnparse() ? &invoc.getAsFortran()
@@ -134,15 +130,15 @@ void debugUnparseNoSema(CompilerInstance &ci, llvm::raw_ostream &out) {
134130
void debugUnparseWithSymbols(CompilerInstance &ci) {
135131
auto &parseTree{*ci.getParsing().parseTree()};
136132

137-
Fortran::semantics::UnparseWithSymbols(
138-
llvm::outs(), parseTree, /*encoding=*/Fortran::parser::Encoding::UTF_8);
133+
semantics::UnparseWithSymbols(llvm::outs(), parseTree,
134+
/*encoding=*/parser::Encoding::UTF_8);
139135
}
140136

141137
void debugUnparseWithModules(CompilerInstance &ci) {
142138
auto &parseTree{*ci.getParsing().parseTree()};
143-
Fortran::semantics::UnparseWithModules(
144-
llvm::outs(), ci.getSemantics().context(), parseTree,
145-
/*encoding=*/Fortran::parser::Encoding::UTF_8);
139+
semantics::UnparseWithModules(llvm::outs(), ci.getSemantics().context(),
140+
parseTree,
141+
/*encoding=*/parser::Encoding::UTF_8);
146142
}
147143

148144
void debugDumpParsingLog(CompilerInstance &ci) {

0 commit comments

Comments
 (0)