@@ -789,6 +789,32 @@ private string getSignatureParameterName(string signature, string type, string n
789789 )
790790}
791791
792+ /**
793+ * Gets a `Function` identified by the `(namespace, type, name)` components.
794+ *
795+ * If `subtypes` is `true` then the result may be an override of the function
796+ * identified by the components.
797+ */
798+ bindingset [ type, name]
799+ private Function getFunction ( string namespace , string type , boolean subtypes , string name ) {
800+ funcHasQualifiedName ( result , namespace , name ) and
801+ subtypes = false and
802+ type = ""
803+ or
804+ exists ( Class namedClass , Class classWithMethod |
805+ hasClassAndName ( classWithMethod , result , name ) and
806+ classHasQualifiedName ( namedClass , namespace , type )
807+ |
808+ // member declared in the named type or a subtype of it
809+ subtypes = true and
810+ classWithMethod = namedClass .getADerivedClass * ( )
811+ or
812+ // member declared directly in the named type
813+ subtypes = false and
814+ classWithMethod = namedClass
815+ )
816+ }
817+
792818/**
793819 * Holds if the suffix containing the entries in `signature` starting at entry
794820 * `i` matches the suffix containing the parameters of `func` starting at entry `i`.
@@ -953,7 +979,7 @@ private predicate funcHasQualifiedName(Function func, string namespace, string n
953979 * Holds if `namedClass` is in namespace `namespace` and has
954980 * name `type` (excluding any template parameters).
955981 */
956- bindingset [ type, namespace ]
982+ bindingset [ type]
957983pragma [ inline_late]
958984private predicate classHasQualifiedName ( Class namedClass , string namespace , string type ) {
959985 exists ( string typeWithoutArgs |
@@ -976,10 +1002,9 @@ pragma[nomagic]
9761002private Element interpretElement0 (
9771003 string namespace , string type , boolean subtypes , string name , string signature
9781004) {
1005+ result = getFunction ( namespace , type , subtypes , name ) and
9791006 (
9801007 // Non-member functions
981- funcHasQualifiedName ( result , namespace , name ) and
982- subtypes = false and
9831008 type = "" and
9841009 (
9851010 elementSpecMatchesSignature ( result , namespace , type , subtypes , name , signature )
@@ -989,52 +1014,36 @@ private Element interpretElement0(
9891014 )
9901015 or
9911016 // Member functions
992- exists ( Class namedClass , Class classWithMethod |
993- hasClassAndName ( classWithMethod , result , name ) and
994- classHasQualifiedName ( namedClass , namespace , type )
995- |
996- (
997- elementSpecMatchesSignature ( result , namespace , type , subtypes , name , signature )
998- or
999- signature = "" and
1000- elementSpec ( namespace , type , subtypes , name , "" , _)
1001- ) and
1002- (
1003- // member declared in the named type or a subtype of it
1004- subtypes = true and
1005- classWithMethod = namedClass .getADerivedClass * ( )
1006- or
1007- // member declared directly in the named type
1008- subtypes = false and
1009- classWithMethod = namedClass
1010- )
1011- )
1017+ elementSpecMatchesSignature ( result , namespace , type , subtypes , name , signature )
10121018 or
1013- elementSpec ( namespace , type , subtypes , name , signature , _) and
1014- // Member variables
10151019 signature = "" and
1016- exists ( Class namedClass , Class classWithMember , MemberVariable member |
1017- member .getName ( ) = name and
1018- member = classWithMember .getAMember ( ) and
1019- namedClass .hasQualifiedName ( namespace , type ) and
1020- result = member
1021- |
1022- // field declared in the named type or a subtype of it (or an extension of any)
1023- subtypes = true and
1024- classWithMember = namedClass .getADerivedClass * ( )
1025- or
1026- // field declared directly in the named type (or an extension of it)
1027- subtypes = false and
1028- classWithMember = namedClass
1029- )
1020+ elementSpec ( namespace , type , subtypes , name , signature , _)
1021+ )
1022+ or
1023+ // Member variables
1024+ elementSpec ( namespace , type , subtypes , name , signature , _) and
1025+ signature = "" and
1026+ exists ( Class namedClass , Class classWithMember , MemberVariable member |
1027+ member .getName ( ) = name and
1028+ member = classWithMember .getAMember ( ) and
1029+ namedClass .hasQualifiedName ( namespace , type ) and
1030+ result = member
1031+ |
1032+ // field declared in the named type or a subtype of it (or an extension of any)
1033+ subtypes = true and
1034+ classWithMember = namedClass .getADerivedClass * ( )
10301035 or
1031- // Global or namespace variables
1032- elementSpec ( namespace , type , subtypes , name , signature , _) and
1033- signature = "" and
1034- type = "" and
1036+ // field declared directly in the named type (or an extension of it)
10351037 subtypes = false and
1036- result = any ( GlobalOrNamespaceVariable v | v . hasQualifiedName ( namespace , name ) )
1038+ classWithMember = namedClass
10371039 )
1040+ or
1041+ // Global or namespace variables
1042+ elementSpec ( namespace , type , subtypes , name , signature , _) and
1043+ signature = "" and
1044+ type = "" and
1045+ subtypes = false and
1046+ result = any ( GlobalOrNamespaceVariable v | v .hasQualifiedName ( namespace , name ) )
10381047}
10391048
10401049cached
0 commit comments