[PATCH] D49589: [UBSan] Strengthen pointer checks in 'new' expressions

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 19 22:24:20 PDT 2018


sepavloff created this revision.
sepavloff added reviewers: rsmith, rjmccall, ikudrin.

With this change compiler generates alignment checks for wider range
of types. Previously such checks were generated only for the record types
with non-trivial default constructor. So the types like:

  struct alignas(32) S2 { int x; };
  typedef __attribute__((ext_vector_type(2), aligned(32))) float float32x2_t;

did not get checks when allocated by 'new' expression.

This change also optimizes the checks generated for the arrays created
in 'new' expressions. Previously the check was generated for each
invocation of type constructor. Now the check is generated only once
for entire array.


Repository:
  rC Clang

https://reviews.llvm.org/D49589

Files:
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/ubsan-new-checks.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49589.156428.patch
Type: text/x-patch
Size: 4718 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180720/bb924339/attachment.bin>


More information about the cfe-commits mailing list