Skip to content

Commit

Permalink
Combine two arms of newtype TSourceOrSinkElement
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-mc committed Oct 25, 2024
1 parent d0833a2 commit 1524075
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,12 @@ module SourceSinkInterpretationInput implements
// Methods having multiple qualified names, a given Method is liable to have
// more than one SourceOrSinkElement, one for each of the names it claims.
private newtype TSourceOrSinkElement =
TMethodEntityElement(Method m, string pkg, string type, boolean subtypes) {
m.hasQualifiedName(pkg, type, _) and subtypes = [true, false]
} or
TFieldEntityElement(Field f, string pkg, string type, boolean subtypes) {
f.hasQualifiedName(pkg, type, _) and subtypes = [true, false]
TMethodOrFieldEntityElement(Entity e, string pkg, string type, boolean subtypes) {
(
e.(Method).hasQualifiedName(pkg, type, _) or
e.(Field).hasQualifiedName(pkg, type, _)
) and
subtypes = [true, false]
} or
TOtherEntityElement(Entity e) {
not e instanceof Method and
Expand All @@ -169,8 +170,7 @@ module SourceSinkInterpretationInput implements
class SourceOrSinkElement extends TSourceOrSinkElement {
/** Gets this source or sink element as an entity, if it is one. */
Entity asEntity() {
this = TMethodEntityElement(result, _, _, _) or
this = TFieldEntityElement(result, _, _, _) or
this = TMethodOrFieldEntityElement(result, _, _, _) or
this = TOtherEntityElement(result)
}

Expand All @@ -182,8 +182,7 @@ module SourceSinkInterpretationInput implements
* with the given values for `pkg`, `type` and `subtypes`.
*/
predicate hasTypeInfo(string pkg, string type, boolean subtypes) {
this = TMethodEntityElement(_, pkg, type, subtypes) or
this = TFieldEntityElement(_, pkg, type, subtypes)
this = TMethodOrFieldEntityElement(_, pkg, type, subtypes)
}

/** Gets a textual representation of this source or sink element. */
Expand Down

0 comments on commit 1524075

Please sign in to comment.