Skip to content

Commit bd83048

Browse files
committed
Reuse SpecialMemberFunction class
1 parent a48c7cc commit bd83048

File tree

1 file changed

+4
-31
lines changed

1 file changed

+4
-31
lines changed

cpp/common/src/codingstandards/cpp/deadcode/UnusedFunctions.qll

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import cpp
1313
import codingstandards.cpp.DynamicCallGraph
1414
import codingstandards.cpp.EncapsulatingFunctions
1515
import codingstandards.cpp.FunctionEquivalence
16+
import codingstandards.cpp.Class
1617

1718
module UnusedFunctions {
1819
/**
@@ -75,9 +76,7 @@ module UnusedFunctions {
7576
*/
7677

7778
private class MainLikeFunctionEntryPoint extends EntryPoint, MainLikeFunction {
78-
MainLikeFunctionEntryPoint() {
79-
this instanceof MainLikeFunction or this instanceof GTestFunction
80-
}
79+
MainLikeFunctionEntryPoint() { this instanceof MainLikeFunction }
8180

8281
override Function getAReachableFunction() { reachable*(this, result) }
8382
}
@@ -113,26 +112,6 @@ module UnusedFunctions {
113112
}
114113
}
115114

116-
/**
117-
* A `MemberFunction` which is either a Default constructor, Destructor
118-
* CopyConstructor, CopyAssingmentOperator, MoveConstructor or a
119-
* MoveAssignmentOperator
120-
*/
121-
predicate isASpecialMemberFunction(MemberFunction f) {
122-
// Default constructor
123-
f instanceof NoArgConstructor
124-
or
125-
f instanceof Destructor
126-
or
127-
f instanceof CopyConstructor
128-
or
129-
f instanceof CopyAssignmentOperator
130-
or
131-
f instanceof MoveConstructor
132-
or
133-
f instanceof MoveAssignmentOperator
134-
}
135-
136115
/**
137116
* A `Function` which is not used from an `EntryPoint`.
138117
*
@@ -156,12 +135,6 @@ module UnusedFunctions {
156135
}
157136
}
158137

159-
/**
160-
* A Special `MemberFunction` which is an `UnusedFunction`.
161-
*
162-
* Refer isASpecialMemberFunction predicate.
163-
*/
164-
class UnusedSplMemberFunction extends UnusedFunction {
165-
UnusedSplMemberFunction() { isASpecialMemberFunction(this) }
166-
}
138+
/** A `SpecialMemberFunction` which is an `UnusedFunction`. */
139+
class UnusedSplMemberFunction extends UnusedFunction, SpecialMemberFunction { }
167140
}

0 commit comments

Comments
 (0)