From: Douglas Gregor Date: Thu, 23 Feb 2012 22:17:26 +0000 (+0000) Subject: Pull the OpaqueValueExpr's source expression into its constructor, so X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97df54e0c075bc8d6a869597e771dad0c11a2180;p=clang Pull the OpaqueValueExpr's source expression into its constructor, so that we can correctly compute value-dependence of the OVE. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151291 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index d943aba0d3..b9c3220c0b 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -696,12 +696,15 @@ class OpaqueValueExpr : public Expr { public: OpaqueValueExpr(SourceLocation Loc, QualType T, ExprValueKind VK, - ExprObjectKind OK = OK_Ordinary) + ExprObjectKind OK = OK_Ordinary, + Expr *SourceExpr = 0) : Expr(OpaqueValueExprClass, T, VK, OK, - T->isDependentType(), T->isDependentType(), + T->isDependentType(), + T->isDependentType() || + (SourceExpr && SourceExpr->isValueDependent()), T->isInstantiationDependentType(), false), - SourceExpr(0), Loc(Loc) { + SourceExpr(SourceExpr), Loc(Loc) { } /// Given an expression which invokes a copy constructor --- i.e. a @@ -735,7 +738,6 @@ public: /// expression which binds the opaque value expression in the first /// place. Expr *getSourceExpr() const { return SourceExpr; } - void setSourceExpr(Expr *e) { SourceExpr = e; } static bool classof(const Stmt *T) { return T->getStmtClass() == OpaqueValueExprClass; @@ -3063,8 +3065,7 @@ public: SubExprs[COND] = cond; SubExprs[LHS] = lhs; SubExprs[RHS] = rhs; - - OpaqueValue->setSourceExpr(common); + assert(OpaqueValue->getSourceExpr() == common && "Wrong opaque value"); } /// \brief Build an empty conditional operator. diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index c7738a5626..fcb2d410cb 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -4899,7 +4899,8 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc, opaqueValue = new (Context) OpaqueValueExpr(commonExpr->getExprLoc(), commonExpr->getType(), commonExpr->getValueKind(), - commonExpr->getObjectKind()); + commonExpr->getObjectKind(), + commonExpr); LHSExpr = CondExpr = opaqueValue; } diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp index fa56b258da..d5f1523f62 100644 --- a/lib/Sema/SemaPseudoObject.cpp +++ b/lib/Sema/SemaPseudoObject.cpp @@ -222,8 +222,8 @@ OpaqueValueExpr *PseudoOpBuilder::capture(Expr *e) { // Make a new OVE whose source is the given expression. OpaqueValueExpr *captured = new (S.Context) OpaqueValueExpr(GenericLoc, e->getType(), - e->getValueKind()); - captured->setSourceExpr(e); + e->getValueKind(), e->getObjectKind(), + e); // Make sure we bind that in the semantics. addSemanticExpr(captured);