When evaluating a VarDecl as a constant or determining whether it is
an integral constant expression, maintain a cache of the value and the
is-an-ICE flag within the VarDecl itself. This eliminates
exponential-time behavior of the Fibonacci template metaprogram.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72428 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/StmtIterator.cpp b/lib/AST/StmtIterator.cpp
index 20024f5..5c22e28 100644
--- a/lib/AST/StmtIterator.cpp
+++ b/lib/AST/StmtIterator.cpp
@@ -140,14 +140,14 @@
   
   if (inDeclGroup()) {
     VarDecl* VD = cast<VarDecl>(*DGI);
-    return VD->Init;
+    return *VD->getInitAddress();
   }
   
   assert (inDecl());
 
   if (VarDecl* VD = dyn_cast<VarDecl>(decl)) {
     assert (VD->Init);
-    return VD->Init;
+    return *VD->getInitAddress();
   }
 
   EnumConstantDecl* ECD = cast<EnumConstantDecl>(decl);