Skip to content

Commit a9f4dd4

Browse files
committed
A1-1-1: restrict to type mentions
1 parent b128546 commit a9f4dd4

File tree

6 files changed

+49
-20
lines changed

6 files changed

+49
-20
lines changed

.vscode/settings.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"sarif-viewer.connectToGithubCodeScanning": "off",
3+
"codeQL.cli.executablePath": "/Users/mauro/GitHub/coding-standards/codeql-bundle-20220908/codeql",
4+
"codeQL.runningQueries.numberOfThreads": 0,
5+
"codeQL.runningTests.numberOfThreads": 0,
6+
"codeQL.runningQueries.autoSave": true,
7+
"codeQL.runningQueries.debug": true,
8+
"files.associations": {
9+
"*.jq": "json",
10+
"*.py": "python",
11+
"*.expected": "csv (pipe)",
12+
"*.actual": "csv (pipe)",
13+
"*.qls": "yaml",
14+
"*.qcc": "cpp",
15+
"*.gcc": "cpp",
16+
"iosfwd": "cpp",
17+
"fstream": "cpp",
18+
"iostream": "cpp"
19+
}
20+
}

cpp/autosar/src/rules/A1-1-1/StrstreamTypesAreDeprecated.ql

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414

1515
import cpp
1616
import codingstandards.cpp.autosar
17-
import codingstandards.cpp.TypeUses
1817

