]> granicus.if.org Git - clang/commitdiff
Stub out CodeGenFunction::EmitObjCForCollectionStmt.
authorAnders Carlsson <andersca@mac.com>
Sat, 30 Aug 2008 19:51:14 +0000 (19:51 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 30 Aug 2008 19:51:14 +0000 (19:51 +0000)
Add CodeGenFunction::EmitMemSetToZero and make AggExprEmitter::EmitAggregateClear use it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55573 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CGObjC.cpp
lib/CodeGen/CGStmt.cpp
lib/CodeGen/CodeGenFunction.cpp
lib/CodeGen/CodeGenFunction.h

index 13c07c959655d81d1f4070149e4b00ce60ccff01..c007cc0ae9612b6b5e226d3a76bd28edf6aa2897 100644 (file)
@@ -114,24 +114,7 @@ public:
 void AggExprEmitter::EmitAggregateClear(llvm::Value *DestPtr, QualType Ty) {
   assert(!Ty->isAnyComplexType() && "Shouldn't happen for complex");
 
-  // Aggregate assignment turns into llvm.memset.
-  const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
-  if (DestPtr->getType() != BP)
-    DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp");
-
-  // Get size and alignment info for this aggregate.
-  std::pair<uint64_t, unsigned> TypeInfo = CGF.getContext().getTypeInfo(Ty);
-
-  // FIXME: Handle variable sized types.
-  const llvm::Type *IntPtr = llvm::IntegerType::get(CGF.LLVMPointerWidth);
-
-  Builder.CreateCall4(CGF.CGM.getMemSetFn(), 
-                      DestPtr,
-                      llvm::ConstantInt::getNullValue(llvm::Type::Int8Ty),
-                      // TypeInfo.first describes size in bits.
-                      llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
-                      llvm::ConstantInt::get(llvm::Type::Int32Ty, 
-                                             TypeInfo.second/8));
+  CGF.EmitMemSetToZero(DestPtr, Ty);
 }
 
 void AggExprEmitter::EmitAggregateCopy(llvm::Value *DestPtr,
index 79b50114b771407ae9505a3586b3c52e80829c3f..3b7e3a13c95e66d8fe49829a9738942149246860 100644 (file)
@@ -16,6 +16,7 @@
 #include "CodeGenModule.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclObjC.h"
+#include "llvm/ADT/STLExtras.h"
 
 using namespace clang;
 using namespace CodeGen;
@@ -260,4 +261,9 @@ void CodeGenFunction::EmitObjCPropertySet(const ObjCPropertyRefExpr *E,
                                            false, Args);
 }
 
+void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
+{
+  ErrorUnsupported(&S, "for ... in statement");
+}
+
 CGObjCRuntime::~CGObjCRuntime() {}
index 6d3bd43d5b5904893e84d0ccd42ae53fb1e49476..b766fe8a64798334df14a082e94e2ef5939b422d 100644 (file)
@@ -92,8 +92,8 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
   case Stmt::ObjCAtSynchronizedStmtClass:
     ErrorUnsupported(S, "@synchronized statement");
     break;
-  case Stmt::ObjCForCollectionStmtClass:
-    ErrorUnsupported(S, "for ... in statement");
+  case Stmt::ObjCForCollectionStmtClass: 
+    EmitObjCForCollectionStmt(cast<ObjCForCollectionStmt>(*S));
     break;
   }
 }
index 909486a6d1a944a200833e0477c7b055debd3900..09f314077319cc88ca54c89b02a3511b32fa3621 100644 (file)
@@ -201,6 +201,26 @@ unsigned CodeGenFunction::GetIDForAddrOfLabel(const LabelStmt *L) {
   return LabelIDs.insert(std::make_pair(L, LabelIDs.size())).first->second;
 }
 
+void CodeGenFunction::EmitMemSetToZero(llvm::Value *DestPtr, QualType Ty)
+{
+  const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
+  if (DestPtr->getType() != BP)
+    DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp");
+
+  // Get size and alignment info for this aggregate.
+  std::pair<uint64_t, unsigned> TypeInfo = getContext().getTypeInfo(Ty);
+
+  // FIXME: Handle variable sized types.
+  const llvm::Type *IntPtr = llvm::IntegerType::get(LLVMPointerWidth);
+
+  Builder.CreateCall4(CGM.getMemSetFn(), DestPtr,
+                      llvm::ConstantInt::getNullValue(llvm::Type::Int8Ty),
+                      // TypeInfo.first describes size in bits.
+                      llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
+                      llvm::ConstantInt::get(llvm::Type::Int32Ty, 
+                                             TypeInfo.second/8));
+}
+
 void CodeGenFunction::EmitIndirectSwitches() {
   llvm::BasicBlock *Default;
   
index c8421e609a565437c5e6bb84c6090328b9a16364..e43b2d39614f993ead8ffdbeea72d41abd33ae9c 100644 (file)
@@ -193,6 +193,9 @@ public:
 
   unsigned GetIDForAddrOfLabel(const LabelStmt *L);
 
+  /// EmitMemSetToZero - Generate code to memset a value of the given type to 0;
+  void EmitMemSetToZero(llvm::Value *DestPtr, QualType Ty);
+  
   //===--------------------------------------------------------------------===//
   //                            Declaration Emission
   //===--------------------------------------------------------------------===//
@@ -230,6 +233,8 @@ public:
   void EmitCaseStmtRange(const CaseStmt &S);
   void EmitAsmStmt(const AsmStmt &S);
   
+  void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S);
+  
   //===--------------------------------------------------------------------===//
   //                         LValue Expression Emission
   //===--------------------------------------------------------------------===//