Skip to content

Commit 347c84f

Browse files
authoredDec 18, 2024
Merge pull request #826 from jketema/template-parameters
Update queries after `TemplateParameter` deprecation
2 parents 40d7800 + 065dc01 commit 347c84f

7 files changed

+22
-21
lines changed
 

‎c/misra/src/rules/RULE-2-4/UnusedTagDeclaration.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ where
3232
// `isInMacroExpansion` is broken for `UserType`s.
3333
not s.isInMacroExpansion() and
3434
// Exclude template parameters, in case this is run on C++ code.
35-
not s instanceof TemplateParameter
35+
not s instanceof TypeTemplateParameter
3636
select s, "struct " + s.getName() + " has an unused tag."

‎cpp/autosar/src/rules/A13-3-1/FunctionThatContainsForwardingReferenceAsItsArgumentOverloaded.ql

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import codingstandards.cpp.FunctionEquivalence
1818

1919
class Candidate extends TemplateFunction {
2020
Candidate() {
21-
this.getAParameter().getType().(RValueReferenceType).getBaseType() instanceof TemplateParameter
21+
this.getAParameter().getType().(RValueReferenceType).getBaseType() instanceof
22+
TypeTemplateParameter
2223
}
2324
}
2425

‎cpp/autosar/src/rules/A14-5-2/NonTemplateMemberDefinedInTemplate.ql

+14-14
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import codingstandards.cpp.autosar
1818
import codingstandards.cpp.TypeUses
1919
import codingstandards.cpp.Operator
2020

