[PATCH] D156175: [clang][ConstExprEmitter] handle NullToPointer ImplicitCastExpr

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 26 12:53:16 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2c26397f76d9: [clang][ConstExprEmitter] handle NullToPointer ImplicitCastExpr (authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156175/new/

https://reviews.llvm.org/D156175

Files:
  clang/lib/CodeGen/CGExprConstant.cpp


Index: clang/lib/CodeGen/CGExprConstant.cpp
===================================================================
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1131,6 +1131,10 @@
       if (const auto *S = dyn_cast<StringLiteral>(subExpr))
         return CGM.GetAddrOfConstantStringFromLiteral(S).getPointer();
       return nullptr;
+    case CK_NullToPointer:
+      if (llvm::Constant *C = Visit(subExpr, destType))
+        return CGM.EmitNullConstant(destType);
+      return nullptr;
 
     case CK_IntToOCLSampler:
       llvm_unreachable("global sampler variables are not generated");
@@ -1187,7 +1191,6 @@
     case CK_IntegralComplexToFloatingComplex:
     case CK_PointerToIntegral:
     case CK_PointerToBoolean:
-    case CK_NullToPointer:
     case CK_IntegralCast:
     case CK_BooleanToSignedIntegral:
     case CK_IntegralToPointer:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156175.544480.patch
Type: text/x-patch
Size: 889 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230726/cfe87142/attachment.bin>


More information about the cfe-commits mailing list