[PATCH] D88336: [ubsan] nullability-arg: Fix crash on C++ member function pointers

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 25 15:49:04 PDT 2020


ahatanak added a comment.

It looks like this still doesn't check null correctly (i.e., compare to -1) for data member pointers. Is that correct?



================
Comment at: clang/lib/CodeGen/CGCall.cpp:3750
+  // Under the Itanium ABI, if the argument has member pointer type, it's a
+  // pair containing the member pointer and the required adjustment to `this`.
+  if (ArgType->isMemberPointerType() && Scalar->getType()->isStructTy())
----------------
I think it's better to make it clear in the comment that we are checking for pointers to member function, not pointers to data members.

Also, I wonder whether there is a better way to do this only for Itanium ABI. Maybe just check `ArgType->isMemberFunctionPointerType()` and add a virtual function to `CGCXXABI` which extracts the pointer field and call it here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88336



More information about the cfe-commits mailing list