[PATCH] D87755: Silence GCC's `-Wclass-memaccess` warnings
Chandler Carruth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 03:33:28 PDT 2020
chandlerc created this revision.
Herald added subscribers: llvm-commits, rupprecht, hiraditya, mcrosier, MatzeB.
Herald added a reviewer: jhenderson.
Herald added a project: LLVM.
chandlerc requested review of this revision.
Herald added a subscriber: MaskRay.
For folks hosting with GCC, this warning is especially annoying. It is
difficult to disable on the command line in all build systems because it
is a C++ specific warning. Disabling it produces still more warnings on
C code.
Suppressing the warning can be done easily by casting the pointer to
`void *`, but I'm also happy with any other suggested approach to
silence this warning in the source code.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87755
Files:
llvm/lib/CodeGen/RegisterPressure.cpp
llvm/lib/ExecutionEngine/ExecutionEngine.cpp
llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
llvm/tools/llvm-nm/llvm-nm.cpp
Index: llvm/tools/llvm-nm/llvm-nm.cpp
===================================================================
--- llvm/tools/llvm-nm/llvm-nm.cpp
+++ llvm/tools/llvm-nm/llvm-nm.cpp
@@ -1636,7 +1636,7 @@
if (!found) {
LastSymbolName = Entry.symbolName();
NMSymbol W;
- memset(&W, '\0', sizeof(NMSymbol));
+ memset((void *)&W, '\0', sizeof(NMSymbol));
W.Name = Entry.symbolName();
W.Address = 0;
W.Size = 0;
Index: llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
===================================================================
--- llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
+++ llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
@@ -1717,7 +1717,7 @@
CommentStream = &CStream;
InternalInstruction Insn;
- memset(&Insn, 0, sizeof(InternalInstruction));
+ memset((void *)&Insn, 0, sizeof(InternalInstruction));
Insn.bytes = Bytes;
Insn.startLocation = Address;
Insn.readerCursor = Address;
Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
===================================================================
--- llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -1044,7 +1044,7 @@
*((double*)Ptr) = Val.DoubleVal;
break;
case Type::X86_FP80TyID:
- memcpy(Ptr, Val.IntVal.getRawData(), 10);
+ memcpy((void *)Ptr, Val.IntVal.getRawData(), 10);
break;
case Type::PointerTyID:
// Ensure 64 bit target pointers are fully initialized on 32 bit hosts.
Index: llvm/lib/CodeGen/RegisterPressure.cpp
===================================================================
--- llvm/lib/CodeGen/RegisterPressure.cpp
+++ llvm/lib/CodeGen/RegisterPressure.cpp
@@ -646,7 +646,7 @@
void PressureDiffs::init(unsigned N) {
Size = N;
if (N <= Max) {
- memset(PDiffArray, 0, N * sizeof(PressureDiff));
+ memset((void *)PDiffArray, 0, N * sizeof(PressureDiff));
return;
}
Max = Size;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87755.292168.patch
Type: text/x-patch
Size: 1977 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200916/2ceaed35/attachment.bin>
More information about the llvm-commits
mailing list