Fix a crash-on-valid that has been here for a very long time:

  const int &x = x;

This crashed by inifinetly recursing within the lvalue evaluation
routine. I've added a (somewhat) braindead way of preventing this
recursion. If folks have better suggestions for how to avoid it I'm all
ears.

That said, we have some work to do. This doesn't trigger a single
warning for uninitialized, self-initialized or otherwise completely
wrong code. In some senses, the crash was almost better.

llvm-svn: 138239
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index fdcff0a..2cd85a1 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -447,6 +447,7 @@
 class LValueExprEvaluator
   : public ExprEvaluatorBase<LValueExprEvaluator, bool> {
   LValue &Result;
+  const Decl *PrevDecl;
 
   bool Success(const Expr *E) {
     Result.Base = E;
@@ -456,7 +457,7 @@
 public:
 
   LValueExprEvaluator(EvalInfo &info, LValue &Result) :
-    ExprEvaluatorBaseTy(info), Result(Result) {}
+    ExprEvaluatorBaseTy(info), Result(Result), PrevDecl(0) {}
 
   bool Success(const APValue &V, const Expr *E) {
     Result.setFrom(V);
@@ -501,10 +502,16 @@
       return Success(E);
     // Reference parameters can refer to anything even if they have an
     // "initializer" in the form of a default argument.
-    if (!isa<ParmVarDecl>(VD))
+    if (!isa<ParmVarDecl>(VD)) {
       // FIXME: Check whether VD might be overridden!
+
+      // Check for recursive initializers of references.
+      if (PrevDecl == VD)
+        return Error(E);
+      PrevDecl = VD;
       if (const Expr *Init = VD->getAnyInitializer())
         return Visit(Init);
+    }
   }
 
   return ExprEvaluatorBaseTy::VisitDeclRefExpr(E);