21-
predicate templateDefinitionMentionsTypeParameter(Declaration d, TemplateParameter tp) {
21+
predicate templateDefinitionMentionsTypeParameter(Declaration d, TypeTemplateParameter tp) {
2222
exists(Type t |
2323
(
2424
// direct reference, e.g., fields.
@@ -50,36 +50,36 @@ predicate templateDefinitionMentionsTypeParameter(Declaration d, TemplateParamet
5050
}
5151

5252
/**
53-
* The set of `TemplateParameter` references within an `Enum`.
53+
* The set of `TypeTemplateParameter` references within an `Enum`.
5454
*/
55-
TemplateParameter enumTemplateReferences(Enum e) {
55+
TypeTemplateParameter enumTemplateReferences(Enum e) {
5656
templateDefinitionMentionsTypeParameter(e.getADeclaration(), result)
5757
or
5858
result = e.getExplicitUnderlyingType()
5959
}
6060

6161
/**
62-
* The set of `TemplateParameter` references within an `Class`.
62+
* The set of `TypeTemplateParameter` references within an `Class`.
6363
*/
64-
TemplateParameter classTemplateReferences(Class c) {
64+
TypeTemplateParameter classTemplateReferences(Class c) {
6565
templateDefinitionMentionsTypeParameter(c.getAMember(), result)
6666
or
6767
c.getADerivation().getBaseType() = result
6868
}
6969

7070
/**
71-
* The set of all of the `TemplateParameter`s referenced by a `EnumConstant`.
71+
* The set of all of the `TypeTemplateParameter`s referenced by a `EnumConstant`.
7272
*/
73-
TemplateParameter enumConstantTemplateReferences(EnumConstant ec) {
73+
TypeTemplateParameter enumConstantTemplateReferences(EnumConstant ec) {
7474
templateDefinitionMentionsTypeParameter(ec.getDeclaringType(), result)
7575
}
7676

7777
/**
78-
* The set of all `TemplateParameter`s referenced by a `Function`.
78+
* The set of all `TypeTemplateParameter`s referenced by a `Function`.
7979
*/
80-
TemplateParameter functionTemplateReferences(Function mf) {
80+
TypeTemplateParameter functionTemplateReferences(Function mf) {
8181
// the type of the function
82-
exists(TemplateParameter tp |
82+
exists(TypeTemplateParameter tp |
8383
result = tp and
8484
(
8585
mf.getType().refersTo(result)
@@ -115,10 +115,10 @@ TemplateParameter functionTemplateReferences(Function mf) {
115115
}
116116

117117
/**
118-
* The set of all `TemplateParameters` available as arguments to the declaring
118+
* The set of all `TypeTemplateParameters` available as arguments to the declaring
119119
* element of some `Declarations`.
120120
*/
121-
TemplateParameter templateParametersOfDeclaringTemplateClass(Declaration d) {
121+
TypeTemplateParameter templateParametersOfDeclaringTemplateClass(Declaration d) {
122122
result = d.getDeclaringType().getATemplateArgument()
123123
}
124124

@@ -149,7 +149,7 @@ where
149149
not d instanceof UserNegationOperator and
150150
// for each declaration within a template class get the
151151
// template parameters of the declaring class
152-
not exists(TemplateParameter t |
152+
not exists(TypeTemplateParameter t |
153153
t = templateParametersOfDeclaringTemplateClass(d) and
154154
// and require that the declaration depends on at least
155155
// one of those template parameters.
@@ -170,7 +170,7 @@ where
170170
) and
171171
// Omit using alias (cf. https://github.com/github/codeql-coding-standards/issues/739)
172172
// Exclude Using alias which refer directly to a TypeParameter
173-
not d.(UsingAliasTypedefType).getBaseType() instanceof TemplateParameter
173+
not d.(UsingAliasTypedefType).getBaseType() instanceof TypeTemplateParameter
174174
select d,
175175
"Member " + d.getName() + " template class does not use any of template arguments of its $@.",
176176
d.getDeclaringType(), "declaring type"

‎cpp/autosar/src/rules/A14-5-3/NonMemberGenericOperatorCondition.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import codingstandards.cpp.autosar
1818
class NonMemberGenericOperator extends TemplateFunction {
1919
NonMemberGenericOperator() {
2020
this instanceof Operator and
21-
exists(TemplateParameter tp, Type pType |
21+
exists(TypeTemplateParameter tp, Type pType |
2222
pType = getAParameter().getType().getUnspecifiedType() //Parameter Type
2323
|
2424
pType = tp or

‎cpp/autosar/src/rules/A7-1-7/IdentifierDeclarationAndInitializationNotOnSeparateLines.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class UniqueLineStmt extends Locatable {
2323
exists(Declaration d |
2424
this = d.getADeclarationEntry() and
2525
not d instanceof Parameter and
26-
not d instanceof TemplateParameter and
26+
not d instanceof TypeTemplateParameter and
2727
// TODO - Needs to be enhanced to solve issues with
2828
// templated inner classes.
2929
not d instanceof Function and

‎cpp/autosar/src/rules/M14-5-3/CopyAssignmentOperatorNotDeclared.ql

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ class TemplateAssignmentOperatorMember extends MemberFunction {
3434
}
3535

3636
/**
37-
* is a copy assigment operator candidate if it has only one param and form in [T, T&, const T&, volatile T&, const volatile T&]
37+
* is a copy assignment operator candidate if it has only one param and form in [T, T&, const T&, volatile T&, const volatile T&]
3838
*/
3939
predicate hasGenericCopyCompatibleParameter() {
40-
exists(TemplateParameter tp, Type pType |
40+
exists(TypeTemplateParameter tp, Type pType |
4141
pType = this.getAParameter().getType().getUnspecifiedType() and //Parameter Type
4242
(
4343
tp = pType //T

‎cpp/common/test/guideline_recategorizations/DisappliedQuery.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ from UserType ut, string reason
1717
where
1818
isExcluded(ut, DeadCodePackage::unusedTypeDeclarationsQuery(), reason) and
1919
exists(ut.getFile()) and
20-
not ut instanceof TemplateParameter and
20+
not ut instanceof TypeTemplateParameter and
2121
not ut instanceof ProxyClass and
2222
not exists(getATypeUse(ut)) and
2323
not ut.isFromUninstantiatedTemplate(_)

0 commit comments

Comments
 (0)