File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -1085,6 +1085,12 @@ bool ByteCodeExprGen<Emitter>::VisitUnaryExprOrTypeTraitExpr(
1085
1085
1086
1086
if (Kind == UETT_SizeOf) {
1087
1087
QualType ArgType = E->getTypeOfArgument ();
1088
+
1089
+ // C++ [expr.sizeof]p2: "When applied to a reference or a reference type,
1090
+ // the result is the size of the referenced type."
1091
+ if (const auto *Ref = ArgType->getAs <ReferenceType>())
1092
+ ArgType = Ref->getPointeeType ();
1093
+
1088
1094
CharUnits Size;
1089
1095
if (ArgType->isVoidType () || ArgType->isFunctionType ())
1090
1096
Size = CharUnits::One ();
Original file line number Diff line number Diff line change @@ -216,6 +216,8 @@ namespace PointerComparison {
216
216
}
217
217
218
218
namespace SizeOf {
219
+ static_assert (alignof (char &) == 1 );
220
+
219
221
constexpr int soint = sizeof (int );
220
222
constexpr int souint = sizeof (unsigned int );
221
223
static_assert (soint == souint, " " );
You can’t perform that action at this time.
0 commit comments