Skip to content

Commit 456931b

Browse files
committed
gcc-parser: extend the regex for Cppcheck events
... to accept numbers in checker IDs Reported-by: Steve Grubb
1 parent 0bb7083 commit 456931b

File tree

5 files changed

+172
-1
lines changed

5 files changed

+172
-1
lines changed

src/gcc-parser.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ class BasicGccParser {
399399
bool exportAndReset(Defect *pDef);
400400

401401
const RE reCppcheck_ =
402-
RE("^([A-Za-z_]+)(?:\\(CWE-([0-9]+)\\))?: (.*)$");
402+
RE("^([0-9A-Za-z_]+)(?:\\(CWE-([0-9]+)\\))?: (.*)$");
403403

404404
const RE reClang_ =
405405
RE("^clang.*$");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--mode=json
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/builddir/build/BUILD/libprelude-5.2.0/bindings/ruby/Prelude.cxx: In function 'int IDMEFValue_to_SWIG(VALUE, const Prelude::IDMEFValue&, void*, VALUE*)': <--[g++]
2+
/builddir/build/BUILD/libprelude-5.2.0/bindings/ruby/Prelude.cxx:4659:58: warning: enum constant in boolean context [-Wint-in-bool-context] <--[g++]
3+
4659 | else if ( t == IDMEF_DATA_TYPE_UINT32 || IDMEF_DATA_TYPE_INT )
4+
| ^~~~~~~~~~~~~~~~~~~
5+
/builddir/build/BUILD/libprelude-5.2.0/bindings/ruby/Prelude.cxx:3144: error: invalidIterator1(CWE-664): Invalid iterator: sb <--[cppcheck]
6+
/builddir/build/BUILD/libprelude-5.2.0/bindings/ruby/Prelude.cxx:2487: error: uninitvar(CWE-457): Uninitialized variable: v <--[cppcheck]
7+
/builddir/build/BUILD/libpmemobj-cpp-1.12/tests/concurrent_hash_map/concurrent_hash_map_layout.cpp: internal warning: child 13758 timed out after 30s <--[cppcheck]
8+
/builddir/build/BUILD/libpmemobj-cpp-1.12/tests/external/libcxx/array/iterators.pass.cpp:149: warning: mismatchingContainerExpression(CWE-664): Iterators to containers from different expressions 'static_cast<const pmem::obj::array < int , 5 >&>(c)' and 'c' are used together. <--[cppcheck]
9+
/builddir/build/BUILD/libpmemobj-cpp-1.12/tests/external/libcxx/array/iterators.pass.cpp:156: warning: mismatchingContainerExpression(CWE-664): Iterators to containers from different expressions 'static_cast<const pmem::obj::array < int , 5 >&>(c)' and 'c' are used together. <--[cppcheck]
10+
/builddir/build/BUILD/libpmemobj-cpp-1.12/tests/external/libcxx/basic_string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp: internal warning: child 19752 timed out after 30s <--[cppcheck]
11+
/builddir/build/BUILD/libpmemobj-cpp-1.12/tests/external/libcxx/vector/vector.cons/move.pass.cpp:85: error: iterators1(CWE-664): Same iterator is used with different containers 'r.c1' and 'r.c2'. <--[cppcheck]
12+
/builddir/build/BUILD/libpmemobj-cpp-1.12/tests/external/libcxx/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp: internal warning: child 29213 timed out after 30s <--[clang++]
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
{
2+
"defects": [
3+
{
4+
"checker": "COMPILER_WARNING",
5+
"language": "c/c++",
6+
"key_event_idx": 1,
7+
"events": [
8+
{
9+
"file_name": "/builddir/build/BUILD/libprelude-5.2.0/bindings/ruby/Prelude.cxx",
10+
"line": 0,
11+
"event": "scope_hint",
12+
"message": "In function 'int IDMEFValue_to_SWIG(VALUE, const Prelude::IDMEFValue&, void*, VALUE*)'",
13+
"verbosity_level": "1"
14+
},
15+
{
16+
"file_name": "/builddir/build/BUILD/libprelude-5.2.0/bindings/ruby/Prelude.cxx",
17+
"line": 4659,
18+
"column": 58,
19+
"event": "warning[-Wint-in-bool-context]",
20+
"message": "enum constant in boolean context",
21+
"verbosity_level": "0"
22+
},
23+
{
24+
"file_name": "",
25+
"line": 0,
26+
"event": "#",
27+
"message": " 4659 | else if ( t == IDMEF_DATA_TYPE_UINT32 || IDMEF_DATA_TYPE_INT )",
28+
"verbosity_level": "1"
29+
},
30+
{
31+
"file_name": "",
32+
"line": 0,
33+
"event": "#",
34+
"message": " | ^~~~~~~~~~~~~~~~~~~",
35+
"verbosity_level": "1"
36+
}
37+
]
38+
},
39+
{
40+
"checker": "CPPCHECK_WARNING",
41+
"cwe": 664,
42+
"language": "c/c++",
43+
"key_event_idx": 0,
44+
"events": [
45+
{
46+
"file_name": "/builddir/build/BUILD/libprelude-5.2.0/bindings/ruby/Prelude.cxx",
47+
"line": 3144,
48+
"event": "error[invalidIterator1]",
49+
"message": "Invalid iterator: sb",
50+
"verbosity_level": "0"
51+
}
52+
]
53+
},
54+
{
55+
"checker": "CPPCHECK_WARNING",
56+
"cwe": 457,
57+
"language": "c/c++",
58+
"key_event_idx": 0,
59+
"events": [
60+
{
61+
"file_name": "/builddir/build/BUILD/libprelude-5.2.0/bindings/ruby/Prelude.cxx",
62+
"line": 2487,
63+
"event": "error[uninitvar]",
64+
"message": "Uninitialized variable: v",
65+
"verbosity_level": "0"
66+
}
67+
]
68+
},
69+
{
70+
"checker": "CPPCHECK_WARNING",
71+
"language": "c/c++",
72+
"key_event_idx": 0,
73+
"events": [
74+
{
75+
"file_name": "/builddir/build/BUILD/libpmemobj-cpp-1.12/tests/concurrent_hash_map/concurrent_hash_map_layout.cpp",
76+
"line": 0,
77+
"event": "internal warning",
78+
"message": "child 13758 timed out after 30s",
79+
"verbosity_level": "0"
80+
}
81+
]
82+
},
83+
{
84+
"checker": "CPPCHECK_WARNING",
85+
"cwe": 664,
86+
"language": "c/c++",
87+
"key_event_idx": 0,
88+
"events": [
89+
{
90+
"file_name": "/builddir/build/BUILD/libpmemobj-cpp-1.12/tests/external/libcxx/array/iterators.pass.cpp",
91+
"line": 149,
92+
"event": "warning[mismatchingContainerExpression]",
93+
"message": "Iterators to containers from different expressions 'static_cast<const pmem::obj::array < int , 5 >&>(c)' and 'c' are used together.",
94+
"verbosity_level": "0"
95+
}
96+
]
97+
},
98+
{
99+
"checker": "CPPCHECK_WARNING",
100+
"cwe": 664,
101+
"language": "c/c++",
102+
"key_event_idx": 0,
103+
"events": [
104+
{
105+
"file_name": "/builddir/build/BUILD/libpmemobj-cpp-1.12/tests/external/libcxx/array/iterators.pass.cpp",
106+
"line": 156,
107+
"event": "warning[mismatchingContainerExpression]",
108+
"message": "Iterators to containers from different expressions 'static_cast<const pmem::obj::array < int , 5 >&>(c)' and 'c' are used together.",
109+
"verbosity_level": "0"
110+
}
111+
]
112+
},
113+
{
114+
"checker": "CPPCHECK_WARNING",
115+
"language": "c/c++",
116+
"key_event_idx": 0,
117+
"events": [
118+
{
119+
"file_name": "/builddir/build/BUILD/libpmemobj-cpp-1.12/tests/external/libcxx/basic_string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp",
120+
"line": 0,
121+
"event": "internal warning",
122+
"message": "child 19752 timed out after 30s",
123+
"verbosity_level": "0"
124+
}
125+
]
126+
},
127+
{
128+
"checker": "CPPCHECK_WARNING",
129+
"cwe": 664,
130+
"language": "c/c++",
131+
"key_event_idx": 0,
132+
"events": [
133+
{
134+
"file_name": "/builddir/build/BUILD/libpmemobj-cpp-1.12/tests/external/libcxx/vector/vector.cons/move.pass.cpp",
135+
"line": 85,
136+
"event": "error[iterators1]",
137+
"message": "Same iterator is used with different containers 'r.c1' and 'r.c2'.",
138+
"verbosity_level": "0"
139+
}
140+
]
141+
},
142+
{
143+
"checker": "CLANG_WARNING",
144+
"language": "c/c++",
145+
"key_event_idx": 0,
146+
"events": [
147+
{
148+
"file_name": "/builddir/build/BUILD/libpmemobj-cpp-1.12/tests/external/libcxx/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp",
149+
"line": 0,
150+
"event": "internal warning",
151+
"message": "child 29213 timed out after 30s",
152+
"verbosity_level": "0"
153+
}
154+
]
155+
}
156+
]
157+
}

tests/csgrep/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,4 @@ test_csgrep("64-json-parser-unknown-node" )
111111
test_csgrep("65-gcc-parser-clang-warn-suff" )
112112
test_csgrep("66-json-parser-valgrind-dedup" )
113113
test_csgrep("67-json-parser-valgrind-dedup" )
114+
test_csgrep("68-gcc-parser-cppcheck-iterator1" )

0 commit comments

Comments
 (0)