C++: Further use of TemplateArgumentValue

This commit is contained in:
Matthew Gretton-Dann
2019-10-18 15:29:16 +01:00
parent 6334ad92c5
commit 4ab87291f3
2 changed files with 24 additions and 0 deletions

View File

@@ -197,6 +197,12 @@ abstract class Declaration extends Locatable, @declaration {
*/
final Type getATemplateArgument() { result = getTemplateArgument(_) }
/**
* Gets a template argument used to instantiate this declaration from a template.
* When called on a template, this will return a template parameter value.
*/
final Expr getATemplateArgumentValue() { result = getTemplateArgumentValue(_) }
/**
* Gets the `i`th template argument used to instantiate this declaration from a
* template. When called on a template, this will return the `i`th template parameter.

View File

@@ -141,15 +141,27 @@ class FunctionCall extends Call, @funbindexpr {
/** Gets an explicit template argument for this call. */
Type getAnExplicitTemplateArgument() { result = getExplicitTemplateArgument(_) }
/** Gets an explicit template argument value for this call. */
Expr getAnExplicitTemplateArgumentValue() { result = getExplicitTemplateArgumentValue(_) }
/** Gets a template argument for this call. */
Type getATemplateArgument() { result = getTarget().getATemplateArgument() }
/** Gets a template argument value for this call. */
Expr getATemplateArgumentValue() { result = getTarget().getATemplateArgumentValue() }
/** Gets the nth explicit template argument for this call. */
Type getExplicitTemplateArgument(int n) {
n < getNumberOfExplicitTemplateArguments() and
result = getTemplateArgument(n)
}
/** Gets the nth explicit template argument value for this call. */
Expr getExplicitTemplateArgumentValue(int n) {
n < getNumberOfExplicitTemplateArguments() and
result = getTemplateArgumentValue(n)
}
/** Gets the number of explicit template arguments for this call. */
int getNumberOfExplicitTemplateArguments() {
if numtemplatearguments(underlyingElement(this), _)
@@ -160,9 +172,15 @@ class FunctionCall extends Call, @funbindexpr {
/** Gets the number of template arguments for this call. */
int getNumberOfTemplateArguments() { result = count(int i | exists(getTemplateArgument(i))) }
/** Gets the number of template argument which are values for this call. */
int getNumberOfTemplateArgumentValues() { result = count(int i | exists(getTemplateArgumentValue(i))) }
/** Gets the nth template argument for this call (indexed from 0). */
Type getTemplateArgument(int n) { result = getTarget().getTemplateArgument(n) }
/** Gets the nth template argument value for this call (indexed from 0). */
Expr getTemplateArgumentValue(int n) { result = getTarget().getTemplateArgumentValue(n) }
/** Holds if any template arguments for this call are implicit / deduced. */
predicate hasImplicitTemplateArguments() {
exists(int i |