77// ===----------------------------------------------------------------------===//
88
99#include " flang/Parser/parsing.h"
10- #include " preprocessor.h"
1110#include " prescan.h"
1211#include " type-parsers.h"
1312#include " flang/Parser/message.h"
13+ #include " flang/Parser/preprocessor.h"
1414#include " flang/Parser/provenance.h"
1515#include " flang/Parser/source.h"
1616#include " llvm/Support/raw_ostream.h"
@@ -60,20 +60,19 @@ const SourceFile *Parsing::Prescan(const std::string &path, Options options) {
6060 }
6161 }
6262
63- Preprocessor preprocessor{allSources};
6463 if (!options.predefinitions .empty ()) {
65- preprocessor .DefineStandardMacros ();
64+ preprocessor_ .DefineStandardMacros ();
6665 for (const auto &predef : options.predefinitions ) {
6766 if (predef.second ) {
68- preprocessor .Define (predef.first , *predef.second );
67+ preprocessor_ .Define (predef.first , *predef.second );
6968 } else {
70- preprocessor .Undefine (predef.first );
69+ preprocessor_ .Undefine (predef.first );
7170 }
7271 }
7372 }
7473 currentCooked_ = &allCooked_.NewCookedSource ();
7574 Prescanner prescanner{
76- messages_, *currentCooked_, preprocessor , options.features };
75+ messages_, *currentCooked_, preprocessor_ , options.features };
7776 prescanner.set_fixedForm (options.isFixedForm )
7877 .set_fixedFormColumnLimit (options.fixedFormColumns )
7978 .AddCompilerDirectiveSentinel (" dir$" );
@@ -87,7 +86,7 @@ const SourceFile *Parsing::Prescan(const std::string &path, Options options) {
8786 if (options.features .IsEnabled (LanguageFeature::CUDA)) {
8887 prescanner.AddCompilerDirectiveSentinel (" $cuf" );
8988 prescanner.AddCompilerDirectiveSentinel (" @cuf" );
90- preprocessor .Define (" _CUDA" , " 1" );
89+ preprocessor_ .Define (" _CUDA" , " 1" );
9190 }
9291 ProvenanceRange range{allSources.AddIncludedFile (
9392 *sourceFile, ProvenanceRange{}, options.isModuleFile )};
@@ -107,6 +106,10 @@ const SourceFile *Parsing::Prescan(const std::string &path, Options options) {
107106 return sourceFile;
108107}
109108
109+ void Parsing::EmitPreprocessorMacros (llvm::raw_ostream &out) const {
110+ preprocessor_.PrintMacros (out);
111+ }
112+
110113void Parsing::EmitPreprocessedSource (
111114 llvm::raw_ostream &out, bool lineDirectives) const {
112115 const std::string *sourcePath{nullptr };
0 commit comments