19-
from Class c, Locatable l
18+
from TypeMention l, Class c
2019
where
2120
not isExcluded(l, ToolchainPackage::strstreamTypesAreDeprecatedQuery()) and
2221
c.hasQualifiedName("std", ["strstreambuf", "ostrstream", "istrstream"]) and
23-
exists(Type t | t = c | l = getATypeUse(t))
24-
select l, "Use of <strstream> class '" + c.getQualifiedName() + "' is deprecated."
22+
l.getMentionedType() = c
23+
select l, "Use of <strstream> class '" + c.getName() + "' is deprecated."
Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
| StrstreamTypesAreDeprecated.cpp:4:21:4:21 | x | Use of <strstream> class 'std::strstreambuf' is deprecated. |
2-
| StrstreamTypesAreDeprecated.cpp:7:20:7:21 | f1 | Use of <strstream> class 'std::strstreambuf' is deprecated. |
3-
| StrstreamTypesAreDeprecated.cpp:12:19:12:20 | i1 | Use of <strstream> class 'std::istrstream' is deprecated. |
4-
| StrstreamTypesAreDeprecated.cpp:12:22:12:27 | call to istrstream | Use of <strstream> class 'std::istrstream' is deprecated. |
5-
| StrstreamTypesAreDeprecated.cpp:14:19:14:20 | i2 | Use of <strstream> class 'std::istrstream' is deprecated. |
6-
| StrstreamTypesAreDeprecated.cpp:14:22:14:23 | call to istrstream | Use of <strstream> class 'std::istrstream' is deprecated. |
7-
| StrstreamTypesAreDeprecated.cpp:16:19:16:20 | i3 | Use of <strstream> class 'std::istrstream' is deprecated. |
8-
| StrstreamTypesAreDeprecated.cpp:16:22:16:37 | call to istrstream | Use of <strstream> class 'std::istrstream' is deprecated. |
9-
| StrstreamTypesAreDeprecated.cpp:19:18:19:19 | f2 | Use of <strstream> class 'std::istrstream' is deprecated. |
10-
| StrstreamTypesAreDeprecated.cpp:20:10:20:31 | call to istrstream | Use of <strstream> class 'std::istrstream' is deprecated. |
11-
| StrstreamTypesAreDeprecated.cpp:24:19:24:19 | call to ostrstream | Use of <strstream> class 'std::ostrstream' is deprecated. |
12-
| StrstreamTypesAreDeprecated.cpp:24:19:24:19 | o | Use of <strstream> class 'std::ostrstream' is deprecated. |
13-
| StrstreamTypesAreDeprecated.cpp:27:18:27:19 | f3 | Use of <strstream> class 'std::ostrstream' is deprecated. |
14-
| StrstreamTypesAreDeprecated.cpp:28:10:28:30 | call to ostrstream | Use of <strstream> class 'std::ostrstream' is deprecated. |
1+
| StrstreamTypesAreDeprecated.cpp:4:8:4:19 | type mention | Use of <strstream> class 'strstreambuf' is deprecated. |
2+
| StrstreamTypesAreDeprecated.cpp:7:6:7:17 | type mention | Use of <strstream> class 'strstreambuf' is deprecated. |
3+
| StrstreamTypesAreDeprecated.cpp:8:19:8:30 | type mention | Use of <strstream> class 'strstreambuf' is deprecated. |
4+
| StrstreamTypesAreDeprecated.cpp:12:8:12:17 | type mention | Use of <strstream> class 'istrstream' is deprecated. |
5+
| StrstreamTypesAreDeprecated.cpp:14:8:14:17 | type mention | Use of <strstream> class 'istrstream' is deprecated. |
6+
| StrstreamTypesAreDeprecated.cpp:16:8:16:17 | type mention | Use of <strstream> class 'istrstream' is deprecated. |
7+
| StrstreamTypesAreDeprecated.cpp:19:6:19:15 | type mention | Use of <strstream> class 'istrstream' is deprecated. |
8+
| StrstreamTypesAreDeprecated.cpp:20:19:20:28 | type mention | Use of <strstream> class 'istrstream' is deprecated. |
9+
| StrstreamTypesAreDeprecated.cpp:24:8:24:17 | type mention | Use of <strstream> class 'ostrstream' is deprecated. |
10+
| StrstreamTypesAreDeprecated.cpp:27:6:27:15 | type mention | Use of <strstream> class 'ostrstream' is deprecated. |
11+
| StrstreamTypesAreDeprecated.cpp:28:19:28:28 | type mention | Use of <strstream> class 'ostrstream' is deprecated. |
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
| test.cpp:9:13:9:21 | call to bind | Prefer lambdas to using std::__1::bind. |
2+
| test.cpp:10:13:10:24 | call to bind1st | Prefer lambdas to using std::__1::bind1st. |
3+
| test.cpp:11:13:11:24 | call to bind2nd | Prefer lambdas to using std::__1::bind2nd. |
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
| test.cpp:10:39:10:48 | call to __wrap_iter | Non-const version of container call immediately converted to a `const_iterator`. |
2+
| test.cpp:13:38:13:42 | call to begin | Non-const version of container call immediately converted to a `const_iterator`. |
3+
| test.cpp:16:44:16:48 | call to begin | Non-const version of container call immediately converted to a `const_iterator`. |
4+
| test.cpp:19:41:19:50 | call to __map_const_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
5+
| test.cpp:22:47:22:57 | call to __map_const_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
6+
| test.cpp:25:8:25:16 | call to __wrap_iter | Non-const version of container call immediately converted to a `const_iterator`. |
7+
| test.cpp:27:10:27:14 | call to begin | Non-const version of container call immediately converted to a `const_iterator`. |
8+
| test.cpp:29:11:29:15 | call to begin | Non-const version of container call immediately converted to a `const_iterator`. |
9+
| test.cpp:31:8:31:16 | call to __map_const_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
10+
| test.cpp:33:9:33:18 | call to __map_const_iterator | Non-const version of container call immediately converted to a `const_iterator`. |
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
| test.cpp:7:9:7:19 | setjmp(__env) | Use of banned setjmp macro. |
2-
| test.cpp:12:3:12:9 | longjmp(__env,__val) | Use of banned longjmp function. |
3-
| test.cpp:14:3:14:9 | longjmp(__env,__val) | Use of banned longjmp function. |
2+
| test.cpp:12:3:12:19 | longjmp(__env,__val) | Use of banned longjmp function. |
3+
| test.cpp:14:3:14:19 | longjmp(__env,__val) | Use of banned longjmp function. |
44
| test.cpp:16:9:16:19 | setjmp(__env) | Use of banned setjmp macro. |

0 commit comments

Comments
 (0)