@@ -465,7 +465,7 @@ private predicate isFunctionConstructedFrom(Function f, Function templateFunc) {
465
465
}
466
466
467
467
/** Gets the fully templated version of `f`. */
468
- private Function getFullyTemplatedFunction ( Function f ) {
468
+ Function getFullyTemplatedFunction ( Function f ) {
469
469
not f .isFromUninstantiatedTemplate ( _) and
470
470
(
471
471
exists ( Class c , Class templateClass , int i |
@@ -559,27 +559,35 @@ private string getTypeName(Type t, boolean needsSpace) {
559
559
560
560
/**
561
561
* Gets a type name for the `n`'th parameter of `f` without any template
562
- * arguments. The result may be a string representing a type for which the
563
- * typedefs have been resolved.
562
+ * arguments.
563
+ *
564
+ * If `canonical = false` then the result may be a string representing a type
565
+ * for which the typedefs have been resolved. If `canonical = true` then the
566
+ * result will be a string representing a type without resolving `typedefs`.
564
567
*/
565
568
bindingset [ f]
566
569
pragma [ inline_late]
567
- string getParameterTypeWithoutTemplateArguments ( Function f , int n ) {
570
+ string getParameterTypeWithoutTemplateArguments ( Function f , int n , boolean canonical ) {
568
571
exists ( string s , string base , string specifiers , Type t |
569
572
t = f .getParameter ( n ) .getType ( ) and
570
573
// The name of the string can either be the possibly typedefed name
571
574
// or an alternative name where typedefs has been resolved.
572
575
// `getTypeName(t, _)` is almost equal to `t.resolveTypedefs().getName()`,
573
576
// except that `t.resolveTypedefs()` doesn't have a result when the
574
577
// resulting type doesn't appear in the database.
575
- s = [ t .getName ( ) , getTypeName ( t , _) ] and
578
+ (
579
+ s = t .getName ( ) and canonical = true
580
+ or
581
+ s = getTypeName ( t , _) and canonical = false
582
+ ) and
576
583
parseAngles ( s , base , _, specifiers ) and
577
584
result = base + specifiers
578
585
)
579
586
or
580
587
f .isVarargs ( ) and
581
588
n = f .getNumberOfParameters ( ) and
582
- result = "..."
589
+ result = "..." and
590
+ canonical = true
583
591
}
584
592
585
593
/**
@@ -590,7 +598,7 @@ private string getTypeNameWithoutFunctionTemplates(Function f, int n, int remain
590
598
exists ( Function templateFunction |
591
599
templateFunction = getFullyTemplatedFunction ( f ) and
592
600
remaining = templateFunction .getNumberOfTemplateArguments ( ) and
593
- result = getParameterTypeWithoutTemplateArguments ( templateFunction , n )
601
+ result = getParameterTypeWithoutTemplateArguments ( templateFunction , n , _ )
594
602
)
595
603
or
596
604
exists ( string mid , TypeTemplateParameter tp , Function templateFunction |
@@ -627,7 +635,7 @@ private string getTypeNameWithoutClassTemplates(Function f, int n, int remaining
627
635
}
628
636
629
637
/** Gets the string representation of the `i`'th parameter of `c`. */
630
- private string getParameterTypeName ( Function c , int i ) {
638
+ string getParameterTypeName ( Function c , int i ) {
631
639
result = getTypeNameWithoutClassTemplates ( c , i , 0 )
632
640
}
633
641
0 commit comments