@@ -801,10 +801,12 @@ void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) {
801801}
802802
803803void CodeGenFunction::EmitIfStmt (const IfStmt &S) {
804+ const Stmt *Else = S.getElse ();
805+
804806 // The else branch of a consteval if statement is always the only branch that
805807 // can be runtime evaluated.
806808 if (S.isConsteval ()) {
807- const Stmt *Executed = S.isNegatedConsteval () ? S.getThen () : S. getElse () ;
809+ const Stmt *Executed = S.isNegatedConsteval () ? S.getThen () : Else ;
808810 if (Executed) {
809811 RunCleanupsScope ExecutedScope (*this );
810812 EmitStmt (Executed);
@@ -830,8 +832,8 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
830832 S.isConstexpr ())) {
831833 // Figure out which block (then or else) is executed.
832834 const Stmt *Executed = S.getThen ();
833- const Stmt *Skipped = S. getElse () ;
834- if (!CondConstant) // Condition false?
835+ const Stmt *Skipped = Else ;
836+ if (!CondConstant) // Condition false?
835837 std::swap (Executed, Skipped);
836838
837839 // If the skipped block has no labels in it, just emit the executed block.
@@ -852,7 +854,7 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
852854 llvm::BasicBlock *ThenBlock = createBasicBlock (" if.then" );
853855 llvm::BasicBlock *ContBlock = createBasicBlock (" if.end" );
854856 llvm::BasicBlock *ElseBlock = ContBlock;
855- if (S. getElse () )
857+ if (Else )
856858 ElseBlock = createBasicBlock (" if.else" );
857859
858860 // Prefer the PGO based weights over the likelihood attribute.
@@ -870,7 +872,7 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
870872 uint64_t ThenCount = getProfileCount (S.getThen ());
871873 if (!ThenCount && !getCurrentProfileCount () &&
872874 CGM.getCodeGenOpts ().OptimizationLevel )
873- LH = Stmt::getLikelihood (S.getThen (), S. getElse () );
875+ LH = Stmt::getLikelihood (S.getThen (), Else );
874876
875877 // When measuring MC/DC, always fully evaluate the condition up front using
876878 // EvaluateExprAsBool() so that the test vector bitmap can be updated prior to
@@ -898,7 +900,7 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
898900 EmitBranch (ContBlock);
899901
900902 // Emit the 'else' code if present.
901- if (const Stmt * Else = S. getElse () ) {
903+ if (Else) {
902904 {
903905 // There is no need to emit line number for an unconditional branch.
904906 auto NL = ApplyDebugLocation::CreateEmpty (*this );
0 commit comments