@@ -20,6 +20,7 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
2020 override string getName ( ) { functions ( underlyingElement ( this ) , result , _) }
2121
2222 /**
23+ * DEPRECATED: Use `getIdentityString(Declaration)` from `semmle.code.cpp.Print` instead.
2324 * Gets the full signature of this function, including return type, parameter
2425 * types, and template arguments.
2526 *
@@ -332,18 +333,11 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
332333 }
333334
334335 /**
335- * Gets an argument used to instantiate this class from a template
336- * class.
336+ * Gets the `i`th template argument used to instantiate this function from a
337+ * function template. When called on a function template, this will return the
338+ * `i`th template parameter.
337339 */
338- Type getATemplateArgument ( ) {
339- exists ( int i | this .getTemplateArgument ( i ) = result )
340- }
341-
342- /**
343- * Gets a particular argument used to instantiate this class from a
344- * template class.
345- */
346- Type getTemplateArgument ( int index ) {
340+ override Type getTemplateArgument ( int index ) {
347341 function_template_argument ( underlyingElement ( this ) , index , unresolveElement ( result ) )
348342 }
349343
@@ -1088,8 +1082,19 @@ class TemplateFunction extends Function {
10881082 * A function that is an instantiation of a template.
10891083 */
10901084class FunctionTemplateInstantiation extends Function {
1085+ TemplateFunction tf ;
1086+
10911087 FunctionTemplateInstantiation ( ) {
1092- exists ( TemplateFunction tf | tf .getAnInstantiation ( ) = this )
1088+ tf .getAnInstantiation ( ) = this
1089+ }
1090+
1091+ /**
1092+ * Gets the function template from which this instantiation was instantiated.
1093+ *
1094+ * Example: For `int const& std::min<int>(int const&, int const&)`, returns `T const& min<T>(T const&, T const&)`.
1095+ */
1096+ TemplateFunction getTemplate ( ) {
1097+ result = tf
10931098 }
10941099}
10951100
0 commit comments