[cfe-commits] r45086 - /cfe/trunk/CodeGen/CodeGenModule.cpp

Chris Lattner sabre at nondot.org
Sun Dec 16 21:17:43 PST 2007


Author: lattner
Date: Sun Dec 16 23:17:42 2007
New Revision: 45086

URL: http://llvm.org/viewvc/llvm-project?rev=45086&view=rev
Log:
add a hack so that codegen doesn't abort on missing sema of initializers, now
we emit stuff like this:

abort on missing sema of initializers, now
we emit stuff like this:

t3.c:1:24: warning: cannot codegen this initializer yet
const char x[2][4] = { { 'a', 'b', '\0', '\0' }, { 'c', 'd', 'e', '\0' } };
                       ^~~~~~~~~~~~~~~~~~~~~~~~

This should be removed when sema is finished.


Modified:
    cfe/trunk/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenModule.cpp?rev=45086&r1=45085&r2=45086&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenModule.cpp Sun Dec 16 23:17:42 2007
@@ -281,7 +281,15 @@
 /// struct typed variables.
 static llvm::Constant *GenerateAggregateInit(const InitListExpr *ILE, 
                                              CodeGenModule &CGM) {
-  assert (ILE->getType()->isArrayType() || ILE->getType()->isStructureType());
+  if (ILE->getType()->isVoidType()) {
+    // FIXME: Remove this when sema of initializers is finished (and the code
+    // below).
+    CGM.WarnUnsupported(ILE, "initializer");
+    return 0;
+  }
+  
+  assert((ILE->getType()->isArrayType() || ILE->getType()->isStructureType()) &&
+         "Bad type for init list!");
   CodeGenTypes& Types = CGM.getTypes();
 
   unsigned NumInitElements = ILE->getNumInits();
@@ -309,6 +317,12 @@
   unsigned i = 0;
   for (i = 0; i < NumInitableElts; ++i) {
     llvm::Constant *C = GenerateConstantExpr(ILE->getInit(i), CGM);
+    // FIXME: Remove this when sema of initializers is finished (and the code
+    // above).
+    if (C == 0 && ILE->getInit(i)->getType()->isVoidType()) {
+      if (ILE->getType()->isVoidType()) return 0;
+      return llvm::UndefValue::get(CType);
+    }
     assert (C && "Failed to create initialiser expression");
     Elts.push_back(C);
   }





More information about the cfe-commits mailing list