Skip to content

Commit ac19c12

Browse files
Address feedback
1 parent f5e8a56 commit ac19c12

4 files changed

Lines changed: 21 additions & 6 deletions

File tree

cpp/misra/src/rules/RULE-6-2-3/DuplicateTypeDefinitions.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class UserTypeDefinition extends TypeDeclarationEntry {
3333

3434
from UserTypeDefinition t1, UserTypeDefinition t2
3535
where
36-
not isExcluded(t1, Declarations8Package::duplicateTypeDefinitionsQuery()) and
36+
not isExcluded([t1, t2], Declarations8Package::duplicateTypeDefinitionsQuery()) and
3737
t1.getUserType().getQualifiedName() = t2.getUserType().getQualifiedName() and
3838
t1.getFile() != t2.getFile() and
3939
t1.getFile().getAbsolutePath() < t2.getFile().getAbsolutePath() // Report only once per pair

cpp/misra/test/rules/RULE-6-2-3/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <cstdint>
22

3-
inline int16_t global_redefined = 0; // NON_COMPLIANT[False negative]
3+
inline int16_t global_redefined = 0; // NON_COMPLIANT[FALSE_NEGATIVE]
44
inline int16_t global_unique = 0; // COMPLIANT
55
inline int16_t global_redeclared = 0; // COMPLIANT
66
inline void func_redefined() {} // NON_COMPLIANT

cpp/misra/test/rules/RULE-6-2-3/test2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <cstdint>
55

6-
inline int16_t global_redefined = 0; // NON_COMPLIANT[False negative]
6+
inline int16_t global_redefined = 0; // NON_COMPLIANT[FALSE_NEGATIVE]
77
extern inline int16_t global_redeclared; // COMPLIANT
88
inline void func_redefined() {} // NON_COMPLIANT -- flagged in test.cpp
99
inline void func_redeclared(); // COMPLIANT

rule_packages/cpp/Declarations8.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@
1919
"scope/system"
2020
],
2121
"implementation_scope": {
22-
"description": "This query does not detect duplicated definitions of inline variables.",
23-
"items": []
22+
"description": "The implementation of this rule and the implementation of Rule 6.2.1 are heavily related.",
23+
"items": [
24+
"Generally speaking, false positives in Rule 6.2.1 will be true violations of this rule, and such results are not duplicated here.",
25+
"Our implementation of Rule 6.2.1 detects duplicate definitions of non-inline entities, but excludes all inline functions to avoid false positives.",
26+
"This query detects duplicate definitions of inline functions.",
27+
"Note that our definition of Rule 6.2.1 cannot distinguish between inline and non-inline variables, and therefore reports all such duplications even if they are not ODR violations. For the same reason, we do not check inline variable definitions in this query.",
28+
"This rule contains another query to detect duplicate definitions of types, another case that is excluded by our implementation of Rule 6.2.1."
29+
]
2430
}
2531
},
2632
{
@@ -47,7 +53,16 @@
4753
"correctness",
4854
"maintainability",
4955
"scope/system"
50-
]
56+
],
57+
"implementation_scope": {
58+
"description": "The implementation of this rule and the implementation of Rule 6.2.1 are heavily related.",
59+
"items": [
60+
"Generally speaking, false positives in Rule 6.2.1 will be true violations of this rule, and such results are not duplicated here.",
61+
"Our implementation of Rule 6.2.1 excludes analysis of duplicate type definitions to avoid false positives, even for cases that are true ODR violations.",
62+
"This query detects duplicate definitions of types.",
63+
"This rule contains another query to detect duplicate definitions of inline functions, another case that is excluded by our implementation of Rule 6.2.1."
64+
]
65+
}
5166
}
5267
],
5368
"title": "The source code used to implement an entity shall appear only once"

0 commit comments

Comments
 (0)