[cfe-commits] r55544 - in /cfe/trunk/lib/CodeGen: CGDecl.cpp CGExprScalar.cpp CGObjCMac.cpp CGStmt.cpp CodeGenFunction.h CodeGenModule.cpp

Daniel Dunbar daniel at zuster.org
Fri Aug 29 10:28:43 PDT 2008


Author: ddunbar
Date: Fri Aug 29 12:28:43 2008
New Revision: 55544

URL: http://llvm.org/viewvc/llvm-project?rev=55544&view=rev
Log:
Downgrade a number of FIXME asserts to ErrorUnsupported.
 - Notably VLAs

Modified:
    cfe/trunk/lib/CodeGen/CGDecl.cpp
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
    cfe/trunk/lib/CodeGen/CGStmt.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=55544&r1=55543&r2=55544&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Aug 29 12:28:43 2008
@@ -37,24 +37,20 @@
   case Decl::Union:     // union X;
   case Decl::Class:     // class X;
   case Decl::Enum:      // enum X;
+  case Decl::EnumConstant: // enum ? { X = ? } 
   case Decl::CXXStruct: // struct X; [C++]
   case Decl::CXXUnion:  // union X; [C++]
   case Decl::CXXClass:  // class X; [C++]
     // None of these decls require codegen support.
     return;
     
-  case Decl::Var:
-    if (cast<VarDecl>(D).isBlockVarDecl())
-      return EmitBlockVarDecl(cast<VarDecl>(D));
-    assert(0 && "Should not see file-scope variables inside a function!");
-  
-  case Decl::EnumConstant:
-    return EmitEnumConstantDecl(cast<EnumConstantDecl>(D));
+  case Decl::Var: {
+    const VarDecl &VD = cast<VarDecl>(D);
+    assert(VD.isBlockVarDecl() && 
+           "Should not see file-scope variables inside a function!");
+    return EmitBlockVarDecl(VD);
+  }
   }
-}
-
-void CodeGenFunction::EmitEnumConstantDecl(const EnumConstantDecl &D) {
-  assert(0 && "FIXME: Enum constant decls not implemented yet!");  
 }
 
 /// EmitBlockVarDecl - This method handles emission of any variable declaration
@@ -169,8 +165,13 @@
       DeclPtr = GenerateStaticBlockVarDecl(D, true, Class);
     }
   } else {
-    // TODO: Create a dynamic alloca.
-    assert(0 && "FIXME: Local VLAs not implemented yet");
+    CGM.ErrorUnsupported(&D, "variable-length array");
+
+    // FIXME: VLA: Add VLA support. For now just make up enough to let
+    // the compile go through.
+    const llvm::Type *LTy = ConvertType(Ty);
+    llvm::AllocaInst * Alloc = CreateTempAlloca(LTy, D.getName());
+    DeclPtr = Alloc;
   }
   
   llvm::Value *&DMEntry = LocalDeclMap[&D];

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=55544&r1=55543&r2=55544&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Aug 29 12:28:43 2008
@@ -513,10 +513,14 @@
     // will not true when we add support for VLAs.
     Value *V = EmitLValue(Op).getAddress();  // Bitfields can't be arrays.
     
-    assert(isa<llvm::PointerType>(V->getType()) &&
-           isa<llvm::ArrayType>(cast<llvm::PointerType>(V->getType())
-                                ->getElementType()) &&
-           "Doesn't support VLAs yet!");
+    if (!(isa<llvm::PointerType>(V->getType()) &&
+          isa<llvm::ArrayType>(cast<llvm::PointerType>(V->getType())
+                               ->getElementType()))) {
+      CGF.ErrorUnsupported(E, "variable-length array cast");
+      if (E->getType()->isVoidType())
+        return 0;
+      return llvm::UndefValue::get(CGF.ConvertType(E->getType()));
+    }
     V = Builder.CreateStructGEP(V, 0, "arraydecay");
     
     // The resultant pointer type can be implicitly casted to other pointer

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=55544&r1=55543&r2=55544&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Fri Aug 29 12:28:43 2008
@@ -1911,7 +1911,7 @@
     Params[1] = IsSuper ? SuperPtrTy : ObjectPtrTy;
     Params[2] = SelectorPtrTy;
     CallFTy = llvm::FunctionType::get(llvm::Type::VoidTy, Params, true);
-  } else { // XXX floating point?
+  } else { // FIXME: floating point?
     F = IsSuper ? MessageSendSuperFn : MessageSendFn;
     std::vector<const llvm::Type*> Params(2);
     Params[0] = IsSuper ? SuperPtrTy : ObjectPtrTy;

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=55544&r1=55543&r2=55544&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Fri Aug 29 12:28:43 2008
@@ -464,7 +464,7 @@
 /// add multiple cases to switch instruction, one for each value within
 /// the range. If range is too big then emit "if" condition check.
 void CodeGenFunction::EmitCaseStmtRange(const CaseStmt &S) {
-  // XXX kill me with param - ddunbar
+  // FIXME: kill me with param - ddunbar
   assert(S.getRHS() && "Expected RHS value in CaseStmt");
 
   llvm::APSInt LHS = S.getLHS()->getIntegerConstantExprValue(getContext());
@@ -755,7 +755,7 @@
         if (ConvertType(InputExpr->getType())->isSingleValueType()) {
           Arg = EmitScalarExpr(InputExpr);
         } else {
-          assert(0 && "FIXME: Implement passing multiple-value types as inputs");
+          ErrorUnsupported(&S, "asm statement passing multiple-value types as inputs");
         }
       } else {
         LValue Dest = EmitLValue(InputExpr);
@@ -796,7 +796,7 @@
       if (ConvertType(InputExpr->getType())->isSingleValueType()) {
         Arg = EmitScalarExpr(InputExpr);
       } else {
-        assert(0 && "FIXME: Implement passing multiple-value types as inputs");
+        ErrorUnsupported(&S, "asm statement passing multiple-value types as inputs");
       }
     } else {
       LValue Dest = EmitLValue(InputExpr);

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=55544&r1=55543&r2=55544&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Aug 29 12:28:43 2008
@@ -198,7 +198,6 @@
   //===--------------------------------------------------------------------===//
   
   void EmitDecl(const Decl &D);
-  void EmitEnumConstantDecl(const EnumConstantDecl &D);
   void EmitBlockVarDecl(const VarDecl &D);
   void EmitLocalBlockVarDecl(const VarDecl &D);
   void EmitStaticBlockVarDecl(const VarDecl &D);

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Aug 29 12:28:43 2008
@@ -764,7 +764,11 @@
 /// GetStringForStringLiteral - Return the appropriate bytes for a
 /// string literal, properly padded to match the literal type.
 std::string CodeGenModule::GetStringForStringLiteral(const StringLiteral *E) {
-  assert(!E->isWide() && "FIXME: Wide strings not supported yet!");
+  if (E->isWide()) {
+    ErrorUnsupported(E, "wide string");
+    return "FIXME";
+  }
+
   const char *StrData = E->getStrData();
   unsigned Len = E->getByteLength();
 
@@ -877,7 +881,7 @@
     break;
 
   case Decl::Namespace:
-    assert(0 && "FIXME: Namespace unsupported");
+    ErrorUnsupported(D, "namespace");
     break;
 
     // Objective-C Decls
@@ -914,7 +918,7 @@
     break;
   }
   case Decl::ObjCCompatibleAlias: 
-    assert(0 && "FIXME: ObjCCompatibleAlias unsupported");
+    ErrorUnsupported(D, "Objective-C compatible alias");
     break;
 
   case Decl::LinkageSpec: {





More information about the cfe-commits mailing list