r368610 - [Sema] Check __builtin_bit_cast operand for completeness before materializing it.

Erik Pilkington via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 12 12:29:44 PDT 2019


Author: epilk
Date: Mon Aug 12 12:29:43 2019
New Revision: 368610

URL: http://llvm.org/viewvc/llvm-project?rev=368610&view=rev
Log:
[Sema] Check __builtin_bit_cast operand for completeness before materializing it.

This shouldn't be observable, but it doesn't make sense to materialize an
incomplete type.

Modified:
    cfe/trunk/lib/Sema/SemaCast.cpp

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=368610&r1=368609&r2=368610&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Mon Aug 12 12:29:43 2019
@@ -2799,9 +2799,6 @@ void CastOperation::CheckCStyleCast() {
 
 void CastOperation::CheckBuiltinBitCast() {
   QualType SrcType = SrcExpr.get()->getType();
-  if (SrcExpr.get()->isRValue())
-    SrcExpr = Self.CreateMaterializeTemporaryExpr(SrcType, SrcExpr.get(),
-                                                  /*IsLValueReference=*/false);
 
   if (Self.RequireCompleteType(OpRange.getBegin(), DestType,
                                diag::err_typecheck_cast_to_incomplete) ||
@@ -2811,6 +2808,10 @@ void CastOperation::CheckBuiltinBitCast(
     return;
   }
 
+  if (SrcExpr.get()->isRValue())
+    SrcExpr = Self.CreateMaterializeTemporaryExpr(SrcType, SrcExpr.get(),
+                                                  /*IsLValueReference=*/false);
+
   CharUnits DestSize = Self.Context.getTypeSizeInChars(DestType);
   CharUnits SourceSize = Self.Context.getTypeSizeInChars(SrcType);
   if (DestSize != SourceSize) {




More information about the cfe-commits mailing list