diff options
author | Arseny <ar@cs.msu.ru> | 2023-10-21 08:10:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-21 10:40:58 +0530 |
commit | 826c93f96efd8e34781c12cfcc6e7284691f6e8c (patch) | |
tree | 5b1b2505974fdefcafae10443dcf31e78d7769d3 /llvm/lib/CodeGen/MachineBasicBlock.cpp | |
parent | cb5612c99b0b8773cc8c5e1b6418b341285c5b14 (diff) | |
download | llvm-826c93f96efd8e34781c12cfcc6e7284691f6e8c.zip llvm-826c93f96efd8e34781c12cfcc6e7284691f6e8c.tar.gz llvm-826c93f96efd8e34781c12cfcc6e7284691f6e8c.tar.bz2 |
[AST] Use explicit type erasure in TypeSourceInfo constructor (#68435)
When this file is included in a project compiled with GCC 13 `-Werror`,
compilation fails with the following diagnostic:
<pre>
/usr/lib/llvm-17.0/include/clang/AST/TypeLoc.h: In constructor
'clang::TypeSourceInfo::TypeSourceInfo(clang::QualType, size_t)':
/usr/lib/llvm-17.0/include/clang/AST/TypeLoc.h:245:9: error: 'void*
memset(void*, int, size_t)' clearing an object of non-trivial type
'class clang::TypeSourceInfo'; use assignment instead
[-Werror=class-memaccess]
245 | memset(this + 1, 0, DataSize);
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
</pre>
To avoid this, we add an explicit type cast. The cast to `void*` makes
sense, since other member functions of `TypeSourceInfo` also treat the
buffer `(this + 1)` of length `DataSize` as opaque memory, and was
likely left out by mistake.
Fixes: 4498663f3de0 ("[AST] Initialized data after TypeSourceInfo")
I also suggest to apply this to release/17.x if possible.
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
0 files changed, 0 insertions, 0 deletions