Skip to content

Commit c525ab3

Browse files
committed
Python: Add toString information for all classes without such.
Having `toString()` defined to be `none()` is a major headache when debugging, as `toString`-less results are silently elided. This PR puts dummy `toString`s in place of the `none()`s. (I am mostly creating this to see if it impacts our tests and/or the performance. If not, we may as well merge it.)
1 parent 77c869f commit c525ab3

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

python/ql/src/external/CodeDuplication.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Copy extends @duplication_or_similarity
9393
}
9494

9595
/** Gets a textual representation of this element. */
96-
string toString() { none() }
96+
string toString() { result = "Copy" }
9797

9898
/**
9999
* Gets a block that extends this one, that is, its first token is also

python/ql/src/semmle/python/Exprs.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ abstract class Num extends Num_, ImmutableLiteral {
419419

420420
/* We want to declare this abstract, but currently we cannot. */
421421
override string toString() {
422-
none()
422+
result = "Num with missing toString"
423423
}
424424

425425
}

python/ql/src/semmle/python/Keywords.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ abstract class DictUnpackingOrKeyword extends DictItem {
6060
abstract Expr getValue();
6161

6262
override string toString() {
63-
none()
63+
result = "DictUnpackingOrKeyword with missing toString"
6464
}
6565

6666
}
@@ -70,7 +70,7 @@ abstract class DictDisplayItem extends DictItem {
7070
abstract Expr getValue();
7171

7272
override string toString() {
73-
none()
73+
result = "DictDisplayItem with missing toString"
7474
}
7575

7676
}

python/ql/src/semmle/python/pointsto/PointsTo.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ library class CfgOrigin extends @py_object {
1313

1414
string toString() {
1515
/* Not to be displayed */
16-
none()
16+
result = "CfgOrigin"
1717
}
1818

1919
/** Get a `ControlFlowNode` from `this` or `here`.
@@ -68,7 +68,7 @@ module CfgOrigin {
6868
//
6969
// string toString() {
7070
// /* Not to be displayed */
71-
// none()
71+
// result = "CfgOrigin"
7272
// }
7373
//
7474
// /** Get a `ControlFlowNode` from `this` or `here`.

python/ql/src/semmle/python/types/Extensions.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import semmle.python.objects.ObjectInternal
2020

2121
abstract class PointsToExtension extends @py_flow_node {
2222

23-
string toString() { none() }
23+
string toString() { result = "PointsToExtension with missing toString" }
2424

2525
abstract predicate pointsTo(Context context, ObjectInternal value, ControlFlowNode origin);
2626

@@ -36,7 +36,7 @@ abstract class PointsToExtension extends @py_flow_node {
3636
/** DEPRECATED -- Use PointsToExtension instead */
3737
deprecated abstract class CustomPointsToFact extends @py_flow_node {
3838

39-
string toString() { none() }
39+
string toString() { result = "CustomPointsToFact with missing toString" }
4040

4141
abstract predicate pointsTo(Context context, Object value, ClassObject cls, ControlFlowNode origin);
4242

0 commit comments

Comments
 (0)