Skip to content

Commit 48fcec8

Browse files
authored
Merge pull request #15736 from michaelnebel/csharp/disconnectfromdotnet
C#: Deprecate dotnet and CIL in QL.
2 parents 1fa151d + 73040bd commit 48fcec8

File tree

111 files changed

+1071
-1797
lines changed

Some content is hidden

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

111 files changed

+1071
-1797
lines changed

csharp/ql/consistency-queries/DataFlowConsistency.ql

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import csharp
2-
import cil
32
private import semmle.code.csharp.controlflow.internal.ControlFlowGraphImpl as ControlFlowGraphImpl
43
private import semmle.code.csharp.dataflow.internal.DataFlowImplSpecific
54
private import semmle.code.csharp.dataflow.internal.TaintTrackingImplSpecific
@@ -31,11 +30,6 @@ private module Input implements InputSig<CsharpDataFlow> {
3130
n instanceof FlowInsensitiveFieldNode
3231
}
3332

34-
predicate missingLocationExclude(Node n) {
35-
// Some CIL methods are missing locations
36-
n.asParameter() instanceof CIL::Parameter
37-
}
38-
3933
predicate postWithInFlowExclude(Node n) {
4034
n instanceof FlowSummaryNode
4135
or
@@ -48,8 +42,6 @@ private module Input implements InputSig<CsharpDataFlow> {
4842
not exists(LocalFlow::getAPostUpdateNodeForArg(n.getControlFlowNode()))
4943
or
5044
n instanceof ParamsArgumentNode
51-
or
52-
n.asExpr() instanceof CIL::Expr
5345
}
5446

5547
predicate postHasUniquePreExclude(PostUpdateNode n) {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: breaking
3+
---
4+
* The QL library C# classes no longer extend their corresponding `DotNet` classes. Furthermore, CIL related data flow functionality has been deleted and all `DotNet` and `CIL` related classes have been deprecated. This effectively means that it no longer has any effect to enable CIL extraction.

csharp/ql/lib/dotnet.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
* The default QL library for modeling .NET definitions for both C# and CIL code.
33
*/
44

5-
import semmle.code.dotnet.DotNet as DotNet
5+
deprecated import semmle.code.dotnet.DotNet as DotNet

csharp/ql/lib/semmle/code/cil/Access.qll

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
private import CIL
88

99
/** An instruction that accesses a variable. */
10-
class Access extends Instruction, @cil_access {
10+
deprecated class Access extends Instruction, @cil_access {
1111
/** Gets the declaration referenced by this instruction. */
1212
Variable getTarget() { cil_access(this, result) }
1313
}
@@ -16,59 +16,59 @@ class Access extends Instruction, @cil_access {
1616
* An instruction that accesses a variable.
1717
* This class is provided for consistency with the C# data model.
1818
*/
19-
class VariableAccess extends Access, @cil_access { }
19+
deprecated class VariableAccess extends Access, @cil_access { }
2020

2121
/** An instruction that reads a variable. */
22-
class ReadAccess extends VariableAccess, Expr, @cil_read_access {
22+
deprecated class ReadAccess extends VariableAccess, Expr, @cil_read_access {
2323
override Type getType() { result = this.getTarget().getType() }
2424
}
2525

2626
/** An instruction yielding an address. */
27-
class ReadRef extends Expr, @cil_read_ref { }
27+
deprecated class ReadRef extends Expr, @cil_read_ref { }
2828

2929
/** An instruction that reads the address of a variable. */
30-
class ReadRefAccess extends ReadAccess, ReadRef { }
30+
deprecated class ReadRefAccess extends ReadAccess, ReadRef { }
3131

3232
/** An instruction that writes a variable. */
33-
class WriteAccess extends VariableAccess, @cil_write_access {
33+
deprecated class WriteAccess extends VariableAccess, @cil_write_access {
3434
/** Gets the expression whose value is used in this variable write. */
3535
Expr getExpr() { none() }
3636
}
3737

3838
/** An instruction that accesses a parameter. */
39-
class ParameterAccess extends StackVariableAccess, @cil_arg_access {
39+
deprecated class ParameterAccess extends StackVariableAccess, @cil_arg_access {
4040
override MethodParameter getTarget() { result = StackVariableAccess.super.getTarget() }
4141
}
4242

4343
/** An instruction that reads a parameter. */
44-
class ParameterReadAccess extends ParameterAccess, ReadAccess {
44+
deprecated class ParameterReadAccess extends ParameterAccess, ReadAccess {
4545
override int getPopCount() { result = 0 }
4646
}
4747

4848
/** An instruction that writes to a parameter. */
49-
class ParameterWriteAccess extends ParameterAccess, WriteAccess {
49+
deprecated class ParameterWriteAccess extends ParameterAccess, WriteAccess {
5050
override int getPopCount() { result = 1 }
5151

5252
override Expr getExpr() { result = this.getOperand(0) }
5353
}
5454

5555
/** An access to the `this` parameter. */
56-
class ThisAccess extends ParameterReadAccess {
56+
deprecated class ThisAccess extends ParameterReadAccess {
5757
ThisAccess() { this.getTarget() instanceof ThisParameter }
5858
}
5959

6060
/** An instruction that accesses a stack variable. */
61-
class StackVariableAccess extends VariableAccess, @cil_stack_access {
61+
deprecated class StackVariableAccess extends VariableAccess, @cil_stack_access {
6262
override StackVariable getTarget() { result = VariableAccess.super.getTarget() }
6363
}
6464

6565
/** An instruction that accesses a local variable. */
66-
class LocalVariableAccess extends StackVariableAccess, @cil_local_access {
66+
deprecated class LocalVariableAccess extends StackVariableAccess, @cil_local_access {
6767
override LocalVariable getTarget() { result = StackVariableAccess.super.getTarget() }
6868
}
6969

7070
/** An instruction that writes to a local variable. */
71-
class LocalVariableWriteAccess extends LocalVariableAccess, WriteAccess {
71+
deprecated class LocalVariableWriteAccess extends LocalVariableAccess, WriteAccess {
7272
override int getPopCount() { result = 1 }
7373

7474
override Expr getExpr() { result = this.getOperand(0) }
@@ -77,12 +77,12 @@ class LocalVariableWriteAccess extends LocalVariableAccess, WriteAccess {
7777
}
7878

7979
/** An instruction that reads a local variable. */
80-
class LocalVariableReadAccess extends LocalVariableAccess, ReadAccess {
80+
deprecated class LocalVariableReadAccess extends LocalVariableAccess, ReadAccess {
8181
override int getPopCount() { result = 0 }
8282
}
8383

8484
/** An instruction that accesses a field. */
85-
class FieldAccess extends VariableAccess, @cil_field_access {
85+
deprecated class FieldAccess extends VariableAccess, @cil_field_access {
8686
override Field getTarget() { result = VariableAccess.super.getTarget() }
8787

8888
override string getExtra() { result = this.getTarget().getName() }
@@ -92,7 +92,7 @@ class FieldAccess extends VariableAccess, @cil_field_access {
9292
}
9393

9494
/** An instruction that reads a field. */
95-
abstract class FieldReadAccess extends FieldAccess, ReadAccess { }
95+
abstract deprecated class FieldReadAccess extends FieldAccess, ReadAccess { }
9696

9797
/** An instruction that writes a field. */
98-
abstract class FieldWriteAccess extends FieldAccess, WriteAccess { }
98+
abstract deprecated class FieldWriteAccess extends FieldAccess, WriteAccess { }

csharp/ql/lib/semmle/code/cil/Attribute.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ private import CIL
44
private import semmle.code.csharp.Location as CS
55

66
/** An attribute to a declaration, such as a method, field, type or parameter. */
7-
class Attribute extends Element, @cil_attribute {
7+
deprecated class Attribute extends Element, @cil_attribute {
88
/** Gets the declaration this attribute is attached to. */
99
Declaration getDeclaration() { cil_attribute(this, result, _) }
1010

@@ -29,7 +29,7 @@ class Attribute extends Element, @cil_attribute {
2929
}
3030

3131
/** A generic attribute to a declaration. */
32-
class GenericAttribute extends Attribute {
32+
deprecated class GenericAttribute extends Attribute {
3333
private ConstructedType type;
3434

3535
GenericAttribute() { type = this.getType() }

csharp/ql/lib/semmle/code/cil/BasicBlock.qll

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ private import CIL
88
* A basic block, that is, a maximal straight-line sequence of control flow nodes
99
* without branches or joins.
1010
*/
11-
class BasicBlock extends Cached::TBasicBlockStart {
11+
deprecated class BasicBlock extends Cached::TBasicBlockStart {
1212
/** Gets an immediate successor of this basic block, if any. */
1313
BasicBlock getASuccessor() { result.getFirstNode() = this.getLastNode().getASuccessor() }
1414

@@ -249,7 +249,7 @@ class BasicBlock extends Cached::TBasicBlockStart {
249249
* Internal implementation details.
250250
*/
251251
cached
252-
private module Cached {
252+
deprecated private module Cached {
253253
/** Internal representation of basic blocks. */
254254
cached
255255
newtype TBasicBlock = TBasicBlockStart(ControlFlowNode cfn) { startsBB(cfn) }
@@ -287,49 +287,54 @@ private module Cached {
287287
* Holds if the first node of basic block `succ` is a control flow
288288
* successor of the last node of basic block `pred`.
289289
*/
290-
private predicate succBB(BasicBlock pred, BasicBlock succ) { succ = pred.getASuccessor() }
290+
deprecated private predicate succBB(BasicBlock pred, BasicBlock succ) {
291+
succ = pred.getASuccessor()
292+
}
291293

292294
/** Holds if `dom` is an immediate dominator of `bb`. */
293-
predicate bbIDominates(BasicBlock dom, BasicBlock bb) = idominance(entryBB/1, succBB/2)(_, dom, bb)
295+
deprecated predicate bbIDominates(BasicBlock dom, BasicBlock bb) =
296+
idominance(entryBB/1, succBB/2)(_, dom, bb)
294297

295298
/** Holds if `pred` is a basic block predecessor of `succ`. */
296-
private predicate predBB(BasicBlock succ, BasicBlock pred) { succBB(pred, succ) }
299+
deprecated private predicate predBB(BasicBlock succ, BasicBlock pred) { succBB(pred, succ) }
297300

298301
/** Holds if `dom` is an immediate post-dominator of `bb`. */
299-
predicate bbIPostDominates(BasicBlock dom, BasicBlock bb) =
302+
deprecated predicate bbIPostDominates(BasicBlock dom, BasicBlock bb) =
300303
idominance(exitBB/1, predBB/2)(_, dom, bb)
301304

302305
/**
303306
* An entry basic block, that is, a basic block whose first node is
304307
* the entry node of a callable.
305308
*/
306-
class EntryBasicBlock extends BasicBlock {
309+
deprecated class EntryBasicBlock extends BasicBlock {
307310
EntryBasicBlock() { entryBB(this) }
308311
}
309312

310313
/** Holds if `bb` is an entry basic block. */
311-
private predicate entryBB(BasicBlock bb) { bb.getFirstNode() instanceof MethodImplementation }
314+
deprecated private predicate entryBB(BasicBlock bb) {
315+
bb.getFirstNode() instanceof MethodImplementation
316+
}
312317

313318
/**
314319
* An exit basic block, that is, a basic block whose last node is
315320
* an exit node.
316321
*/
317-
class ExitBasicBlock extends BasicBlock {
322+
deprecated class ExitBasicBlock extends BasicBlock {
318323
ExitBasicBlock() { exitBB(this) }
319324
}
320325

321326
/** Holds if `bb` is an exit basic block. */
322-
private predicate exitBB(BasicBlock bb) { not exists(bb.getLastNode().getASuccessor()) }
327+
deprecated private predicate exitBB(BasicBlock bb) { not exists(bb.getLastNode().getASuccessor()) }
323328

324329
/**
325330
* A basic block with more than one predecessor.
326331
*/
327-
class JoinBlock extends BasicBlock {
332+
deprecated class JoinBlock extends BasicBlock {
328333
JoinBlock() { this.getFirstNode().isJoin() }
329334
}
330335

331336
/** A basic block that terminates in a condition, splitting the subsequent control flow. */
332-
class ConditionBlock extends BasicBlock {
337+
deprecated class ConditionBlock extends BasicBlock {
333338
ConditionBlock() {
334339
exists(BasicBlock succ |
335340
succ = this.getATrueSuccessor()

csharp/ql/lib/semmle/code/cil/CallableReturns.qll

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,26 @@ cached
88
private module Cached {
99
/** Holds if method `m` always returns null. */
1010
cached
11-
predicate alwaysNullMethod(Method m) { forex(Expr e | m.canReturn(e) | alwaysNullExpr(e)) }
11+
deprecated predicate alwaysNullMethod(Method m) {
12+
forex(Expr e | m.canReturn(e) | alwaysNullExpr(e))
13+
}
1214

1315
/** Holds if method `m` always returns non-null. */
1416
cached
15-
predicate alwaysNotNullMethod(Method m) { forex(Expr e | m.canReturn(e) | alwaysNotNullExpr(e)) }
17+
deprecated predicate alwaysNotNullMethod(Method m) {
18+
forex(Expr e | m.canReturn(e) | alwaysNotNullExpr(e))
19+
}
1620

1721
/** Holds if method `m` always throws an exception. */
1822
cached
19-
predicate alwaysThrowsMethod(Method m) {
23+
deprecated predicate alwaysThrowsMethod(Method m) {
2024
m.hasBody() and
2125
not exists(m.getImplementation().getAnInstruction().(Return))
2226
}
2327

2428
/** Holds if method `m` always throws an exception of type `t`. */
2529
cached
26-
predicate alwaysThrowsException(Method m, Type t) {
30+
deprecated predicate alwaysThrowsException(Method m, Type t) {
2731
alwaysThrowsMethod(m) and
2832
forex(Throw ex | ex = m.getImplementation().getAnInstruction() | t = ex.getExceptionType())
2933
}
@@ -32,12 +36,12 @@ private module Cached {
3236
import Cached
3337

3438
pragma[noinline]
35-
private predicate alwaysNullVariableUpdate(VariableUpdate vu) {
39+
deprecated private predicate alwaysNullVariableUpdate(VariableUpdate vu) {
3640
forex(Expr src | src = vu.getSource() | alwaysNullExpr(src))
3741
}
3842

3943
/** Holds if expression `expr` always evaluates to `null`. */
40-
private predicate alwaysNullExpr(Expr expr) {
44+
deprecated private predicate alwaysNullExpr(Expr expr) {
4145
expr instanceof NullLiteral
4246
or
4347
alwaysNullMethod(expr.(StaticCall).getTarget())
@@ -50,12 +54,12 @@ private predicate alwaysNullExpr(Expr expr) {
5054
}
5155

5256
pragma[noinline]
53-
private predicate alwaysNotNullVariableUpdate(VariableUpdate vu) {
57+
deprecated private predicate alwaysNotNullVariableUpdate(VariableUpdate vu) {
5458
forex(Expr src | src = vu.getSource() | alwaysNotNullExpr(src))
5559
}
5660

5761
/** Holds if expression `expr` always evaluates to non-null. */
58-
private predicate alwaysNotNullExpr(Expr expr) {
62+
deprecated private predicate alwaysNotNullExpr(Expr expr) {
5963
expr instanceof Opcodes::NewObj
6064
or
6165
expr instanceof Literal and not expr instanceof NullLiteral

0 commit comments

Comments
 (0)