same.
We were missing the lvalue-to-rvalue conversion entirely in this case,
and in fact still need the full CK_LValueToRValueBitCast conversion to
perform a load with no TBAA.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@373874
91177308-0d34-0410-b5e6-
96231b3b80d8
/// bool b; reinterpret_cast<char&>(b) = 'a';
CAST_OPERATION(LValueBitCast)
-/// CK_LValueToRValueBitCast - A conversion that causes us to reinterpret an
-/// lvalue as an rvalue of a different type. Created by __builtin_bit_cast.
+/// CK_LValueToRValueBitCast - A conversion that causes us to reinterpret the
+/// object representation of an lvalue as an rvalue. Created by
+/// __builtin_bit_cast.
CAST_OPERATION(LValueToRValueBitCast)
/// CK_LValueToRValue - A conversion which causes the extraction of
return;
}
- if (Self.Context.hasSameUnqualifiedType(DestType, SrcType)) {
- Kind = CK_NoOp;
- return;
- }
-
Kind = CK_LValueToRValueBitCast;
}
// CHECK: load i32, i32* {{.*}}, align 4, !tbaa ![[MAY_ALIAS_TBAA]]
}
+int test_same_type(int &r) {
+ // CHECK: load i32, i32* {{.*}}, align 4, !tbaa ![[MAY_ALIAS_TBAA]]
+ return __builtin_bit_cast(int, r);
+}
+
// CHECK: ![[CHAR_TBAA:.*]] = !{!"omnipotent char", {{.*}}, i64 0}
// CHECK: ![[MAY_ALIAS_TBAA]] = !{![[CHAR_TBAA]], ![[CHAR_TBAA]], i64 0}
return x.a == z.a && x.b == z.b;
}
static_assert(test_pad_buffer());
+
+constexpr unsigned char identity1a = 42;
+constexpr unsigned char identity1b = __builtin_bit_cast(unsigned char, identity1a);
+static_assert(identity1b == 42);
+
+struct IdentityInStruct {
+ unsigned char n;
+};
+constexpr IdentityInStruct identity2a = {42};
+constexpr unsigned char identity2b = __builtin_bit_cast(unsigned char, identity2a.n);
+
+union IdentityInUnion {
+ unsigned char n;
+};
+constexpr IdentityInUnion identity3a = {42};
+constexpr unsigned char identity3b = __builtin_bit_cast(unsigned char, identity3a.n);