@@ -584,6 +584,12 @@ ParserResult<IfConfigDecl> Parser::parseIfConfig(
584
584
Parser::StructureMarkerRAII ParsingDecl (
585
585
*this , Tok.getLoc (), Parser::StructureMarkerKind::IfConfig);
586
586
587
+ bool shouldEvaluate =
588
+ // Don't evaluate if it's in '-parse' mode, etc.
589
+ State->PerformConditionEvaluation &&
590
+ // If it's in inactive #if ... #endif block, there's no point to do it.
591
+ !getScopeInfo ().isInactiveConfigBlock ();
592
+
587
593
bool foundActive = false ;
588
594
bool isVersionCondition = false ;
589
595
while (1 ) {
@@ -604,7 +610,7 @@ ParserResult<IfConfigDecl> Parser::parseIfConfig(
604
610
// Parse the condition. Evaluate it to determine the active
605
611
// clause unless we're doing a parse-only pass.
606
612
if (isElse) {
607
- isActive = !foundActive && State-> PerformConditionEvaluation ;
613
+ isActive = !foundActive && shouldEvaluate ;
608
614
} else {
609
615
llvm::SaveAndRestore<bool > S (InPoundIfEnvironment, true );
610
616
ParserResult<Expr> Result = parseExprSequence (diag::expected_expr,
@@ -619,7 +625,7 @@ ParserResult<IfConfigDecl> Parser::parseIfConfig(
619
625
// Error in the condition;
620
626
isActive = false ;
621
627
isVersionCondition = false ;
622
- } else if (!foundActive && State-> PerformConditionEvaluation ) {
628
+ } else if (!foundActive && shouldEvaluate ) {
623
629
// Evaluate the condition only if we haven't found any active one and
624
630
// we're not in parse-only mode.
625
631
isActive = evaluateIfConfigCondition (Condition, Context);
0 commit comments