Skip to content

Commit 1d1e41c

Browse files
committed
Improve precision alert message
We know explicitly mention the missing actions in the alert message.
1 parent 945d67a commit 1d1e41c

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

cpp/autosar/src/rules/A12-8-6/CopyAndMoveNotDeclaredProtected.ql

+14-14
Original file line numberDiff line numberDiff line change
@@ -16,49 +16,49 @@ import cpp
1616
import codingstandards.cpp.autosar
1717
import codingstandards.cpp.Class
1818

19-
predicate isInvalidConstructor(Constructor f, string constructorType) {
19+
predicate isInvalidConstructor(Constructor f, string constructorType, string missingAction) {
2020
not f.isDeleted() and
2121
not f.isProtected() and
2222
(
2323
f instanceof MoveConstructor and
2424
if f.isCompilerGenerated()
25-
then constructorType = "Implicit move constructor"
26-
else constructorType = "Move constructor"
25+
then constructorType = "Implicit move constructor" and missingAction = "deleted"
26+
else (constructorType = "Move constructor" and missingAction = "protected")
2727
or
2828
f instanceof CopyConstructor and
2929
if f.isCompilerGenerated()
30-
then constructorType = "Implicit copy constructor"
31-
else constructorType = "Copy constructor"
30+
then constructorType = "Implicit copy constructor" and missingAction = "deleted"
31+
else (constructorType = "Copy constructor" and missingAction = "protected")
3232
)
3333
}
3434

35-
predicate isInvalidAssignment(Operator f, string operatorType) {
35+
predicate isInvalidAssignment(Operator f, string operatorType, string missingAction) {
3636
not f.isDeleted() and
3737
(
3838
f instanceof MoveAssignmentOperator and
3939
if f.isCompilerGenerated()
40-
then operatorType = "Implicit move assignment operator"
41-
else operatorType = "Move constructor"
40+
then operatorType = "Implicit move assignment operator" and missingAction = "deleted"
41+
else (operatorType = "Move assignment operator" and missingAction = "protected")
4242
or
4343
f instanceof CopyAssignmentOperator and
4444
if f.isCompilerGenerated()
45-
then operatorType = "Implicit copy assignment operator"
46-
else operatorType = "Copy assignment operator"
45+
then operatorType = "Implicit copy assignment operator" and missingAction = "deleted"
46+
else (operatorType = "Copy assignment operator" and missingAction = "protected")
4747
) and
4848
not f.hasSpecifier("protected")
4949
}
5050

51-
from BaseClass baseClass, MemberFunction mf, string type
51+
from BaseClass baseClass, MemberFunction mf, string type, string missingAction
5252
where
5353
not isExcluded(mf, OperatorsPackage::copyAndMoveNotDeclaredProtectedQuery()) and
5454
(
55-
isInvalidConstructor(mf, type)
55+
isInvalidConstructor(mf, type, missingAction)
5656
or
57-
isInvalidAssignment(mf, type)
57+
isInvalidAssignment(mf, type, missingAction)
5858
) and
5959
baseClass = mf.getDeclaringType()
6060
// To avoid duplicate alerts due to inaccurate location information in the database we don't use the location of the base class.
6161
// This for example happens if multiple copies of the same header file are present in the database.
6262
select getDeclarationEntryInClassDeclaration(mf),
6363
type + " for base class '" + baseClass.getQualifiedName() +
64-
"' is not declared protected or deleted."
64+
"' is not declared "+ missingAction +"."
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
| test.cpp:4:3:4:12 | declaration of BaseClass1 | Copy constructor for base class 'BaseClass1' is not declared protected or deleted. |
2-
| test.cpp:5:3:5:12 | declaration of BaseClass1 | Move constructor for base class 'BaseClass1' is not declared protected or deleted. |
3-
| test.cpp:6:15:6:23 | declaration of operator= | Copy assignment operator for base class 'BaseClass1' is not declared protected or deleted. |
4-
| test.cpp:7:15:7:23 | declaration of operator= | Move constructor for base class 'BaseClass1' is not declared protected or deleted. |
5-
| test.cpp:15:7:15:7 | declaration of operator= | Implicit copy assignment operator for base class 'BaseClass2' is not declared protected or deleted. |
6-
| test.cpp:15:7:15:7 | declaration of operator= | Implicit move assignment operator for base class 'BaseClass2' is not declared protected or deleted. |
7-
| test.cpp:55:3:55:12 | declaration of BaseClass5 | Copy constructor for base class 'BaseClass5' is not declared protected or deleted. |
8-
| test.cpp:56:3:56:12 | declaration of BaseClass5 | Move constructor for base class 'BaseClass5' is not declared protected or deleted. |
9-
| test.cpp:57:15:57:23 | declaration of operator= | Copy assignment operator for base class 'BaseClass5' is not declared protected or deleted. |
10-
| test.cpp:58:15:58:23 | declaration of operator= | Move constructor for base class 'BaseClass5' is not declared protected or deleted. |
11-
| test.cpp:75:3:75:12 | declaration of BaseClass6 | Copy constructor for base class 'BaseClass6' is not declared protected or deleted. |
12-
| test.cpp:76:3:76:12 | declaration of BaseClass6 | Move constructor for base class 'BaseClass6' is not declared protected or deleted. |
13-
| test.cpp:77:15:77:23 | declaration of operator= | Copy assignment operator for base class 'BaseClass6' is not declared protected or deleted. |
14-
| test.cpp:78:15:78:23 | declaration of operator= | Move constructor for base class 'BaseClass6' is not declared protected or deleted. |
15-
| test.cpp:85:3:85:12 | declaration of BaseClass7 | Copy constructor for base class 'BaseClass7<T1>' is not declared protected or deleted. |
16-
| test.cpp:86:3:86:12 | declaration of BaseClass7 | Move constructor for base class 'BaseClass7<T1>' is not declared protected or deleted. |
17-
| test.cpp:87:15:87:23 | declaration of operator= | Copy assignment operator for base class 'BaseClass7<T1>' is not declared protected or deleted. |
18-
| test.cpp:88:15:88:23 | declaration of operator= | Move constructor for base class 'BaseClass7<T1>' is not declared protected or deleted. |
19-
| test.cpp:108:3:108:12 | declaration of BaseClass8 | Copy constructor for base class 'BaseClass8' is not declared protected or deleted. |
20-
| test.cpp:109:3:109:12 | declaration of BaseClass8 | Move constructor for base class 'BaseClass8' is not declared protected or deleted. |
21-
| test.cpp:110:15:110:23 | declaration of operator= | Copy assignment operator for base class 'BaseClass8' is not declared protected or deleted. |
22-
| test.cpp:111:15:111:23 | declaration of operator= | Move constructor for base class 'BaseClass8' is not declared protected or deleted. |
23-
| test.cpp:124:26:124:26 | declaration of BaseClass9 | Implicit copy constructor for base class 'BaseClass9<int>' is not declared protected or deleted. |
24-
| test.cpp:124:26:124:26 | declaration of BaseClass9 | Implicit move constructor for base class 'BaseClass9<int>' is not declared protected or deleted. |
25-
| test.cpp:124:26:124:26 | declaration of operator= | Implicit copy assignment operator for base class 'BaseClass9<int>' is not declared protected or deleted. |
26-
| test.cpp:124:26:124:26 | declaration of operator= | Implicit move assignment operator for base class 'BaseClass9<int>' is not declared protected or deleted. |
1+
| test.cpp:4:3:4:12 | declaration of BaseClass1 | Copy constructor for base class 'BaseClass1' is not declared protected. |
2+
| test.cpp:5:3:5:12 | declaration of BaseClass1 | Move constructor for base class 'BaseClass1' is not declared protected. |
3+
| test.cpp:6:15:6:23 | declaration of operator= | Copy assignment operator for base class 'BaseClass1' is not declared protected. |
4+
| test.cpp:7:15:7:23 | declaration of operator= | Move assignment operator for base class 'BaseClass1' is not declared protected. |
5+
| test.cpp:15:7:15:7 | declaration of operator= | Implicit copy assignment operator for base class 'BaseClass2' is not declared deleted. |
6+
| test.cpp:15:7:15:7 | declaration of operator= | Implicit move assignment operator for base class 'BaseClass2' is not declared deleted. |
7+
| test.cpp:55:3:55:12 | declaration of BaseClass5 | Copy constructor for base class 'BaseClass5' is not declared protected. |
8+
| test.cpp:56:3:56:12 | declaration of BaseClass5 | Move constructor for base class 'BaseClass5' is not declared protected. |
9+
| test.cpp:57:15:57:23 | declaration of operator= | Copy assignment operator for base class 'BaseClass5' is not declared protected. |
10+
| test.cpp:58:15:58:23 | declaration of operator= | Move assignment operator for base class 'BaseClass5' is not declared protected. |
11+
| test.cpp:75:3:75:12 | declaration of BaseClass6 | Copy constructor for base class 'BaseClass6' is not declared protected. |
12+
| test.cpp:76:3:76:12 | declaration of BaseClass6 | Move constructor for base class 'BaseClass6' is not declared protected. |
13+
| test.cpp:77:15:77:23 | declaration of operator= | Copy assignment operator for base class 'BaseClass6' is not declared protected. |
14+
| test.cpp:78:15:78:23 | declaration of operator= | Move assignment operator for base class 'BaseClass6' is not declared protected. |
15+
| test.cpp:85:3:85:12 | declaration of BaseClass7 | Copy constructor for base class 'BaseClass7<T1>' is not declared protected. |
16+
| test.cpp:86:3:86:12 | declaration of BaseClass7 | Move constructor for base class 'BaseClass7<T1>' is not declared protected. |
17+
| test.cpp:87:15:87:23 | declaration of operator= | Copy assignment operator for base class 'BaseClass7<T1>' is not declared protected. |
18+
| test.cpp:88:15:88:23 | declaration of operator= | Move assignment operator for base class 'BaseClass7<T1>' is not declared protected. |
19+
| test.cpp:108:3:108:12 | declaration of BaseClass8 | Copy constructor for base class 'BaseClass8' is not declared protected. |
20+
| test.cpp:109:3:109:12 | declaration of BaseClass8 | Move constructor for base class 'BaseClass8' is not declared protected. |
21+
| test.cpp:110:15:110:23 | declaration of operator= | Copy assignment operator for base class 'BaseClass8' is not declared protected. |
22+
| test.cpp:111:15:111:23 | declaration of operator= | Move assignment operator for base class 'BaseClass8' is not declared protected. |
23+
| test.cpp:124:26:124:26 | declaration of BaseClass9 | Implicit copy constructor for base class 'BaseClass9<int>' is not declared deleted. |
24+
| test.cpp:124:26:124:26 | declaration of BaseClass9 | Implicit move constructor for base class 'BaseClass9<int>' is not declared deleted. |
25+
| test.cpp:124:26:124:26 | declaration of operator= | Implicit copy assignment operator for base class 'BaseClass9<int>' is not declared deleted. |
26+
| test.cpp:124:26:124:26 | declaration of operator= | Implicit move assignment operator for base class 'BaseClass9<int>' is not declared deleted. |

0 commit comments

Comments
 (0)