[PATCH] D13325: Fix crash in codegen on casting to `bool &`.

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 7 03:23:58 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL249534: Fix crash in codegen on casting to `bool &`. (authored by ABataev).

Changed prior to commit:
  http://reviews.llvm.org/D13325?vs=36179&id=36725#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13325

Files:
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/test/CodeGenCXX/cast-to-ref-bool.cpp

Index: cfe/trunk/test/CodeGenCXX/cast-to-ref-bool.cpp
===================================================================
--- cfe/trunk/test/CodeGenCXX/cast-to-ref-bool.cpp
+++ cfe/trunk/test/CodeGenCXX/cast-to-ref-bool.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: main
+int main(int argc, char **argv) {
+  // CHECK: load i8, i8* %
+  // CHECK-NEXT: trunc i8 %{{.+}} to i1
+  bool b = (bool &)argv[argc][1];
+  return b;
+}
Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -1383,7 +1383,7 @@
   case CK_LValueBitCast:
   case CK_ObjCObjectLValueCast: {
     Address Addr = EmitLValue(E).getAddress();
-    Addr = Builder.CreateElementBitCast(Addr, ConvertType(DestTy));
+    Addr = Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(DestTy));
     LValue LV = CGF.MakeAddrLValue(Addr, DestTy);
     return EmitLoadOfLValue(LV, CE->getExprLoc());
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13325.36725.patch
Type: text/x-patch
Size: 1088 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151007/45449659/attachment.bin>


More information about the cfe-commits mailing list