@@ -362,16 +362,14 @@ static LexerMode sourceFileKindToLexerMode(SourceFileKind kind) {
362
362
363
363
Parser::Parser (unsigned BufferID, SourceFile &SF, SILParserTUStateBase *SIL,
364
364
PersistentParserState *PersistentState,
365
- std::shared_ptr<SyntaxParseActions> SPActions,
366
- bool EvaluateConditionals)
365
+ std::shared_ptr<SyntaxParseActions> SPActions)
367
366
: Parser(BufferID, SF, &SF.getASTContext().Diags, SIL, PersistentState,
368
- std::move(SPActions), EvaluateConditionals ) {}
367
+ std::move(SPActions)) {}
369
368
370
369
Parser::Parser (unsigned BufferID, SourceFile &SF, DiagnosticEngine* LexerDiags,
371
370
SILParserTUStateBase *SIL,
372
371
PersistentParserState *PersistentState,
373
- std::shared_ptr<SyntaxParseActions> SPActions,
374
- bool EvaluateConditionals)
372
+ std::shared_ptr<SyntaxParseActions> SPActions)
375
373
: Parser(
376
374
std::unique_ptr<Lexer>(new Lexer(
377
375
SF.getASTContext().LangOpts, SF.getASTContext().SourceMgr,
@@ -386,8 +384,7 @@ Parser::Parser(unsigned BufferID, SourceFile &SF, DiagnosticEngine* LexerDiags,
386
384
SF.shouldBuildSyntaxTree()
387
385
? TriviaRetentionMode::WithTrivia
388
386
: TriviaRetentionMode::WithoutTrivia)),
389
- SF, SIL, PersistentState, std::move(SPActions),
390
- EvaluateConditionals) {}
387
+ SF, SIL, PersistentState, std::move(SPActions)) {}
391
388
392
389
namespace {
393
390
@@ -507,8 +504,7 @@ class TokenRecorder: public ConsumeTokenReceiver {
507
504
Parser::Parser (std::unique_ptr<Lexer> Lex, SourceFile &SF,
508
505
SILParserTUStateBase *SIL,
509
506
PersistentParserState *PersistentState,
510
- std::shared_ptr<SyntaxParseActions> SPActions,
511
- bool EvaluateConditionals)
507
+ std::shared_ptr<SyntaxParseActions> SPActions)
512
508
: SourceMgr(SF.getASTContext().SourceMgr),
513
509
Diags(SF.getASTContext().Diags),
514
510
SF(SF),
@@ -517,7 +513,6 @@ Parser::Parser(std::unique_ptr<Lexer> Lex, SourceFile &SF,
517
513
CurDeclContext(&SF),
518
514
Context(SF.getASTContext()),
519
515
CurrentTokenHash(SF.getInterfaceHashPtr()),
520
- EvaluateConditionals(EvaluateConditionals),
521
516
TokReceiver(SF.shouldCollectToken() ?
522
517
new TokenRecorder(SF, L->getBufferID ()) :
523
518
new ConsumeTokenReceiver()),
@@ -551,6 +546,11 @@ bool Parser::isDelayedParsingEnabled() const {
551
546
return SF.hasDelayedBodyParsing ();
552
547
}
553
548
549
+ bool Parser::shouldEvaluatePoundIfDecls () const {
550
+ auto opts = SF.getParsingOptions ();
551
+ return !opts.contains (SourceFile::ParsingFlags::DisablePoundIfEvaluation);
552
+ }
553
+
554
554
bool Parser::allowTopLevelCode () const {
555
555
return SF.isScriptMode ();
556
556
}
@@ -1179,7 +1179,8 @@ struct ParserUnit::Implementation {
1179
1179
*ModuleDecl::create (Ctx.getIdentifier(ModuleName), Ctx), SFKind,
1180
1180
BufferID, SourceFile::ImplicitModuleImportKind::None,
1181
1181
Opts.CollectParsedToken, Opts.BuildSyntaxTree,
1182
- SourceFile::ParsingFlags::DisableDelayedBodies)) {}
1182
+ SourceFile::ParsingFlags::DisableDelayedBodies |
1183
+ SourceFile::ParsingFlags::DisablePoundIfEvaluation)) {}
1183
1184
1184
1185
~Implementation () {
1185
1186
// We need to delete the parser before the context so that it can finalize
0 commit comments