Index: include/clang/AST/Stmt.h =================================================================== --- include/clang/AST/Stmt.h +++ include/clang/AST/Stmt.h @@ -577,13 +577,24 @@ /// @endcode bool HasLeadingEmptyMacro = false; + /// \brief True if the null statement was produced by folding a part of the + /// code away, e.g: + /// @code + /// if constexpr(0 > 1) { willBeFoldedAway(); } + /// // After constexpr evaluation: + /// if constexpr(0 > 1) ; + /// @endcode + bool ResultOfConstexprFolding = false; + public: friend class ASTStmtReader; friend class ASTStmtWriter; - NullStmt(SourceLocation L, bool hasLeadingEmptyMacro = false) + NullStmt(SourceLocation L, bool hasLeadingEmptyMacro = false, + bool resultOfConstexprFolding = false) : Stmt(NullStmtClass), SemiLoc(L), - HasLeadingEmptyMacro(hasLeadingEmptyMacro) {} + HasLeadingEmptyMacro(hasLeadingEmptyMacro), + ResultOfConstexprFolding(resultOfConstexprFolding) {} /// \brief Build an empty null statement. explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty) {} @@ -592,6 +603,7 @@ void setSemiLoc(SourceLocation L) { SemiLoc = L; } bool hasLeadingEmptyMacro() const { return HasLeadingEmptyMacro; } + bool resultOfConstexprFolding() const { return ResultOfConstexprFolding; } SourceLocation getLocStart() const LLVM_READONLY { return SemiLoc; } SourceLocation getLocEnd() const LLVM_READONLY { return SemiLoc; } Index: lib/Sema/TreeTransform.h =================================================================== --- lib/Sema/TreeTransform.h +++ lib/Sema/TreeTransform.h @@ -6605,7 +6605,9 @@ if (Then.isInvalid()) return StmtError(); } else { - Then = new (getSema().Context) NullStmt(S->getThen()->getLocStart()); + Then = new (getSema().Context) NullStmt(S->getThen()->getLocStart(), + /*hasLeadingEmptyMacro=*/false, + /*resultOfConstexprFolding=*/true); } // Transform the "else" branch.