Skip to content

Commit 20a20b6

Browse files
committed
C++: Fix queries I forgot after merging github/codeql#20485 (part 1).
1 parent 1f68a2f commit 20a20b6

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

c/cert/src/rules/EXP16-C/DoNotCompareFunctionPointersToConstantValues.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ class ExplicitComparison extends EffectivelyComparison, FinalComparisonOperation
5353

5454
class ImplicitComparison extends EffectivelyComparison, GuardCondition instanceof Expr {
5555
ImplicitComparison() {
56+
this.valueControlsEdge(_, _, _) and
5657
this instanceof FunctionExpr and
57-
not getParent() instanceof ComparisonOperation
58+
not super.getParent() instanceof ComparisonOperation
5859
}
5960

6061
override string getExplanation() { result = "$@ undergoes implicit constant comparison." }

cpp/autosar/src/rules/A4-7-1/IntegerExpressionLeadToDataLoss.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ from InterestingOverflowingOperation e
2323
where
2424
not isExcluded(e, IntegerConversionPackage::integerExpressionLeadToDataLossQuery()) and
2525
// Not within a guard condition
26-
not exists(GuardCondition gc | gc.getAChild*() = e) and
26+
not e.getParent*().(GuardCondition).valueControlsEdge(_, _, _) and
2727
// Not guarded by a check, where the check is not an invalid overflow check
2828
not e.hasValidPreCheck() and
2929
// Covered by `IntMultToLong.ql` instead

cpp/common/src/codingstandards/cpp/rules/functionerroneousreturnvaluenottested/FunctionErroneousReturnValueNotTested.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ query predicate problems(FunctionCall fc, string message) {
5555
"vwprintf", "vfwprintf", "vswprintf", "vwprintf_s", "vfwprintf_s", "vswprintf_s",
5656
"vsnwprintf_s"
5757
]) and
58-
not exists(GuardCondition gc |
59-
DataFlow::localFlow(DataFlow::exprNode(fc), DataFlow::exprNode(gc.(Expr).getAChild*()))
60-
) and
58+
not fc.(GuardCondition).valueControlsEdge(_, _, _) and
6159
message = "Return value from " + fc.getTarget().getName() + " is not tested for errors."
6260
}

cpp/common/src/codingstandards/cpp/rules/unsignedoperationwithconstantoperandswraps/UnsignedOperationWithConstantOperandsWraps.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ query predicate problems(InterestingOverflowingOperation op, string message) {
1818
not isExcluded(op, getQuery()) and
1919
op.getType().getUnderlyingType().(IntegralType).isUnsigned() and
2020
// Not within a guard condition
21-
not exists(GuardCondition gc | gc.getAChild*() = op) and
21+
not op.getParent*().(GuardCondition).valueControlsEdge(_, _, _) and
2222
// Not guarded by a check, where the check is not an invalid overflow check
2323
not op.hasValidPreCheck() and
2424
// Is not checked after the operation

0 commit comments

Comments
 (0)