]> granicus.if.org Git - clang/commitdiff
Pull the OpaqueValueExpr's source expression into its constructor, so
authorDouglas Gregor <dgregor@apple.com>
Thu, 23 Feb 2012 22:17:26 +0000 (22:17 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 23 Feb 2012 22:17:26 +0000 (22:17 +0000)
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

include/clang/AST/Expr.h
lib/Sema/SemaExpr.cpp
lib/Sema/SemaPseudoObject.cpp

index d943aba0d3831a51791095222b65672840375972..b9c3220c0b85a6f3cb4f5dacadc4a1404ea291e9 100644 (file)
@@ -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.
index c7738a5626a05d8d56d37ea5568390c6444652e3..fcb2d410cb20dc04f68b3db1fa504a6fb4c30597 100644 (file)
@@ -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;
   }
 
index fa56b258daa9b1d23f9365ab97cecc832b07230b..d5f1523f62a45b29ad38ded7ded5448e8d7e3337 100644 (file)
@@ -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);