Skip to content

Commit 6aaf0ee

Browse files
committed
A15-2-2: Address compiler compatibility issue
This query included some spurious edges for results that are outside the source location. We now exclude constructors outside the source archive to avoid these spurious edges, and make the result more stable.
1 parent eb95419 commit 6aaf0ee

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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
class ExceptionThrownInConstructor extends ExceptionThrowingExpr {
7979
Constructor c;
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
Constructor getConstructor() { result = c }
8488
}
8589

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

8895
from

0 commit comments

Comments
 (0)