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

Commita79ad24

Browse files
authored
Merge pull request#338 from github/lcartey/final-compiler-compat-issues
Fixing the final compatibility issues
2 parentsa03c176 +a24fca8 commita79ad24

File tree

50 files changed

+501
-374
lines changed

Some content is hidden

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

50 files changed

+501
-374
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-`A8-4-13`
2+
- Address false positives caused by missing modelling of modifying operations for smart pointers for some standard libraries (such as libstdc++).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-`A20-8-1`/`MEM56-CPP`
2+
- Address false negatives caused by lack of modelling of flow through smart pointers.
3+
- Reduce flow paths through standard library headers to simplify results.
4+
-`A18-1-4`
5+
- Address false positives caused by missing modelling of modifying operations for smart pointers for some standard libraries (such as libstdc++).
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-`STR51-CPP`
2+
- Address false negatives caused by incomplete modelling of the`std::string::replace()` function.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-`A15-5-1`
2+
- Rephrase alert message for`noalert(false)` special functions to clarify that this permits exceptions.
3+
- Additional results for implicit`noexcept(true)` special functions highlighting that the specification should be made explicit.

‎cpp/autosar/src/rules/A15-2-2/ConstructorErrorLeavesObjectInInvalidState.ql‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,18 @@ class DeleteWrapperFunction extends Function {
7878
classExceptionThrownInConstructorextendsExceptionThrowingExpr{
7979
Constructorc;
8080

81-
ExceptionThrownInConstructor(){exists(getAFunctionThrownType(c,this))}
81+
ExceptionThrownInConstructor(){
82+
exists(getAFunctionThrownType(c,this))and
83+
// The constructor is within the users source code
84+
exists(c.getFile().getRelativePath())
85+
}
8286

8387
ConstructorgetConstructor(){result=c}
8488
}
8589

90+
/**
91+
* Add the `nodes` predicate to ensure results with an empty path are still reported.
92+
*/
8693
querypredicatenodes(ExceptionFlowNodenode){any()}
8794

8895
from

‎cpp/autosar/src/rules/A15-5-1/SpecialFunctionMissingNoExceptSpecification.ql‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,25 @@ import codingstandards.cpp.exceptions.ExceptionSpecifications
2222
fromSpecialFunctionf,stringmessage
2323
where
2424
notisExcluded(f, Exceptions2Package::specialFunctionMissingNoExceptSpecificationQuery())and
25-
notisNoExceptTrue(f)and
25+
notisFDENoExceptTrue(f.getDefinition())and
2626
notf.isCompilerGenerated()and
2727
notf.isDeleted()and
2828
notf.isDefaulted()and
2929
(
3030
isNoExceptExplicitlyFalse(f)and
31-
message=f.getQualifiedName()+" should not be noexcept(false)."
31+
message=
32+
"Special function "+f.getQualifiedName()+
33+
" has a noexcept(false) specification that permits exceptions."
3234
or
35+
isNoExceptTrue(f)and
36+
message=
37+
f.getQualifiedName()+
38+
" has an implicit noexcept(true) specification but should make that explicit."
39+
or
40+
notisNoExceptTrue(f)and
3341
notisNoExceptExplicitlyFalse(f)and
34-
message=f.getQualifiedName()+" is implicitly noexcept(false) and might throw."
42+
message=
43+
"Special function "+f.getQualifiedName()+
44+
" has an implicit noexcept(false) specification that permits exceptions."
3545
)
3646
selectf,message

‎cpp/autosar/src/rules/A18-1-4/PointerToAnElementOfAnArrayPassedToASmartPointer.ql‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,28 @@ class SingleObjectSmartPointerArrayConstructionConfig extends TaintTracking::Con
4646
(
4747
sp.getAConstructorCallWithExternalObjectConstruction().getAnArgument()=sink.asExpr()
4848
or
49-
sink.asExpr()=
50-
any(FunctionCallfc,MemberFunctionmf|
51-
mf=fc.getTarget()and
52-
mf.getDeclaringType()=spand
53-
mf.getName()="reset"
54-
|
55-
fc.getArgument(0)
56-
)
49+
sink.asExpr()=sp.getAResetCall().getArgument(0)
5750
)
5851
)
5952
}
53+
54+
overridepredicateisAdditionalTaintStep(DataFlow::Nodesource, DataFlow::Nodesink){
55+
exists(AutosarUniquePointersp,FunctionCallfc|
56+
fc=sp.getAReleaseCall()and
57+
source.asExpr()=fc.getQualifier()and
58+
sink.asExpr()=fc
59+
)
60+
}
61+
62+
overridepredicateisSanitizerIn(DataFlow::Nodenode){
63+
// Exclude flow into header files outside the source archive which are summarized by the
64+
// additional taint steps above.
65+
exists(AutosarUniquePointersp|
66+
sp.getAReleaseCall().getTarget()=node.asExpr().(ThisExpr).getEnclosingFunction()
67+
|
68+
notexists(node.getLocation().getFile().getRelativePath())
69+
)
70+
}
6071
}
6172

6273
from

‎cpp/autosar/src/rules/A8-4-13/SharedPtrPassedToFunctionWithImproperSemantics.ql‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,15 @@ import cpp
1919
import codingstandards.cpp.autosar
2020
import codingstandards.cpp.SmartPointers
2121

22-
ExprunderlyingObjectAffectingSharedPointerExpr(Functionf){
23-
result=
24-
any(VariableAccessva,FunctionCallfc|
25-
va.getEnclosingFunction()=fand
26-
// strip the type so as to include reference parameter types
27-
va.getType().stripType()instanceofAutosarSharedPointerand
28-
fc.getTarget().getDeclaringType().stripType()instanceofAutosarSharedPointerand
29-
fc.getQualifier()=vaand
30-
// include only calls to methods which modify the underlying object
31-
fc.getTarget().hasName(["operator=","reset","swap"])
32-
|
33-
va
34-
)
22+
VariableAccessunderlyingObjectAffectingSharedPointerExpr(Functionf){
23+
exists(FunctionCallfc|
24+
// Find a call in the function
25+
fc.getEnclosingFunction()=fand
26+
// include only calls to methods which modify the underlying object
27+
fc=any(AutosarSharedPointers).getAModifyingCall()and
28+
// Report the qualifier
29+
fc.getQualifier()=result
30+
)
3531
}
3632

3733
predicateflowsToUnderlyingObjectAffectingExpr(Parameterp){
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-w

‎cpp/autosar/test/rules/A12-0-2/test.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include<cstdlib>
2-
#include<string>
2+
#include<cstring>
33

44
classA {
55
public:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp