]> granicus.if.org Git - clang/commitdiff
fix PR6805: llvm.objectsize changed to take an i1 instead of an i32.
authorChris Lattner <sabre@nondot.org>
Sat, 10 Apr 2010 18:34:14 +0000 (18:34 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 10 Apr 2010 18:34:14 +0000 (18:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100938 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
test/CodeGen/catch-undef-behavior.c [new file with mode: 0644]

index 6fd18f395c4f007aa082c0a0c8895f388835fa98..4b61c2835ffdd23af510eda63d41c5eae3c7c2c7 100644 (file)
@@ -240,18 +240,15 @@ void CodeGenFunction::EmitCheck(llvm::Value *Address, unsigned Size) {
   if (!CatchUndefined)
     return;
 
-  const llvm::IntegerType *Size_tTy
+  const llvm::Type *Size_tTy
     = llvm::IntegerType::get(VMContext, LLVMPointerWidth);
   Address = Builder.CreateBitCast(Address, PtrToInt8Ty);
 
-  const llvm::Type *ResType[] = {
-    Size_tTy
-  };
-  llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::objectsize, ResType, 1);
-  const llvm::IntegerType *IntTy = cast<llvm::IntegerType>(
-    CGM.getTypes().ConvertType(CGM.getContext().IntTy));
+  llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::objectsize, &Size_tTy, 1);
+  const llvm::IntegerType *Int1Ty = llvm::IntegerType::get(VMContext, 1);
+
   // In time, people may want to control this and use a 1 here.
-  llvm::Value *Arg = llvm::ConstantInt::get(IntTy, 0);
+  llvm::Value *Arg = llvm::ConstantInt::get(Int1Ty, 0);
   llvm::Value *C = Builder.CreateCall2(F, Address, Arg);
   llvm::BasicBlock *Cont = createBasicBlock();
   llvm::BasicBlock *Check = createBasicBlock();
diff --git a/test/CodeGen/catch-undef-behavior.c b/test/CodeGen/catch-undef-behavior.c
new file mode 100644 (file)
index 0000000..b7a4a90
--- /dev/null
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -o /dev/null %s
+
+// PR6805
+void foo() {
+  union { int i; } u;
+  u.i=1;
+}