Skip to content

Commit 07a8ebe

Browse files
[clang] Move warning about memset/memcpy to NonTriviallyCopyable type… (#117387)
…s to its own flag Namely -Wnontrivial-memcall, implied by -Wnontrivial-memaccess This is a followup to #111434
1 parent ddaf1d6 commit 07a8ebe

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,10 @@ Modified Compiler Flags
436436
to utilize these vector libraries. The behavior for all other vector function
437437
libraries remains unchanged.
438438

439-
- The ``-Wnontrivial-memaccess`` warning has been updated to also warn about
439+
- The ``-Wnontrivial-memcall`` warning has been added to warn about
440440
passing non-trivially-copyable destrination parameter to ``memcpy``,
441441
``memset`` and similar functions for which it is a documented undefined
442-
behavior.
442+
behavior. It is implied by ``-Wnontrivial-memaccess``
443443

444444
Removed Compiler Flags
445445
-------------------------

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,8 @@ def SizeofArrayDecay : DiagGroup<"sizeof-array-decay">;
683683
def SizeofPointerMemaccess : DiagGroup<"sizeof-pointer-memaccess">;
684684
def MemsetTransposedArgs : DiagGroup<"memset-transposed-args">;
685685
def DynamicClassMemaccess : DiagGroup<"dynamic-class-memaccess">;
686-
def NonTrivialMemaccess : DiagGroup<"nontrivial-memaccess">;
686+
def NonTrivialMemcall : DiagGroup<"nontrivial-memcall">;
687+
def NonTrivialMemaccess : DiagGroup<"nontrivial-memaccess", [NonTrivialMemcall]>;
687688
def SuspiciousBzero : DiagGroup<"suspicious-bzero">;
688689
def SuspiciousMemaccess : DiagGroup<"suspicious-memaccess",
689690
[SizeofPointerMemaccess, DynamicClassMemaccess,

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ def warn_cstruct_memaccess : Warning<
798798
def warn_cxxstruct_memaccess : Warning<
799799
"first argument in call to "
800800
"%0 is a pointer to non-trivially copyable type %1">,
801-
InGroup<NonTrivialMemaccess>;
801+
InGroup<NonTrivialMemcall>;
802802
def note_nontrivial_field : Note<
803803
"field is non-trivial to %select{copy|default-initialize}0">;
804804
def err_non_trivial_c_union_in_invalid_context : Error<

clang/test/SemaCXX/warn-memaccess.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wnontrivial-memaccess %s
1+
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wnontrivial-memcall %s
22

33
extern "C" void *bzero(void *, unsigned);
44
extern "C" void *memset(void *, int, unsigned);

0 commit comments

Comments
 (0)