For
double data[20000000] = {0};
we would blow out the memory by creating 20M Exprs to fill out the initializer.
To fix this, if the initializer list initializes an array with more elements than
there are initializers in the list, have InitListExpr store a single 'ArrayFiller' expression
that specifies an expression to be used for value initialization of the rest of the elements.
Fixes rdar://9275920.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129896 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Index/initializer-memory.cpp b/test/Index/initializer-memory.cpp
new file mode 100644
index 0000000..d0f531f
--- /dev/null
+++ b/test/Index/initializer-memory.cpp
@@ -0,0 +1,14 @@
+// RUN: c-index-test -test-load-source-memory-usage none %s 2>&1 | FileCheck %s
+
+// rdar://9275920 - We would create millions of Exprs to fill out the initializer.
+
+double data[1000000] = {0};
+
+struct S {
+ S(int);
+ S();
+};
+
+S data2[1000000] = {0};
+
+// CHECK: TOTAL = {{.*}} (0.{{.*}} MBytes)