[cfe-commits] r79059 - /cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Chris Lattner sabre at nondot.org
Fri Aug 14 17:03:43 PDT 2009


Author: lattner
Date: Fri Aug 14 19:03:43 2009
New Revision: 79059

URL: http://llvm.org/viewvc/llvm-project?rev=79059&view=rev
Log:
minor cleanups for VLA stuff.

Modified:
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Aug 14 19:03:43 2009
@@ -493,19 +493,16 @@
     llvm::Value *&SizeEntry = VLASizeMap[VAT];
     
     if (!SizeEntry) {
-      // Get the element size;
-      llvm::Value *ElemSize;
-    
-      QualType ElemTy = VAT->getElementType();
-
       const llvm::Type *SizeTy = ConvertType(getContext().getSizeType());
                                              
+      // Get the element size;
+      QualType ElemTy = VAT->getElementType();
+      llvm::Value *ElemSize;
       if (ElemTy->isVariableArrayType())
         ElemSize = EmitVLASize(ElemTy);
-      else {
+      else
         ElemSize = llvm::ConstantInt::get(SizeTy,
                                           getContext().getTypeSize(ElemTy) / 8);
-      }
     
       llvm::Value *NumElements = EmitScalarExpr(VAT->getSizeExpr());
       NumElements = Builder.CreateIntCast(NumElements, SizeTy, false, "tmp");
@@ -514,14 +511,16 @@
     }
     
     return SizeEntry;
-  } else if (const ArrayType *AT = dyn_cast<ArrayType>(Ty)) {
-    EmitVLASize(AT->getElementType());
-  } else if (const PointerType *PT = Ty->getAs<PointerType>())
-    EmitVLASize(PT->getPointeeType());
-  else {
-    assert(0 && "unknown VM type!");
   }
   
+  if (const ArrayType *AT = dyn_cast<ArrayType>(Ty)) {
+    EmitVLASize(AT->getElementType());
+    return 0;
+  } 
+  
+  const PointerType *PT = Ty->getAs<PointerType>();
+  assert(PT && "unknown VM type!");
+  EmitVLASize(PT->getPointeeType());
   return 0;
 }
 





More information about the cfe-commits mailing list