Skip to content

Commit 0a80144

Browse files
committed
review comments
1 parent 61a5cec commit 0a80144

5 files changed

Lines changed: 47 additions & 70 deletions

File tree

csharp/ql/lib/semmle/code/csharp/dataflow/Bound.qll

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,28 @@ overlay[local?]
55
module;
66

77
private import csharp as CS
8-
private import internal.rangeanalysis.BoundSpecific
9-
private import internal.rangeanalysis.BoundSpecific as BoundSpecific
8+
private import semmle.code.csharp.dataflow.SSA::Ssa as Ssa
9+
private import semmle.code.csharp.dataflow.internal.rangeanalysis.ConstantUtils as CU
10+
private import semmle.code.csharp.dataflow.internal.rangeanalysis.RangeUtils as RU
11+
private import semmle.code.csharp.dataflow.internal.rangeanalysis.SsaUtils as SU
1012
private import codeql.rangeanalysis.Bound as SharedBound
1113

12-
private module BoundImpl = SharedBound::Bound<CS::Location, BoundSpecific::BoundDefs>;
14+
/** Provides C#-specific definitions for bounds. */
15+
private module BoundDefs implements SharedBound::BoundDefinitions<CS::Location> {
16+
class Type = CS::Type;
1317

14-
import BoundImpl
18+
class SsaVariable = SU::SsaVariable;
19+
20+
class SsaSourceVariable = Ssa::SourceVariable;
21+
22+
class Expr = CS::ControlFlowNodes::ExprNode;
23+
24+
class IntegralType = CS::IntegralType;
25+
26+
class ConstantIntegerExpr = CU::ConstantIntegerExpr;
27+
28+
/** Holds if `e` is a bound expression and it is not an SSA variable read. */
29+
predicate interestingExprBound(Expr e) { CU::systemArrayLengthAccess(e.getExpr()) }
30+
}
31+
32+
import SharedBound::Bound<CS::Location, BoundDefs>

csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/BoundSpecific.qll

Lines changed: 0 additions & 30 deletions
This file was deleted.

java/ql/lib/semmle/code/java/dataflow/Bound.qll

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,30 @@ overlay[local?]
55
module;
66

77
private import java as J
8-
private import internal.rangeanalysis.BoundSpecific as BoundSpecific
8+
private import semmle.code.java.dataflow.SSA as Ssa
9+
private import semmle.code.java.dataflow.RangeUtils as RU
910
private import codeql.rangeanalysis.Bound as SharedBound
1011

11-
private module BoundImpl = SharedBound::Bound<J::Location, BoundSpecific::BoundDefs>;
12+
private module BoundDefs implements SharedBound::BoundDefinitions<J::Location> {
13+
class SsaVariable extends Ssa::SsaDefinition {
14+
/** Gets a use of this variable. */
15+
Expr getAUse() { result = super.getARead() }
16+
}
1217

13-
import BoundImpl
18+
class SsaSourceVariable = Ssa::SourceVariable;
19+
20+
class Type = J::Type;
21+
22+
class Expr = J::Expr;
23+
24+
class IntegralType = J::IntegralType;
25+
26+
class ConstantIntegerExpr = RU::ConstantIntegerExpr;
27+
28+
/** Holds if `e` is a bound expression and it is not an SSA variable read. */
29+
predicate interestingExprBound(Expr e) {
30+
e.(J::FieldRead).getField() instanceof J::ArrayLengthField
31+
}
32+
}
33+
34+
import SharedBound::Bound<J::Location, BoundDefs>

java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/BoundSpecific.qll

Lines changed: 0 additions & 32 deletions
This file was deleted.

shared/rangeanalysis/codeql/rangeanalysis/Bound.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ signature module BoundDefinitions<LocationSig Location> {
4040

4141
/**
4242
* Provides classes for representing abstract bounds for use in, for example, range analysis.
43-
* This is a generic implementation of bounds that relies on language specific modules to provide language-specific definitions of expressions, SSA variables, etc.
43+
* This is a generic implementation of bounds that relies on language specific modules to provide language-specific definitions of expressions, SSA variables, etc.
4444
*/
4545
overlay[local?]
4646
module Bound<LocationSig Location, BoundDefinitions<Location> Defs> {

0 commit comments

Comments
 (0)