You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: clang-tools-extra/test/clang-tidy/checkers/portability/avoid-platform-specific-fundamental-types-ints.cpp
+24-24Lines changed: 24 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -23,28 +23,28 @@ typedef unsigned long size_t;
23
23
24
24
// Test fundamental integer types that should trigger warnings
25
25
int global_int = 42;
26
-
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
26
+
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
27
27
28
28
short global_short = 10;
29
-
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'short'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
29
+
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'short'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
30
30
31
31
long global_long = 100L;
32
-
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'long'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
32
+
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'long'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
33
33
34
34
longlong global_long_long = 1000LL;
35
-
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'long long'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
35
+
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'long long'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
36
36
37
37
unsignedint global_unsigned_int = 42U;
38
-
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'unsigned int'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
38
+
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'unsigned int'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
39
39
40
40
unsignedshort global_unsigned_short = 10U;
41
-
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'unsigned short'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
41
+
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'unsigned short'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
42
42
43
43
unsignedlong global_unsigned_long = 100UL;
44
-
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'unsigned long'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
44
+
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'unsigned long'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'unsigned long long'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
47
+
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'unsigned long long'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
48
48
49
49
// Test integer that should NEVER trigger warnings
// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
71
+
// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
72
72
}
73
73
74
74
voidfunction_with_short_param(short param) {
75
-
// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: avoid using platform-dependent fundamental integer type 'short'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
75
+
// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: avoid using platform-dependent fundamental integer type 'short'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
76
76
}
77
77
78
78
// Test function return types
79
79
intfunction_returning_int() {
80
-
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
80
+
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
81
81
return42;
82
82
}
83
83
84
84
longfunction_returning_long() {
85
-
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'long'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
85
+
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: avoid using platform-dependent fundamental integer type 'long'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
86
86
return100L;
87
87
}
88
88
89
89
// Test local variables
90
90
voidtest_local_variables() {
91
91
int local_int = 10;
92
-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
92
+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
93
93
94
94
short local_short = 5;
95
-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using platform-dependent fundamental integer type 'short'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
95
+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using platform-dependent fundamental integer type 'short'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
96
96
97
97
unsignedlong local_unsigned_long = 200UL;
98
-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using platform-dependent fundamental integer type 'unsigned long'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
98
+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using platform-dependent fundamental integer type 'unsigned long'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
116
+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
117
117
118
118
long member_long;
119
-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using platform-dependent fundamental integer type 'long'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
119
+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using platform-dependent fundamental integer type 'long'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
120
120
121
121
// These should not trigger warnings
122
122
char member_char;
@@ -126,29 +126,29 @@ struct TestStruct {
126
126
classTestClass {
127
127
public:
128
128
unsignedint public_member;
129
-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using platform-dependent fundamental integer type 'unsigned int'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
129
+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using platform-dependent fundamental integer type 'unsigned int'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
130
130
131
131
private:
132
132
short private_member;
133
-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using platform-dependent fundamental integer type 'short'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
133
+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using platform-dependent fundamental integer type 'short'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
134
134
};
135
135
136
136
// Test typedefs and type aliases
137
137
typedefint MyInt;
138
-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
138
+
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
139
139
140
140
using MyLong = long;
141
-
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: avoid using platform-dependent fundamental integer type 'long'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
141
+
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: avoid using platform-dependent fundamental integer type 'long'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
142
142
143
143
typedeflonglong customType;
144
-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: avoid using platform-dependent fundamental integer type 'long long'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
144
+
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: avoid using platform-dependent fundamental integer type 'long long'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
145
145
146
146
// Test template parameters
147
147
template<typename T>
148
148
voidtemplate_function(T param) {}
149
149
150
150
template<>
151
151
void template_function<int>(int param) {
152
-
// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
153
-
// CHECK-MESSAGES: :[[@LINE-2]]:29: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a 'typedef' or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
152
+
// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
153
+
// CHECK-MESSAGES: :[[@LINE-2]]:29: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a type alias or fixed-width type instead [portability-avoid-platform-specific-fundamental-types]
0 commit comments