Skip to content

Commit b155a0f

Browse files
committed
C#: Avoid computing CIL strings and non-PDB locations in data flow library
Computing strings and locations for CIL instructions can be quite time consuming. The CIL `toString()`s are not very helpful in path explanations, and their locations are only useful when a PDB source file exists. Therefore, produce a simple constant `toString()`, and restrict locations to those in PDB files.
1 parent 344466a commit b155a0f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

csharp/ql/src/semmle/code/csharp/dataflow/DataFlow.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,19 @@ module DataFlow {
5353

5454
override DotNet::Callable getEnclosingCallable() { result = expr.getEnclosingCallable() }
5555

56-
override string toString() { result = expr.toString() }
56+
override string toString() {
57+
result = expr.(Expr).toString()
58+
or
59+
expr instanceof CIL::Expr and
60+
result = "CIL expression"
61+
}
5762

58-
override Location getLocation() { result = expr.getLocation() }
63+
override Location getLocation() {
64+
result = expr.(Expr).getLocation()
65+
or
66+
result.getFile().isPdbSourceFile() and
67+
result = expr.(CIL::Expr).getALocation()
68+
}
5969
}
6070

6171
/**

0 commit comments

Comments
 (0)