[PATCH] D68526: [Diagnostics] Silence -Wsizeof-array-div for character buffers
James Clarke via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 8 04:23:50 PDT 2019
jrtc27 updated this revision to Diff 223823.
jrtc27 added a comment.
Rebased
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68526/new/
https://reviews.llvm.org/D68526
Files:
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/div-sizeof-array.cpp
Index: clang/test/Sema/div-sizeof-array.cpp
===================================================================
--- clang/test/Sema/div-sizeof-array.cpp
+++ clang/test/Sema/div-sizeof-array.cpp
@@ -25,6 +25,8 @@
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]);
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -9197,6 +9197,7 @@
QualType ArrayElemTy = ArrayTy->getElementType();
if (ArrayElemTy != S.Context.getBaseElementType(ArrayTy) ||
ArrayElemTy->isDependentType() || RHSTy->isDependentType() ||
+ ArrayElemTy->isCharType() ||
S.Context.getTypeSize(ArrayElemTy) == S.Context.getTypeSize(RHSTy))
return;
S.Diag(Loc, diag::warn_division_sizeof_array)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68526.223823.patch
Type: text/x-patch
Size: 1055 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191008/cd3609d0/attachment.bin>
More information about the cfe-commits
mailing list