summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/div-sizeof-array.cpp
diff options
context:
space:
mode:
authorJames Clarke <jrtc27@jrtc27.com>2019-10-08 11:34:02 +0000
committerJames Clarke <jrtc27@jrtc27.com>2019-10-08 11:34:02 +0000
commit67f542aba72f552c4833bb253761dbcc54071016 (patch)
treee50e5165bea01f41ebb7c0f6fca32ac6c4e05ccd /clang/test/Sema/div-sizeof-array.cpp
parent8d6651f7b11ee3bc68d4e5523e44e987b53760bf (diff)
downloadbcm5719-llvm-67f542aba72f552c4833bb253761dbcc54071016.tar.gz
bcm5719-llvm-67f542aba72f552c4833bb253761dbcc54071016.zip
[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
Diffstat (limited to 'clang/test/Sema/div-sizeof-array.cpp')
-rw-r--r--clang/test/Sema/div-sizeof-array.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/test/Sema/div-sizeof-array.cpp b/clang/test/Sema/div-sizeof-array.cpp
index 7c76a5265b8..e295a9dec6d 100644
--- a/clang/test/Sema/div-sizeof-array.cpp
+++ b/clang/test/Sema/div-sizeof-array.cpp
@@ -25,6 +25,8 @@ void test(void) {
int a10 = sizeof(arr3) / sizeof(char);
int a11 = sizeof(arr2) / (sizeof(unsigned));
int a12 = sizeof(arr) / (sizeof(short));
+ int a13 = sizeof(arr3) / sizeof(p);
+ int a14 = sizeof(arr3) / sizeof(int);
int arr4[10][12];
int b1 = sizeof(arr4) / sizeof(arr2[12]);
OpenPOWER on IntegriCloud