Commit 66addf8e authored by Benjamin Kramer's avatar Benjamin Kramer
Browse files

Revert "Fix regression in bdad0a1b: force rebuilding of StmtExpr nodes in",...

Revert "Fix regression in bdad0a1b: force rebuilding of StmtExpr nodes in", "PR45083: Mark statement expressions as being dependent if they appear in"

This reverts commit f545ede9.
This reverts commit bdad0a1b.

This crashes clang. I'll follow up with reproduction instructions.
parent 6e9c10f6
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -3959,13 +3959,13 @@ class StmtExpr : public Expr {
  Stmt *SubStmt;
  SourceLocation LParenLoc, RParenLoc;
public:
  // FIXME: Does type-dependence need to be computed differently?
  // FIXME: Do we need to compute instantiation instantiation-dependence for
  // statements? (ugh!)
  StmtExpr(CompoundStmt *substmt, QualType T,
           SourceLocation lp, SourceLocation rp, bool InDependentContext) :
    // Note: we treat a statement-expression in a dependent context as always
    // being value- and instantiation-dependent. This matches the behavior of
    // lambda-expressions and GCC.
           SourceLocation lp, SourceLocation rp) :
    Expr(StmtExprClass, T, VK_RValue, OK_Ordinary,
         T->isDependentType(), InDependentContext, InDependentContext, false),
         T->isDependentType(), false, false, false),
    SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) { }

  /// Build an empty statement expression.
+2 −4
Original line number Diff line number Diff line
@@ -4964,10 +4964,8 @@ public:
                            LabelDecl *TheDecl);
  void ActOnStartStmtExpr();
  ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
                           SourceLocation RPLoc);
  ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
                           SourceLocation RPLoc, bool IsDependent);
  ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
                           SourceLocation RPLoc); // "({..})"
  // Handle the final expression in a statement expression.
  ExprResult ActOnStmtExprResult(ExprResult E);
  void ActOnStmtExprError();
+2 −3
Original line number Diff line number Diff line
@@ -6631,9 +6631,8 @@ ExpectedStmt ASTNodeImporter::VisitStmtExpr(StmtExpr *E) {
  if (Err)
    return std::move(Err);

  return new (Importer.getToContext())
      StmtExpr(ToSubStmt, ToType, ToLParenLoc, ToRParenLoc,
               E->isInstantiationDependent());
  return new (Importer.getToContext()) StmtExpr(
      ToSubStmt, ToType, ToLParenLoc, ToRParenLoc);
}

ExpectedStmt ASTNodeImporter::VisitUnaryOperator(UnaryOperator *E) {
+1 −2
Original line number Diff line number Diff line
@@ -2655,8 +2655,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,

      // If the substmt parsed correctly, build the AST node.
      if (!Stmt.isInvalid()) {
        Result = Actions.ActOnStmtExpr(getCurScope(), OpenLoc, Stmt.get(),
                                       Tok.getLocation());
        Result = Actions.ActOnStmtExpr(OpenLoc, Stmt.get(), Tok.getLocation());
      } else {
        Actions.ActOnStmtExprError();
      }
+4 −10
Original line number Diff line number Diff line
@@ -13911,14 +13911,9 @@ void Sema::ActOnStmtExprError() {
  PopExpressionEvaluationContext();
}
ExprResult Sema::ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
                               SourceLocation RPLoc) {
  return BuildStmtExpr(LPLoc, SubStmt, RPLoc,
                       S->getTemplateParamParent() != nullptr);
}
ExprResult Sema::BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
                               SourceLocation RPLoc, bool IsDependent) {
ExprResult
Sema::ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
                    SourceLocation RPLoc) { // "({..})"
  assert(SubStmt && isa<CompoundStmt>(SubStmt) && "Invalid action invocation!");
  CompoundStmt *Compound = cast<CompoundStmt>(SubStmt);
@@ -13949,8 +13944,7 @@ ExprResult Sema::BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
  // FIXME: Check that expression type is complete/non-abstract; statement
  // expressions are not lvalues.
  Expr *ResStmtExpr =
      new (Context) StmtExpr(Compound, Ty, LPLoc, RPLoc, IsDependent);
  Expr *ResStmtExpr = new (Context) StmtExpr(Compound, Ty, LPLoc, RPLoc);
  if (StmtExprMayBindToTemp)
    return MaybeBindToTemporary(ResStmtExpr);
  return ResStmtExpr;
Loading