[PATCH] D55510: [ExprConstant] Improve memchr/memcmp for type mismatch and multibyte element types

Hubert Tong via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 11 18:07:40 PST 2018


hubert.reinterpretcast marked 3 inline comments as done.
hubert.reinterpretcast added inline comments.


================
Comment at: lib/AST/ExprConstant.cpp:6147-6148
+      return ZeroInitialization(E);
+    if (!Result.checkNullPointerForFoldAccess(Info, E, AK_Read))
+      return false;
+    QualType CharTy =
----------------
rsmith wrote:
> hubert.reinterpretcast wrote:
> > rsmith wrote:
> > > Why do we need to do this explicitly, rather than allowing to simply happen as part of the first `handleLValueToRValueConversion` below?
> > We want the error message to be produced even if we bail early on not having a valid designator.
> If we have an invalid designator, we already produced a diagnostic when setting it invalid, and generally don't need to diagnose anything else.
The null pointer diagnostic does not get produced if we do not do the check here on cases like the following:
```
static_assert(__builtin_memchr((int *)0, 0, 1) == 0, "");
```



Repository:
  rC Clang

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

https://reviews.llvm.org/D55510





More information about the cfe-commits mailing list