When constant folding reference variables with an initializer to the
initializer, don't fold paramters. Their initializers are just default
arguments which can be overridden. This fixes some spectacular regressions due
to more things making it into the constant folding.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103904 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGenCXX/references.cpp b/test/CodeGenCXX/references.cpp
index 5a5947d..3ae1e47 100644
--- a/test/CodeGenCXX/references.cpp
+++ b/test/CodeGenCXX/references.cpp
@@ -155,3 +155,16 @@
 // CHECK: load
 // CHECK: ret
 const int &f2() { return 0; }
+
+// Don't constant fold const reference parameters with default arguments to
+// their default arguments.
+namespace N1 {
+  const int foo = 1;
+  // CHECK: @_ZN2N14test
+  int test(const int& arg = foo) {
+    // Ensure this array is on the stack where we can set values instead of
+    // being a global constant.
+    // CHECK: %args_array = alloca
+    const int* const args_array[] = { &arg };
+  }
+}