Skip to content

Commit e1dfed0

Browse files
committed
Ruby: move OptionalContentSet to TypeTrackerSpecific.qll
1 parent 14e384a commit e1dfed0

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPublic.qll

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -336,23 +336,13 @@ module Content {
336336
AttributeNameContent getAttributeName(string name) { result.getName() = name }
337337
}
338338

339-
class OptionalContentSet extends TOptionalContentSet {
340-
/** Gets a textual representation of this content set. */
341-
string toString() {
342-
result = "no content" // overridden in `ContentSet`
343-
}
344-
345-
/** Holds if this is the special "no content set" value. */
346-
predicate isNoContentSet() { this instanceof TNoContentSet }
347-
}
348-
349339
/**
350340
* An entity that represents a set of `Content`s.
351341
*
352342
* The set may be interpreted differently depending on whether it is
353343
* stored into (`getAStoreContent`) or read from (`getAReadContent`).
354344
*/
355-
class ContentSet extends OptionalContentSet, TContentSet {
345+
class ContentSet extends TContentSet {
356346
/** Holds if this content set is the singleton `{c}`. */
357347
predicate isSingleton(Content c) { this = TSingletonContent(c) }
358348

@@ -365,7 +355,8 @@ class ContentSet extends OptionalContentSet, TContentSet {
365355
*/
366356
predicate isElementLowerBound(int lower) { this = TElementLowerBoundContent(lower) }
367357

368-
override string toString() {
358+
/** Gets a textual representation of this content set. */
359+
string toString() {
369360
exists(Content c |
370361
this.isSingleton(c) and
371362
result = c.toString()

ruby/ql/lib/codeql/ruby/typetracking/TypeTrackerSpecific.qll

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ class TypeTrackingNode = DataFlowPublic::LocalSourceNode;
1717

1818
class TypeTrackerContent = DataFlowPublic::ContentSet;
1919

20-
class OptionalTypeTrackerContent = DataFlowPublic::OptionalContentSet;
20+
class OptionalTypeTrackerContent extends DataFlowPrivate::TOptionalContentSet {
21+
/** Gets a textual representation of this content set. */
22+
string toString() {
23+
this instanceof DataFlowPrivate::TNoContentSet and
24+
result = "no content"
25+
or
26+
result = this.(DataFlowPublic::ContentSet).toString()
27+
}
28+
}
2129

2230
/**
2331
* Holds if a value stored with `storeContents` can be read back with `loadContents`.
@@ -28,7 +36,7 @@ predicate compatibleContents(TypeTrackerContent storeContents, TypeTrackerConten
2836
}
2937

3038
/** Gets the "no content set" value to use for a type tracker not inside any content. */
31-
OptionalTypeTrackerContent noContent() { result.isNoContentSet() }
39+
OptionalTypeTrackerContent noContent() { result = DataFlowPrivate::TNoContentSet() }
3240

3341
/** Holds if there is a simple local flow step from `nodeFrom` to `nodeTo` */
3442
predicate simpleLocalFlowStep = DataFlowPrivate::localFlowStepTypeTracker/2;

0 commit comments

Comments
 (0)