Commit Graph

7 Commits

Author SHA1 Message Date
James Clarke 67f542aba7 [Diagnostics] Silence -Wsizeof-array-div for character buffers
Summary:
Character buffers are sometimes used to represent a pool of memory that
contains non-character objects, due to them being synonymous with a stream of
bytes on almost all modern architectures. Often, when interacting with hardware
devices, byte buffers are therefore used as an intermediary and so we can end
Character buffers are sometimes used to represent a pool of memory that
contains non-character objects, due to them being synonymous with a stream of
bytes on almost all modern architectures. Often, when interacting with hardware
devices, byte buffers are therefore used as an intermediary and so we can end
up generating lots of false-positives.

Moreover, due to the ability of character pointers to alias non-character
pointers, the strict aliasing violations that would generally be implied by the
calculations caught by the warning (if the calculation itself is in fact
correct) do not apply here, and so although the length calculation may be
wrong, that is the only possible issue.

Reviewers: rsmith, xbolva00, thakis

Reviewed By: xbolva00, thakis

Subscribers: thakis, lebedev.ri, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D68526

llvm-svn: 374035
2019-10-08 11:34:02 +00:00
David Bolvansky 116e6cf36e [Diagnostics] Avoid -Wsizeof-array-div when dividing the size of a nested array by the size of the deepest base type
llvm-svn: 372600
2019-09-23 12:54:35 +00:00
David Bolvansky b8185153f3 [Diagnostics] Added silence note for -Wsizeof-array-div; suggest extra parens
llvm-svn: 371924
2019-09-14 19:38:55 +00:00
David Bolvansky 82d9e0e122 [NFC] Added triple to test file to avoid arm buildbots failures
llvm-svn: 371646
2019-09-11 18:55:56 +00:00
David Bolvansky 3240ad4ced [Diagnostics] Add -Wsizeof-array-div
Summary: Clang version of https://www.viva64.com/en/examples/v706/

Reviewers: rsmith

Differential Revision: https://reviews.llvm.org/D67287

llvm-svn: 371605
2019-09-11 10:59:47 +00:00
David Bolvansky 454e40eaf3 [NFCI] Unbreak buildbots
llvm-svn: 371226
2019-09-06 16:30:44 +00:00
David Bolvansky d1cc181d03 [NFC] Added new tests for r371222
llvm-svn: 371223
2019-09-06 16:18:18 +00:00