Skip to content

Commit ecbb588

Browse files
authored
Merge branch 'main' into rvermeulen/fix-392
2 parents de82e22 + 34d836f commit ecbb588

File tree

47 files changed

+302
-62
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+302
-62
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- The following queries have been updated to address issues with applying deviations:
2+
- `A18-5-11`, `A23-0-1`, `A9-3-1`, `M0-1-2`, `M3-1-2`, `M3-2-1`, `M3-2-3`, `M3-9-1`, `M4-5-3`, `M5-0-2`, `M5-2-10`, `A23-0-2`, `CTR51-CPP`, `STR52-CPP`
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- `A5-1-1` - `LiteralValueUsedOutsideTypeInit.ql`:
2+
- Address FP reported in #371. Exclude literals generated by uses of constexpr variables.
3+
- Exclude literals used in class template instantiations.
4+
- Update the alert message to adhere to the style-guide.
5+
- Exclude boolean literals used as template arguments.
6+
- Exclude `u` and `U` prefixed char literals.
7+
- Exclude literals part of a class aggregate literal.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- `A5-0-2` - `NonBooleanIterationCondition.ql`:
2+
- Address FP reported in #10. Exclude conditions in uninstantiated templates.
3+
- `M5-3-1` - `EachOperandOfTheOperatorTheLogicalAndOrTheLogicalOperatorsShallHaveTypeBool.ql`:
4+
- Adjust the alert message to comply with the style guide.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `M5-14-1` - `RightHandOperandOfALogicalAndOperatorsContainSideEffects.ql`:
2+
- Fix FP reported in #375. Addresses incorrect detection of side effects in unevaluated contexts.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `A16-2-2` - `UnusedIncludeDirectives.ql`:
2+
- Address FP reported in #453. Exclude reporting of redundant include directives indirectly included by included files.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- `A8-4-7` - `InParametersForNotCheapToCopyTypesNotPassedByReference.ql`, `InParametersForCheapToCopyTypesNotPassedByValue.ql`:
2+
- Improve coverage of the query by additionally alerting to non-trivially-copyable types being passed by value.
3+
- Non-trivially-copyable types not passed by value will no longer be incorrectly reported.

cpp/autosar/src/rules/A16-2-2/UnusedIncludeDirectives.ql

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,19 @@ private predicate firstReliableProvide(File f, File g, int line) {
223223

224224
cached
225225
predicate mayProvideFirst(IncludeDepends i, File g) {
226-
// i may provide g and does not come after a reliable include of g.
226+
// i may provide g
227227
i.provides(g) and
228-
not exists(int line | firstReliableProvide(i.getFile(), g, line) |
229-
line < i.getLocation().getStartLine()
228+
(
229+
// and does not come after a reliable include of g.
230+
not exists(int line | firstReliableProvide(i.getFile(), g, line) |
231+
line < i.getLocation().getStartLine()
232+
)
233+
or
234+
// or it comes after a reliable include of g, and although redundant,
235+
// is not necessarily an issue e.g. in the case of libraries with
236+
// public header forwards to an internal header.
237+
// therefore, hold for transitive includes as well to exclude those results.
238+
not i.getIncludedFile() = g
230239
)
231240
}
232241

cpp/autosar/src/rules/A18-5-11/OperatorNewAndOperatorDeleteNotDefinedLocally.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import codingstandards.cpp.autosar
1919

2020
from MemberFunction operator_new, Class c
2121
where
22-
not isExcluded(operator_new) and
22+
not isExcluded(operator_new,
23+
DeclarationsPackage::operatorNewAndOperatorDeleteNotDefinedLocallyQuery()) and
2324
not isExcluded(c, DeclarationsPackage::operatorNewAndOperatorDeleteNotDefinedLocallyQuery()) and
2425
operator_new.hasName("operator new") and
2526
operator_new.getDeclaringType() = c and

cpp/autosar/src/rules/A23-0-1/IteratorImplicitlyConvertedToConstIterator.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ import codingstandards.cpp.Iterators
4040

4141
from ConstIteratorVariable v, STLContainer c, Expr e
4242
where
43-
not isExcluded(v) and
44-
not isExcluded(e) and
43+
not isExcluded(v, IteratorsPackage::iteratorImplicitlyConvertedToConstIteratorQuery()) and
44+
not isExcluded(e, IteratorsPackage::iteratorImplicitlyConvertedToConstIteratorQuery()) and
4545
e = v.getAnAssignedValue() and
4646
e.getAChild*() = /* see note at top of query */ c.getANonConstIteratorFunctionCall()
4747
select e, "Non-const version of container call immediately converted to a `const_iterator`."

cpp/autosar/src/rules/A5-1-1/LiteralValueUsedOutsideTypeInit.ql

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import cpp
1818
import codingstandards.cpp.autosar
1919
import codingstandards.cpp.LoggingOperation
2020
import codingstandards.cpp.Literals
21+
import codingstandards.cpp.Cpp14Literal
2122

2223
from Literal l
2324
where
@@ -35,11 +36,11 @@ where
3536
// Exclude literal 0
3637
not l.getValue() = "0" and
3738
// Exclude character literals
38-
not l instanceof CharLiteral and
39+
not l instanceof Cpp14Literal::CharLiteral and
3940
// Exclude `nullptr`
4041
not l.getType() instanceof NullPointerType and
4142
// Exclude boolean `true` and `false`
42-
not l.getType() instanceof BoolType and
43+
not l instanceof BoolLiteral and
4344
// Exclude empty string
4445
not l.getValue() = "" and
4546
// Template functions use literals to represent calls which are unknown
@@ -51,7 +52,14 @@ where
5152
// Aggregate literal
5253
not l = any(ArrayOrVectorAggregateLiteral aal).getAnElementExpr(_).getAChild*() and
5354
// Ignore x - 1 expressions
54-
not exists(SubExpr se | se.getRightOperand() = l and l.getValue() = "1")
55-
select l,
56-
"Literal value " + getTruncatedLiteralText(l) + " used outside of type initialization " +
57-
l.getAPrimaryQlClass()
55+
not exists(SubExpr se | se.getRightOperand() = l and l.getValue() = "1") and
56+
// Exclude compile time computed integral literals as they can appear as integral literals
57+
// when used as non-type template arguments.
58+
// We limit ourselves to integral literals, because floating point literals as non-type
59+
// template arguments are not supported in C++ 14. Those are supported shince C++ 20.
60+
not l instanceof CompileTimeComputedIntegralLiteral and
61+
// Exclude literals to instantiate a class template per example in the standard
62+
// where an type of std::array is intialized with size 5.
63+
not l = any(ClassTemplateInstantiation cti).getATemplateArgument() and
64+
not l = any(ClassAggregateLiteral cal).getAFieldExpr(_)
65+
select l, "Literal value '" + getTruncatedLiteralText(l) + "' used outside of type initialization."

0 commit comments

Comments
 (0)