Skip to content

Commit 0288499

Browse files
committed
C++: Rephrase the alert message for cpp/wrong-type-format-argument to be less prescriptive.
1 parent 5d89872 commit 0288499

File tree

8 files changed

+173
-174
lines changed

8 files changed

+173
-174
lines changed

cpp/ql/src/Likely Bugs/Format/WrongTypeFormatArguments.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,4 @@ where
172172
not arg.isFromUninstantiatedTemplate(_) and
173173
not actual.getUnspecifiedType() instanceof ErroneousType
174174
select arg,
175-
"This argument should be of type '" + expected.getName() + "' but is of type '" +
176-
actual.getUnspecifiedType().getName() + "'."
175+
"This format specifier for type '" + expected.getName() + "' does not match the argument type '" + actual.getUnspecifiedType().getName() + "'."
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
| tests.cpp:18:15:18:22 | Hello | This argument should be of type 'char *' but is of type 'char16_t *'. |
2-
| tests.cpp:19:15:19:22 | Hello | This argument should be of type 'char *' but is of type 'wchar_t *'. |
3-
| tests.cpp:21:15:21:21 | Hello | This argument should be of type 'char16_t *' but is of type 'char *'. |
4-
| tests.cpp:21:15:21:21 | Hello | This argument should be of type 'wchar_t *' but is of type 'char *'. |
5-
| tests.cpp:26:17:26:24 | Hello | This argument should be of type 'char *' but is of type 'char16_t *'. |
6-
| tests.cpp:30:17:30:24 | Hello | This argument should be of type 'wchar_t *' but is of type 'char16_t *'. |
7-
| tests.cpp:35:36:35:43 | Hello | This argument should be of type 'char *' but is of type 'wchar_t *'. |
8-
| tests.cpp:39:36:39:43 | Hello | This argument should be of type 'char16_t *' but is of type 'wchar_t *'. |
9-
| tests.cpp:42:37:42:44 | Hello | This argument should be of type 'char *' but is of type 'char16_t *'. |
10-
| tests.cpp:43:37:43:44 | Hello | This argument should be of type 'char *' but is of type 'wchar_t *'. |
11-
| tests.cpp:45:37:45:43 | Hello | This argument should be of type 'char16_t *' but is of type 'char *'. |
12-
| tests.cpp:47:37:47:44 | Hello | This argument should be of type 'char16_t *' but is of type 'wchar_t *'. |
1+
| tests.cpp:18:15:18:22 | Hello | This format specifier for type 'char *' does not match the argument type 'char16_t *'. |
2+
| tests.cpp:19:15:19:22 | Hello | This format specifier for type 'char *' does not match the argument type 'wchar_t *'. |
3+
| tests.cpp:21:15:21:21 | Hello | This format specifier for type 'char16_t *' does not match the argument type 'char *'. |
4+
| tests.cpp:21:15:21:21 | Hello | This format specifier for type 'wchar_t *' does not match the argument type 'char *'. |
5+
| tests.cpp:26:17:26:24 | Hello | This format specifier for type 'char *' does not match the argument type 'char16_t *'. |
6+
| tests.cpp:30:17:30:24 | Hello | This format specifier for type 'wchar_t *' does not match the argument type 'char16_t *'. |
7+
| tests.cpp:35:36:35:43 | Hello | This format specifier for type 'char *' does not match the argument type 'wchar_t *'. |
8+
| tests.cpp:39:36:39:43 | Hello | This format specifier for type 'char16_t *' does not match the argument type 'wchar_t *'. |
9+
| tests.cpp:42:37:42:44 | Hello | This format specifier for type 'char *' does not match the argument type 'char16_t *'. |
10+
| tests.cpp:43:37:43:44 | Hello | This format specifier for type 'char *' does not match the argument type 'wchar_t *'. |
11+
| tests.cpp:45:37:45:43 | Hello | This format specifier for type 'char16_t *' does not match the argument type 'char *'. |
12+
| tests.cpp:47:37:47:44 | Hello | This format specifier for type 'char16_t *' does not match the argument type 'wchar_t *'. |
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| tests_32.cpp:14:16:14:23 | void_ptr | This argument should be of type 'long' but is of type 'void *'. |
2-
| tests_32.cpp:15:15:15:15 | l | This argument should be of type 'void *' but is of type 'long'. |
3-
| tests_64.cpp:14:16:14:23 | void_ptr | This argument should be of type 'long' but is of type 'void *'. |
4-
| tests_64.cpp:15:15:15:15 | l | This argument should be of type 'void *' but is of type 'long'. |
1+
| tests_32.cpp:14:16:14:23 | void_ptr | This format specifier for type 'long' does not match the argument type 'void *'. |
2+
| tests_32.cpp:15:15:15:15 | l | This format specifier for type 'void *' does not match the argument type 'long'. |
3+
| tests_64.cpp:14:16:14:23 | void_ptr | This format specifier for type 'long' does not match the argument type 'void *'. |
4+
| tests_64.cpp:15:15:15:15 | l | This format specifier for type 'void *' does not match the argument type 'long'. |
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
1-
| format.h:16:59:16:61 | str | This argument should be of type 'int' but is of type 'char *'. |
2-
| format.h:16:64:16:64 | i | This argument should be of type 'double' but is of type 'int'. |
3-
| format.h:16:67:16:67 | d | This argument should be of type 'char *' but is of type 'double'. |
4-
| linux.cpp:15:24:15:41 | call to get_template_value | This argument should be of type 'int' but is of type 'long'. |
5-
| linux_c.c:11:15:11:18 | str3 | This argument should be of type 'char *' but is of type 'short *'. |
6-
| pri_macros.h:15:35:15:40 | my_u64 | This argument should be of type 'unsigned int' but is of type 'unsigned long long'. |
7-
| printf1.h:12:27:12:27 | i | This argument should be of type 'double' but is of type 'int'. |
8-
| printf1.h:18:18:18:18 | i | This argument should be of type 'void *' but is of type 'int'. |
9-
| printf1.h:25:22:25:22 | i | This argument should be of type 'char *' but is of type 'int'. |
10-
| printf1.h:27:19:27:20 | cs | This argument should be of type 'int' but is of type 'char *'. |
11-
| printf1.h:38:18:38:30 | MYONETHOUSAND | This argument should be of type 'char *' but is of type 'int'. |
12-
| printf1.h:44:18:44:20 | ull | This argument should be of type 'int' but is of type 'unsigned long long'. |
13-
| printf1.h:45:18:45:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long'. |
14-
| printf1.h:46:18:46:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long'. |
15-
| printf1.h:113:17:113:17 | d | This argument should be of type 'long double' but is of type 'double'. |
16-
| printf1.h:114:18:114:18 | d | This argument should be of type 'long double' but is of type 'double'. |
17-
| printf1.h:147:19:147:19 | i | This argument should be of type 'long long' but is of type 'int'. |
18-
| printf1.h:148:19:148:20 | ui | This argument should be of type 'unsigned long long' but is of type 'unsigned int'. |
19-
| printf1.h:160:18:160:18 | i | This argument should be of type 'char *' but is of type 'int'. |
20-
| printf1.h:161:21:161:21 | s | This argument should be of type 'int' but is of type 'char *'. |
21-
| printf1.h:167:17:167:17 | i | This argument should be of type 'char *' but is of type 'int'. |
22-
| printf1.h:168:18:168:18 | i | This argument should be of type 'char *' but is of type 'int'. |
23-
| printf1.h:169:19:169:19 | i | This argument should be of type 'char *' but is of type 'int'. |
24-
| printf1.h:174:17:174:17 | s | This argument should be of type 'int' but is of type 'char *'. |
25-
| printf1.h:175:18:175:18 | s | This argument should be of type 'int' but is of type 'char *'. |
26-
| printf1.h:176:19:176:19 | s | This argument should be of type 'int' but is of type 'char *'. |
27-
| printf1.h:180:17:180:17 | s | This argument should be of type 'int' but is of type 'char *'. |
28-
| printf1.h:181:20:181:20 | i | This argument should be of type 'char *' but is of type 'int'. |
29-
| printf1.h:183:18:183:18 | s | This argument should be of type 'int' but is of type 'char *'. |
30-
| printf1.h:184:21:184:21 | i | This argument should be of type 'char *' but is of type 'int'. |
31-
| printf1.h:186:19:186:19 | s | This argument should be of type 'int' but is of type 'char *'. |
32-
| printf1.h:187:22:187:22 | i | This argument should be of type 'char *' but is of type 'int'. |
33-
| printf1.h:189:19:189:19 | s | This argument should be of type 'int' but is of type 'char *'. |
34-
| printf1.h:190:22:190:22 | i | This argument should be of type 'char *' but is of type 'int'. |
35-
| printf1.h:192:19:192:19 | s | This argument should be of type 'int' but is of type 'char *'. |
36-
| printf1.h:193:22:193:22 | s | This argument should be of type 'int' but is of type 'char *'. |
37-
| printf1.h:194:25:194:25 | i | This argument should be of type 'char *' but is of type 'int'. |
38-
| printf1.h:198:24:198:24 | s | This argument should be of type 'int' but is of type 'char *'. |
39-
| printf1.h:199:21:199:21 | i | This argument should be of type 'char *' but is of type 'int'. |
40-
| printf1.h:202:26:202:26 | s | This argument should be of type 'int' but is of type 'char *'. |
41-
| printf1.h:203:23:203:23 | i | This argument should be of type 'char *' but is of type 'int'. |
42-
| printf1.h:206:25:206:25 | s | This argument should be of type 'int' but is of type 'char *'. |
43-
| printf1.h:207:22:207:22 | i | This argument should be of type 'char *' but is of type 'int'. |
44-
| printf1.h:210:26:210:26 | s | This argument should be of type 'int' but is of type 'char *'. |
45-
| printf1.h:211:23:211:23 | i | This argument should be of type 'char *' but is of type 'int'. |
46-
| printf1.h:214:28:214:28 | s | This argument should be of type 'int' but is of type 'char *'. |
47-
| printf1.h:215:28:215:28 | s | This argument should be of type 'int' but is of type 'char *'. |
48-
| printf1.h:216:25:216:25 | i | This argument should be of type 'char *' but is of type 'int'. |
49-
| printf1.h:221:18:221:18 | s | This argument should be of type 'int' but is of type 'char *'. |
50-
| printf1.h:222:20:222:20 | s | This argument should be of type 'int' but is of type 'char *'. |
51-
| printf1.h:225:23:225:23 | i | This argument should be of type 'char *' but is of type 'int'. |
52-
| printf1.h:228:24:228:24 | i | This argument should be of type 'char *' but is of type 'int'. |
53-
| printf1.h:231:25:231:25 | i | This argument should be of type 'char *' but is of type 'int'. |
54-
| printf1.h:234:25:234:25 | i | This argument should be of type 'char *' but is of type 'int'. |
55-
| printf1.h:235:22:235:22 | s | This argument should be of type 'int' but is of type 'char *'. |
56-
| printf1.h:276:32:276:32 | s | This argument should be of type 'int' but is of type 'char *'. |
57-
| printf1.h:278:17:278:17 | s | This argument should be of type 'int' but is of type 'char *'. |
58-
| real_world.h:61:21:61:22 | & ... | This argument should be of type 'int *' but is of type 'short *'. |
59-
| real_world.h:62:22:62:23 | & ... | This argument should be of type 'short *' but is of type 'int *'. |
60-
| real_world.h:63:22:63:24 | & ... | This argument should be of type 'short *' but is of type 'unsigned int *'. |
61-
| real_world.h:64:22:64:24 | & ... | This argument should be of type 'short *' but is of type 'signed int *'. |
62-
| wide_string.h:25:18:25:20 | c | This argument should be of type 'char' but is of type 'char *'. |
1+
| format.h:16:59:16:61 | str | This format specifier for type 'int' does not match the argument type 'char *'. |
2+
| format.h:16:64:16:64 | i | This format specifier for type 'double' does not match the argument type 'int'. |
3+
| format.h:16:67:16:67 | d | This format specifier for type 'char *' does not match the argument type 'double'. |
4+
| linux.cpp:15:24:15:41 | call to get_template_value | This format specifier for type 'int' does not match the argument type 'long'. |
5+
| linux_c.c:11:15:11:18 | str3 | This format specifier for type 'char *' does not match the argument type 'short *'. |
6+
| pri_macros.h:15:35:15:40 | my_u64 | This format specifier for type 'unsigned int' does not match the argument type 'unsigned long long'. |
7+
| printf1.h:12:27:12:27 | i | This format specifier for type 'double' does not match the argument type 'int'. |
8+
| printf1.h:18:18:18:18 | i | This format specifier for type 'void *' does not match the argument type 'int'. |
9+
| printf1.h:25:22:25:22 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
10+
| printf1.h:27:19:27:20 | cs | This format specifier for type 'int' does not match the argument type 'char *'. |
11+
| printf1.h:38:18:38:30 | MYONETHOUSAND | This format specifier for type 'char *' does not match the argument type 'int'. |
12+
| printf1.h:44:18:44:20 | ull | This format specifier for type 'int' does not match the argument type 'unsigned long long'. |
13+
| printf1.h:45:18:45:20 | ull | This format specifier for type 'unsigned int' does not match the argument type 'unsigned long long'. |
14+
| printf1.h:46:18:46:20 | ull | This format specifier for type 'unsigned int' does not match the argument type 'unsigned long long'. |
15+
| printf1.h:113:17:113:17 | d | This format specifier for type 'long double' does not match the argument type 'double'. |
16+
| printf1.h:114:18:114:18 | d | This format specifier for type 'long double' does not match the argument type 'double'. |
17+
| printf1.h:147:19:147:19 | i | This format specifier for type 'long long' does not match the argument type 'int'. |
18+
| printf1.h:148:19:148:20 | ui | This format specifier for type 'unsigned long long' does not match the argument type 'unsigned int'. |
19+
| printf1.h:160:18:160:18 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
20+
| printf1.h:161:21:161:21 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
21+
| printf1.h:167:17:167:17 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
22+
| printf1.h:168:18:168:18 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
23+
| printf1.h:169:19:169:19 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
24+
| printf1.h:174:17:174:17 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
25+
| printf1.h:175:18:175:18 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
26+
| printf1.h:176:19:176:19 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
27+
| printf1.h:180:17:180:17 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
28+
| printf1.h:181:20:181:20 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
29+
| printf1.h:183:18:183:18 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
30+
| printf1.h:184:21:184:21 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
31+
| printf1.h:186:19:186:19 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
32+
| printf1.h:187:22:187:22 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
33+
| printf1.h:189:19:189:19 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
34+
| printf1.h:190:22:190:22 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
35+
| printf1.h:192:19:192:19 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
36+
| printf1.h:193:22:193:22 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
37+
| printf1.h:194:25:194:25 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
38+
| printf1.h:198:24:198:24 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
39+
| printf1.h:199:21:199:21 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
40+
| printf1.h:202:26:202:26 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
41+
| printf1.h:203:23:203:23 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
42+
| printf1.h:206:25:206:25 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
43+
| printf1.h:207:22:207:22 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
44+
| printf1.h:210:26:210:26 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
45+
| printf1.h:211:23:211:23 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
46+
| printf1.h:214:28:214:28 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
47+
| printf1.h:215:28:215:28 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
48+
| printf1.h:216:25:216:25 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
49+
| printf1.h:221:18:221:18 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
50+
| printf1.h:222:20:222:20 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
51+
| printf1.h:225:23:225:23 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
52+
| printf1.h:228:24:228:24 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
53+
| printf1.h:231:25:231:25 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
54+
| printf1.h:234:25:234:25 | i | This format specifier for type 'char *' does not match the argument type 'int'. |
55+
| printf1.h:235:22:235:22 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
56+
| printf1.h:276:32:276:32 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
57+
| printf1.h:278:17:278:17 | s | This format specifier for type 'int' does not match the argument type 'char *'. |
58+
| real_world.h:61:21:61:22 | & ... | This format specifier for type 'int *' does not match the argument type 'short *'. |
59+
| real_world.h:62:22:62:23 | & ... | This format specifier for type 'short *' does not match the argument type 'int *'. |
60+
| real_world.h:63:22:63:24 | & ... | This format specifier for type 'short *' does not match the argument type 'unsigned int *'. |
61+
| real_world.h:64:22:64:24 | & ... | This format specifier for type 'short *' does not match the argument type 'signed int *'. |
62+
| wide_string.h:25:18:25:20 | c | This format specifier for type 'char' does not match the argument type 'char *'. |
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| printf.cpp:43:29:43:35 | test | This argument should be of type 'char *' but is of type 'char16_t *'. |
2-
| printf.cpp:50:29:50:35 | test | This argument should be of type 'char16_t *' but is of type 'wchar_t *'. |
1+
| printf.cpp:43:29:43:35 | test | This format specifier for type 'char *' does not match the argument type 'char16_t *'. |
2+
| printf.cpp:50:29:50:35 | test | This format specifier for type 'char16_t *' does not match the argument type 'wchar_t *'. |

0 commit comments

Comments
 (0)