Skip to content

Commit 72a38e4

Browse files
committed
test and review fixup
1 parent 274fc45 commit 72a38e4

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

clang-tools-extra/docs/clang-tidy/checks/bugprone/cast-to-struct.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ Options
5050
and casts from ``short *`` to ``struct T1 *`` (the `*` character needs to be
5151
escaped). The type name in the cast expression is matched without resolution
5252
of ``typedef`` types.
53-
54-
Default value of the option is an empty list.
53+
54+
Default value of the option is an empty string.

clang-tools-extra/test/clang-tidy/checkers/bugprone/cast-to-struct.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ typedef int * int_ptr_t;
2828

2929
struct S1 *test_simple(short *p) {
3030
return (struct S1 *)p;
31-
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: casting a 'short *' pointer to a 'struct S1 *' pointer and accessing a field can lead to memory access errors or data corruption [bugprone-cast-to-struct]
31+
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: casting a 'short *' pointer to a 'struct S1 *' pointer can lead to memory access errors or data corruption [bugprone-cast-to-struct]
3232
struct S1 *s;
3333
int i;
3434
s = (struct S1 *)&i;
35-
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: casting a 'int *' pointer to a 'struct S1 *' pointer and accessing a field can lead to memory access errors or data corruption [bugprone-cast-to-struct]
35+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: casting a 'int *' pointer to a 'struct S1 *' pointer can lead to memory access errors or data corruption [bugprone-cast-to-struct]
3636
}
3737

3838
struct S1 *test_cast_from_void(void *p) {
@@ -41,7 +41,7 @@ struct S1 *test_cast_from_void(void *p) {
4141

4242
struct S1 *test_cast_from_struct(struct S2 *p) {
4343
return (struct S1 *)p;
44-
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: casting a 'struct S2 *' pointer to a 'struct S1 *' pointer and accessing a field can lead to memory access errors or data corruption [bugprone-cast-to-struct]
44+
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: casting a 'struct S2 *' pointer to a 'struct S1 *' pointer can lead to memory access errors or data corruption [bugprone-cast-to-struct]
4545
}
4646

4747
TyPS1 test_cast_from_similar(struct S1 *p) {
@@ -50,13 +50,13 @@ TyPS1 test_cast_from_similar(struct S1 *p) {
5050

5151
void test_typedef(short *p1, int_t *p2, int_ptr_t p3) {
5252
TyS1 *a = (TyS1 *)p1;
53-
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: casting a 'short *' pointer to a 'TyS1 *' (aka 'struct S1 *') pointer and accessing a field can lead to memory access errors or data corruption [bugprone-cast-to-struct]
53+
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: casting a 'short *' pointer to a 'TyS1 *' (aka 'struct S1 *') pointer can lead to memory access errors or data corruption [bugprone-cast-to-struct]
5454
TyPS1 b = (TyPS1)p1;
55-
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: casting a 'short *' pointer to a 'TyPS1' (aka 'struct S1 *') pointer and accessing a field can lead to memory access errors or data corruption [bugprone-cast-to-struct]
55+
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: casting a 'short *' pointer to a 'TyPS1' (aka 'struct S1 *') pointer can lead to memory access errors or data corruption [bugprone-cast-to-struct]
5656
struct S1 *c = (struct S1 *)p2;
57-
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: casting a 'int_t *' (aka 'int *') pointer to a 'struct S1 *' pointer and accessing a field can lead to memory access errors or data corruption [bugprone-cast-to-struct]
57+
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: casting a 'int_t *' (aka 'int *') pointer to a 'struct S1 *' pointer can lead to memory access errors or data corruption [bugprone-cast-to-struct]
5858
struct S1 *d = (struct S1 *)p3;
59-
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: casting a 'int_ptr_t' (aka 'int *') pointer to a 'struct S1 *' pointer and accessing a field can lead to memory access errors or data corruption [bugprone-cast-to-struct]
59+
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: casting a 'int_ptr_t' (aka 'int *') pointer to a 'struct S1 *' pointer can lead to memory access errors or data corruption [bugprone-cast-to-struct]
6060
}
6161

6262
void test_union(short *p1, union U1 *p2, TyPU1 p3) {

0 commit comments

Comments
 (0)