@@ -596,6 +596,14 @@ private string getAtIndex(string s, int i) {
596596 not ( s = "" and i = 0 )
597597}
598598
599+ /** Gets the number of comma-separated arguments in `s`. */
600+ bindingset [ s]
601+ private int getNumberOfArguments ( string s ) {
602+ s = "" and result = 0
603+ or
604+ s != "" and result = count ( s .indexOf ( "," ) ) + 1
605+ }
606+
599607/**
600608 * Normalizes `partiallyNormalizedSignature` by replacing the `remaining`
601609 * number of template arguments in `partiallyNormalizedSignature` with their
@@ -605,7 +613,7 @@ private string getSignatureWithoutClassTemplateNames(
605613 string partiallyNormalizedSignature , string typeArgs , string nameArgs , int remaining
606614) {
607615 elementSpecWithArguments0 ( _, _, _, partiallyNormalizedSignature , typeArgs , nameArgs ) and
608- remaining = count ( partiallyNormalizedSignature . indexOf ( "," ) ) + 1 and
616+ remaining = getNumberOfArguments ( typeArgs ) and
609617 result = partiallyNormalizedSignature
610618 or
611619 exists ( string mid |
@@ -619,7 +627,7 @@ private string getSignatureWithoutClassTemplateNames(
619627 )
620628 or
621629 // Make sure `remaining` is properly bound
622- remaining = [ 0 .. count ( partiallyNormalizedSignature . indexOf ( "," ) ) + 1 ] and
630+ remaining = [ 0 .. getNumberOfArguments ( typeArgs ) ] and
623631 not exists ( getAtIndex ( typeArgs , remaining ) ) and
624632 result = mid
625633 )
@@ -636,7 +644,7 @@ pragma[nomagic]
636644private string getSignatureWithoutFunctionTemplateNames (
637645 string partiallyNormalizedSignature , string typeArgs , string nameArgs , int remaining
638646) {
639- remaining = count ( partiallyNormalizedSignature . indexOf ( "," ) ) + 1 and
647+ remaining = getNumberOfArguments ( nameArgs ) and
640648 result =
641649 getSignatureWithoutClassTemplateNames ( partiallyNormalizedSignature , typeArgs , nameArgs , 0 )
642650 or
@@ -651,7 +659,7 @@ private string getSignatureWithoutFunctionTemplateNames(
651659 )
652660 or
653661 // Make sure `remaining` is properly bound
654- remaining = [ 0 .. count ( partiallyNormalizedSignature . indexOf ( "," ) ) + 1 ] and
662+ remaining = [ 0 .. getNumberOfArguments ( nameArgs ) ] and
655663 not exists ( getAtIndex ( nameArgs , remaining ) ) and
656664 result = mid
657665 )
0 commit comments