[PATCH] D45310: Warn about memcpy'ing non-trivial C structs

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 4 23:59:04 PDT 2018


ahatanak created this revision.
ahatanak added a reviewer: rjmccall.

Issue a warning when non-trivial C structs (structs with '__weak' or '__strong' fields) are copied or initialized by calls to memset, bzero, memcpy, and memmove. This is similar to gcc's -Wclass-memaccess warning. It might be better to add support for -Wclass-memaccess and make it cover both C and C++ structs that are non-trivial.

rdar://problem/36124208


Repository:
  rC Clang

https://reviews.llvm.org/D45310

Files:
  include/clang/AST/NonTrivialCStructTypeVisitor.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CGNonTrivialStruct.cpp
  lib/Sema/SemaChecking.cpp
  test/SemaObjC/warn-nontrivial-struct-memaccess.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45310.141108.patch
Type: text/x-patch
Size: 16437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180405/a69132fe/attachment.bin>


More information about the cfe-commits mailing list