efriedma added inline comments.

================
Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1131-1132
+    case CK_NullToPointer: {
+      if (llvm::Constant *C = Visit(subExpr, destType))
+        if (C->isNullValue())
+          return CGM.EmitNullConstant(destType);
----------------
nickdesaulniers wrote:
> FWIW, I would have thought these might be unnecessary, but we do trip 2 tests 
> without these guards IIRC.
The fact that the Visit can fail doesn't surprise me; you can write arbitrary 
expressions of type nullptr_t (for example, `nullptr_t f(); void* g = f();`.  I 
can't think of any reason you'd need to check C->isNullValue(), though; do you 
have a testcase for that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156175

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to