[PATCH] D29530: [ubsan] Reduce null checking of C++ object pointers (PR27581)

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 9 04:30:22 PST 2017


arphaman added a comment.

Thanks!

I guess for the sake of completeness it might be useful for handle 'this' in parens as well, since it could up in macros:

  #define MEMBER(x) (x)->y
  ...
  MEMBER(this)
  ...

Btw, I was curious if we could do a similar optimization in Objective-C, but 'self' can be set to null there inside the body of a method. I guess maybe it would be possible to avoid the null check on self if we can prove it wasn't modified, but that's out of scope of this patch.



================
Comment at: lib/CodeGen/CGExprCXX.cpp:294
+  bool SkipNullCheck = false;
+  if (const auto *CMCE = dyn_cast<CXXMemberCallExpr>(CE)) {
+    SkipNullCheck =
----------------
You can avoid the '{' '}' here.


https://reviews.llvm.org/D29530





More information about the cfe-commits mailing list