Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb68aeaa

Browse files
authored
Merge branch 'main' into lcartey/fix-fork-code-scanning-pack-job
2 parentsb817d0c +ce5b364 commitb68aeaa

File tree

5 files changed

+56
-1
lines changed

5 files changed

+56
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `A15-4-4` - `MissingNoExcept.ql`:
2+
- Reduce false positives by not reporting on functions that have a noexcept specification with a complex expression or call other such functions.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-`A3-9-1` -`VariableWidthIntegerTypesUsed.ql`:
2+
- Reduce false positives by not considering variables from template instantiations.

‎cpp/autosar/src/rules/A15-4-4/MissingNoExcept.ql‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,36 @@ import codingstandards.cpp.autosar
1919
import codingstandards.cpp.exceptions.ExceptionSpecifications
2020
import codingstandards.cpp.exceptions.ExceptionFlow
2121

22+
// These functions have a noexcept specification that could not be resolved
23+
// to noexcept(true). So either, they are noexcept(false) functions which
24+
// means, they can throw an exception OR they have an expression which
25+
// could not be resolved to "true" or "false". Even in this case, lets
26+
// be more conservative and assume they may thrown an exception.
27+
classFunctionWithUnknownNoExceptextendsFunction{
28+
FunctionWithUnknownNoExcept(){
29+
// Exists a noexcept specification but not noexcept(true)
30+
exists(this.getADeclarationEntry().getNoExceptExpr())and
31+
notisNoExceptTrue(this)
32+
}
33+
}
34+
35+
// This predicate checks if a function can call to other functions
36+
// that may have a noexcept specification which cannot be resolved to
37+
// noexcept(true).
38+
predicatemayCallThrowingFunctions(Functionf){
39+
// Exists a call in this function
40+
exists(Callfc|
41+
fc.getEnclosingFunction()=fand
42+
(
43+
// Either this call is to a function with an unknown noexcept OR
44+
fc.getTarget()instanceofFunctionWithUnknownNoExcept
45+
or
46+
// That function can further have calls to unknown noexcept functions.
47+
mayCallThrowingFunctions(fc.getTarget())
48+
)
49+
)
50+
}
51+
2252
fromFunctionf
2353
where
2454
notisExcluded(f, Exceptions1Package::missingNoExceptQuery())and
@@ -28,6 +58,12 @@ where
2858
notisNoExceptTrue(f)and
2959
// Not explicitly marked noexcept(false)
3060
notisNoExceptExplicitlyFalse(f)and
61+
// Not having a noexcept specification that
62+
// could not be computed as true or false above.
63+
notexists(f.getADeclarationEntry().getNoExceptExpr())and
64+
// Not calling function(s) which have a noexcept specification that
65+
// could not be computed as true.
66+
notmayCallThrowingFunctions(f)and
3167
// Not compiler generated
3268
notf.isCompilerGenerated()and
3369
// The function is defined in this database

‎cpp/autosar/src/rules/A3-9-1/VariableWidthIntegerTypesUsed.ql‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ where
3232
typeStrippedOfSpecifiersinstanceofSignedCharType
3333
)and
3434
notvinstanceofExcludedVariableand
35+
// Dont consider template instantiations because instantiations with
36+
// Fixed Width Types are recorded after stripping their typedef'd type,
37+
// thereby, causing false positives (#540).
38+
notv.isFromTemplateInstantiation(_)and
3539
//post-increment/post-decrement operators are required by the standard to have a dummy int parameter
3640
notv.(Parameter).getFunction()instanceofPostIncrementOperatorand
3741
notv.(Parameter).getFunction()instanceofPostDecrementOperator

‎cpp/autosar/test/rules/A3-9-1/test.cpp‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,15 @@ void test_variable_width_type_qualified_variables() {
7575
structtest_fix_fp_614 {
7676
test_fix_fp_614operator++(int);// COMPLIANT
7777
test_fix_fp_614operator--(int);// COMPLIANT
78-
};
78+
};
79+
80+
// COMPLIANT - instantiated with Fixed Width Types.
81+
template<typename MyType>constexprvoidtest_fix_fp_540(MyType value) {
82+
value++;
83+
}
84+
85+
intcall_test_fix_fp_540() {
86+
test_fix_fp_540<std::uint8_t>(19);
87+
test_fix_fp_540<std::int16_t>(20);
88+
return0;
89+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp