@@ -5,7 +5,6 @@ import semmle.code.cpp.Parameter
55import semmle.code.cpp.exprs.Call
66import semmle.code.cpp.metrics.MetricFunction
77import semmle.code.cpp.Linkage
8- private import semmle.code.cpp.internal.IdentityString
98private import semmle.code.cpp.internal.ResolveClass
109
1110/**
@@ -21,6 +20,7 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
2120 override string getName ( ) { functions ( underlyingElement ( this ) , result , _) }
2221
2322 /**
23+ * DEPRECATED: Use `getIdentityString(Declaration)` from `semmle.code.cpp.Print` instead.
2424 * Gets the full signature of this function, including return type, parameter
2525 * types, and template arguments.
2626 *
@@ -33,7 +33,7 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
3333 * "min<int>(int, int) -> int", and the full signature of the uninstantiated
3434 * template on the first line would be "min<T>(T, T) -> T".
3535 */
36- string getFullSignature ( ) {
36+ deprecated string getFullSignature ( ) {
3737 exists ( string name , string templateArgs , string args |
3838 result = name + templateArgs + args + " -> " + getType ( ) .toString ( ) and
3939 name = getQualifiedName ( ) and
@@ -56,48 +56,6 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
5656 )
5757 }
5858
59- override string getIdentityString ( ) {
60- result = getType ( ) .getTypeSpecifier ( ) + getType ( ) .getDeclaratorPrefix ( ) + " " + getScopePrefix ( this ) + getName ( ) + getTemplateArgumentsString ( ) + getDeclaratorSuffixBeforeQualifiers ( ) + getDeclaratorSuffix ( )
61- }
62-
63- language [ monotonicAggregates]
64- private string getTemplateArgumentsString ( ) {
65- if exists ( getATemplateArgument ( ) ) then (
66- result = "<" +
67- concat ( int i |
68- exists ( getTemplateArgument ( i ) ) |
69- getTemplateArgument ( i ) .getTypeIdentityString ( ) , ", " order by i
70- ) + ">"
71- )
72- else
73- result = ""
74- }
75-
76- language [ monotonicAggregates]
77- private string getDeclaratorSuffixBeforeQualifiers ( ) {
78- result = "(" +
79- concat ( int i |
80- exists ( getParameter ( i ) .getType ( ) ) |
81- getParameterTypeString ( getParameter ( i ) .getType ( ) ) , ", " order by i
82- ) + ")" + getQualifierString ( )
83- }
84-
85- private string getQualifierString ( ) {
86- if exists ( getACVQualifier ( ) ) then
87- result = " " + concat ( string qualifier | qualifier = getACVQualifier ( ) | qualifier , " " )
88- else
89- result = ""
90- }
91-
92- private string getACVQualifier ( ) {
93- result = getASpecifier ( ) .getName ( ) and
94- ( result = "const" or result = "volatile" )
95- }
96-
97- private string getDeclaratorSuffix ( ) {
98- result = getType ( ) .getDeclaratorSuffixBeforeQualifiers ( ) + getType ( ) .getDeclaratorSuffix ( )
99- }
100-
10159 /** Gets a specifier of this function. */
10260 override Specifier getASpecifier ( ) {
10361 funspecifiers ( underlyingElement ( this ) , unresolveElement ( result ) )
@@ -1137,6 +1095,11 @@ class FunctionTemplateInstantiation extends Function {
11371095 tf .getAnInstantiation ( ) = this
11381096 }
11391097
1098+ /**
1099+ * Gets the function template from which this instantiation was instantiated.
1100+ *
1101+ * Example: For `min<int>()`, returns `min<T>`.
1102+ */
11401103 TemplateFunction getTemplate ( ) {
11411104 result = tf
11421105 }
0 commit comments