forked from OSchip/llvm-project
[flang] add isModuleFile flag to parser::Options, use it
Original-commit: flang-compiler/f18@0727140f53 Reviewed-on: https://github.com/flang-compiler/f18/pull/151 Tree-same-pre-rewrite: false
This commit is contained in:
parent
4c5dfecb3e
commit
851a5a00f9
|
@ -78,8 +78,8 @@ void Parsing::Prescan(const std::string &path, Options options) {
|
|||
prescanner.AddCompilerDirectiveSentinel("$omp");
|
||||
prescanner.AddCompilerDirectiveSentinel("$"); // OMP conditional line
|
||||
}
|
||||
ProvenanceRange range{
|
||||
allSources.AddIncludedFile(*sourceFile, ProvenanceRange{})};
|
||||
ProvenanceRange range{allSources.AddIncludedFile(
|
||||
*sourceFile, ProvenanceRange{}, options.isModuleFile)};
|
||||
prescanner.Prescan(range);
|
||||
cooked_.Marshal();
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ struct Options {
|
|||
std::vector<std::string> searchDirectories;
|
||||
std::vector<Predefinition> predefinitions;
|
||||
bool instrumentedParse{false};
|
||||
bool isModuleFile{false};
|
||||
};
|
||||
|
||||
class Parsing {
|
||||
|
|
|
@ -355,7 +355,9 @@ bool ModFileReader::Read(const SourceName &modName) {
|
|||
}
|
||||
// TODO: Construct parsing with an AllSources reference to share provenance
|
||||
parser::Parsing parsing;
|
||||
parsing.Prescan(*path, {});
|
||||
parser::Options options;
|
||||
options.isModuleFile = true;
|
||||
parsing.Prescan(*path, options);
|
||||
parsing.Parse(&std::cout);
|
||||
auto &parseTree{parsing.parseTree()};
|
||||
if (!parsing.messages().empty() || !parsing.consumedWholeFile() ||
|
||||
|
@ -372,6 +374,7 @@ bool ModFileReader::Read(const SourceName &modName) {
|
|||
return false;
|
||||
}
|
||||
auto &modSymbol{*it->second};
|
||||
// TODO: Preserve the CookedSource rather than a copy of its string.
|
||||
modSymbol.scope()->set_chars(std::string{parsing.cooked().data()});
|
||||
modSymbol.set(Symbol::Flag::ModFile);
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue