diff options
author | David Bolvansky <david.bolvansky@gmail.com> | 2018-08-12 17:31:46 +0000 |
---|---|---|
committer | David Bolvansky <david.bolvansky@gmail.com> | 2018-08-12 17:31:46 +0000 |
commit | a72172f4312b9fd1b4f60cc016c20094ad1af9d1 (patch) | |
tree | da60345d0490817024b28928c130f13d2c611fa2 /clang/docs/LibASTMatchersReference.html | |
parent | 01d98cc03f777054e398510d047e06a650e9d466 (diff) | |
download | bcm5719-llvm-a72172f4312b9fd1b4f60cc016c20094ad1af9d1.tar.gz bcm5719-llvm-a72172f4312b9fd1b4f60cc016c20094ad1af9d1.zip |
[Support][JSON][NFC] Silence GCC warning about broken strict aliasing rules
Summary:
The as<T>() method would trigger the following warning on GCC <7:
warning: dereferencing type-punned pointer will break
strict-aliasing rules [-Wstrict-aliasing]
return *reinterpret_cast<T *>(Union.buffer);
^
Union.buffer is guaranteed to be aligned to whatever types it contains,
and json::Value maintains the invariant that it only calls as<T>() for a
T it has previously placement-newed into Union.buffer. This should
follow the rules for strict aliasing.
Using two static_cast via void * instead of reinterpret_cast
silences the warning and presumably makes GCC understand that no
strict-aliasing violation is happening.
No functional change intended.
Patch by: kimgr (Kim Gräsman)
Reviewers: sammccall, xiangzhai, HaoLiu, llvm-commits, xbolva00
Reviewed By: sammccall, xbolva00
Subscribers: xbolva00
Differential Revision: https://reviews.llvm.org/D50608
llvm-svn: 339521
Diffstat (limited to 'clang/docs/LibASTMatchersReference.html')
0 files changed, 0 insertions, 0 deletions