Change EmitConstantExpr to allow failure.

IRgen no longer relies on isConstantInitializer, instead we just try
to emit the constant. If that fails then in C we emit an error
unsupported (this occurs when Sema accepted something that it doesn't
know how to fold, and IRgen doesn't know how to emit) and in C++ we
emit a guarded initializer.

This ends up handling a few more cases, because IRgen was actually
able to emit some of the constants Sema accepts but can't Evaluate().
For example, PR3398.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64780 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGen/staticinit.c b/test/CodeGen/staticinit.c
index 196d931..384ddbf 100644
--- a/test/CodeGen/staticinit.c
+++ b/test/CodeGen/staticinit.c
@@ -1,4 +1,5 @@
-// RUN: clang -emit-llvm < %s | grep "g.b = internal global i8. getelementptr"
+// RUN: clang -arch i386 -emit-llvm -o %t %s &&
+// RUN: grep "g.b = internal global i8. getelementptr" %t &&
 
 struct AStruct { 
 	int i;
@@ -24,3 +25,7 @@
 void foo(void) {
   static struct s var = {((void*)&((char*)0)[0])};
 }
+
+// RUN: grep "f1.l0 = internal global i32 ptrtoint (i32 ()\* @f1 to i32)" %t
+int f1(void) { static int l0 = (unsigned) f1; }
+