aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/AST/ExprConstant.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index cbb75db255..c095f2166d 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -1557,9 +1557,16 @@ public:
RetTy VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
const CCValue *Value = Info.getOpaqueValue(E);
- if (!Value)
- return (E->getSourceExpr() ? StmtVisitorTy::Visit(E->getSourceExpr())
- : DerivedError(E));
+ if (!Value) {
+ const Expr *Source = E->getSourceExpr();
+ if (!Source)
+ return DerivedError(E);
+ if (Source == E) { // sanity checking.
+ assert(0 && "OpaqueValueExpr recursively refers to itself");
+ return DerivedError(E);
+ }
+ return StmtVisitorTy::Visit(Source);
+ }
return DerivedSuccess(*Value, E);
}