Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7f54379

Browse files
committed
C++: Make more function models private (except a few that are used outside the library).
1 parent 9249444 commit 7f54379

21 files changed

Lines changed: 117 additions & 117 deletions

cpp/ql/src/semmle/code/cpp/models/implementations/Allocation.qll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import semmle.code.cpp.models.interfaces.Allocation
1010
* An allocation function (such as `malloc`) that has an argument for the size
1111
* in bytes.
1212
*/
13-
class MallocAllocationFunction extends AllocationFunction {
13+
private class MallocAllocationFunction extends AllocationFunction {
1414
int sizeArg;
1515

1616
MallocAllocationFunction() {
@@ -112,7 +112,7 @@ class MallocAllocationFunction extends AllocationFunction {
112112
* An allocation function (such as `alloca`) that does not require a
113113
* corresponding free (and has an argument for the size in bytes).
114114
*/
115-
class AllocaAllocationFunction extends AllocationFunction {
115+
private class AllocaAllocationFunction extends AllocationFunction {
116116
int sizeArg;
117117

118118
AllocaAllocationFunction() {
@@ -137,7 +137,7 @@ class AllocaAllocationFunction extends AllocationFunction {
137137
* An allocation function (such as `calloc`) that has an argument for the size
138138
* and another argument for the size of those units (in bytes).
139139
*/
140-
class CallocAllocationFunction extends AllocationFunction {
140+
private class CallocAllocationFunction extends AllocationFunction {
141141
int sizeArg;
142142
int multArg;
143143

@@ -158,7 +158,7 @@ class CallocAllocationFunction extends AllocationFunction {
158158
* An allocation function (such as `realloc`) that has an argument for the size
159159
* in bytes, and an argument for an existing pointer that is to be reallocated.
160160
*/
161-
class ReallocAllocationFunction extends AllocationFunction {
161+
private class ReallocAllocationFunction extends AllocationFunction {
162162
int sizeArg;
163163
int reallocArg;
164164

@@ -197,7 +197,7 @@ class ReallocAllocationFunction extends AllocationFunction {
197197
* A miscellaneous allocation function that has no explicit argument for
198198
* the size of the allocation.
199199
*/
200-
class SizelessAllocationFunction extends AllocationFunction {
200+
private class SizelessAllocationFunction extends AllocationFunction {
201201
SizelessAllocationFunction() {
202202
exists(string name |
203203
hasGlobalName(name) and
@@ -302,7 +302,7 @@ private predicate deconstructSizeExpr(Expr sizeExpr, Expr lengthExpr, int sizeof
302302
/**
303303
* An allocation expression that is a function call, such as call to `malloc`.
304304
*/
305-
class CallAllocationExpr extends AllocationExpr, FunctionCall {
305+
private class CallAllocationExpr extends AllocationExpr, FunctionCall {
306306
AllocationFunction target;
307307

308308
CallAllocationExpr() {
@@ -353,7 +353,7 @@ class CallAllocationExpr extends AllocationExpr, FunctionCall {
353353
/**
354354
* An allocation expression that is a `new` expression.
355355
*/
356-
class NewAllocationExpr extends AllocationExpr, NewExpr {
356+
private class NewAllocationExpr extends AllocationExpr, NewExpr {
357357
NewAllocationExpr() { this instanceof NewExpr }
358358

359359
override int getSizeBytes() { result = getAllocatedType().getSize() }
@@ -366,7 +366,7 @@ class NewAllocationExpr extends AllocationExpr, NewExpr {
366366
/**
367367
* An allocation expression that is a `new []` expression.
368368
*/
369-
class NewArrayAllocationExpr extends AllocationExpr, NewArrayExpr {
369+
private class NewArrayAllocationExpr extends AllocationExpr, NewArrayExpr {
370370
NewArrayAllocationExpr() { this instanceof NewArrayExpr }
371371

372372
override Expr getSizeExpr() {

cpp/ql/src/semmle/code/cpp/models/implementations/Deallocation.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import semmle.code.cpp.models.interfaces.Deallocation
99
/**
1010
* A deallocation function such as `free`.
1111
*/
12-
class StandardDeallocationFunction extends DeallocationFunction {
12+
private class StandardDeallocationFunction extends DeallocationFunction {
1313
int freedArg;
1414

1515
StandardDeallocationFunction() {
@@ -114,7 +114,7 @@ class OperatorDeleteDeallocationFunction extends DeallocationFunction {
114114
/**
115115
* An deallocation expression that is a function call, such as call to `free`.
116116
*/
117-
class CallDeallocationExpr extends DeallocationExpr, FunctionCall {
117+
private class CallDeallocationExpr extends DeallocationExpr, FunctionCall {
118118
DeallocationFunction target;
119119

120120
CallDeallocationExpr() { target = getTarget() }
@@ -125,7 +125,7 @@ class CallDeallocationExpr extends DeallocationExpr, FunctionCall {
125125
/**
126126
* An deallocation expression that is a `delete` expression.
127127
*/
128-
class DeleteDeallocationExpr extends DeallocationExpr, DeleteExpr {
128+
private class DeleteDeallocationExpr extends DeallocationExpr, DeleteExpr {
129129
DeleteDeallocationExpr() { this instanceof DeleteExpr }
130130

131131
override Expr getFreedExpr() { result = getExpr() }
@@ -134,7 +134,7 @@ class DeleteDeallocationExpr extends DeallocationExpr, DeleteExpr {
134134
/**
135135
* An deallocation expression that is a `delete []` expression.
136136
*/
137-
class DeleteArrayDeallocationExpr extends DeallocationExpr, DeleteArrayExpr {
137+
private class DeleteArrayDeallocationExpr extends DeallocationExpr, DeleteArrayExpr {
138138
DeleteArrayDeallocationExpr() { this instanceof DeleteArrayExpr }
139139

140140
override Expr getFreedExpr() { result = getExpr() }

cpp/ql/src/semmle/code/cpp/models/implementations/Fread.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import semmle.code.cpp.models.interfaces.Alias
22
import semmle.code.cpp.models.interfaces.FlowSource
33

4-
class Fread extends AliasFunction, RemoteFlowFunction {
4+
private class Fread extends AliasFunction, RemoteFlowFunction {
55
Fread() { this.hasGlobalName("fread") }
66

77
override predicate parameterNeverEscapes(int n) {

cpp/ql/src/semmle/code/cpp/models/implementations/GetDelim.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import semmle.code.cpp.models.interfaces.FlowSource
66
/**
77
* The standard functions `getdelim`, `getwdelim` and the glibc variant `__getdelim`.
88
*/
9-
class GetDelimFunction extends TaintFunction, AliasFunction, SideEffectFunction, RemoteFlowFunction {
9+
private class GetDelimFunction extends TaintFunction, AliasFunction, SideEffectFunction, RemoteFlowFunction {
1010
GetDelimFunction() { hasGlobalName(["getdelim", "getwdelim", "__getdelim"]) }
1111

1212
override predicate hasTaintFlow(FunctionInput i, FunctionOutput o) {

cpp/ql/src/semmle/code/cpp/models/implementations/Gets.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import semmle.code.cpp.models.interfaces.FlowSource
1313
/**
1414
* The standard functions `gets` and `fgets`.
1515
*/
16-
class GetsFunction extends DataFlowFunction, TaintFunction, ArrayFunction, AliasFunction,
16+
private class GetsFunction extends DataFlowFunction, TaintFunction, ArrayFunction, AliasFunction,
1717
SideEffectFunction, RemoteFlowFunction {
1818
GetsFunction() {
1919
// gets(str)

cpp/ql/src/semmle/code/cpp/models/implementations/IdentityFunction.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import semmle.code.cpp.models.interfaces.SideEffect
66
/**
77
* The standard function templates `std::move` and `std::forward`.
88
*/
9-
class IdentityFunction extends DataFlowFunction, SideEffectFunction, AliasFunction {
9+
private class IdentityFunction extends DataFlowFunction, SideEffectFunction, AliasFunction {
1010
IdentityFunction() {
1111
this.getNamespace().getParentNamespace() instanceof GlobalNamespace and
1212
this.getNamespace().getName() = "std" and

cpp/ql/src/semmle/code/cpp/models/implementations/Inet.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import semmle.code.cpp.models.interfaces.Taint
22
import semmle.code.cpp.models.interfaces.ArrayFunction
33

4-
class InetNtoa extends TaintFunction {
4+
private class InetNtoa extends TaintFunction {
55
InetNtoa() { hasGlobalName("inet_ntoa") }
66

77
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
@@ -10,7 +10,7 @@ class InetNtoa extends TaintFunction {
1010
}
1111
}
1212

13-
class InetAton extends TaintFunction, ArrayFunction {
13+
private class InetAton extends TaintFunction, ArrayFunction {
1414
InetAton() { hasGlobalName("inet_aton") }
1515

1616
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
@@ -30,7 +30,7 @@ class InetAton extends TaintFunction, ArrayFunction {
3030
}
3131
}
3232

33-
class InetAddr extends TaintFunction, ArrayFunction, AliasFunction {
33+
private class InetAddr extends TaintFunction, ArrayFunction, AliasFunction {
3434
InetAddr() { hasGlobalName("inet_addr") }
3535

3636
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
@@ -49,7 +49,7 @@ class InetAddr extends TaintFunction, ArrayFunction, AliasFunction {
4949
override predicate parameterIsAlwaysReturned(int index) { none() }
5050
}
5151

52-
class InetNetwork extends TaintFunction, ArrayFunction {
52+
private class InetNetwork extends TaintFunction, ArrayFunction {
5353
InetNetwork() { hasGlobalName("inet_network") }
5454

5555
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
@@ -62,7 +62,7 @@ class InetNetwork extends TaintFunction, ArrayFunction {
6262
override predicate hasArrayWithNullTerminator(int bufParam) { bufParam = 0 }
6363
}
6464

65-
class InetMakeaddr extends TaintFunction {
65+
private class InetMakeaddr extends TaintFunction {
6666
InetMakeaddr() { hasGlobalName("inet_makeaddr") }
6767

6868
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
@@ -74,7 +74,7 @@ class InetMakeaddr extends TaintFunction {
7474
}
7575
}
7676

77-
class InetLnaof extends TaintFunction {
77+
private class InetLnaof extends TaintFunction {
7878
InetLnaof() { hasGlobalName("inet_lnaof") }
7979

8080
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
@@ -83,7 +83,7 @@ class InetLnaof extends TaintFunction {
8383
}
8484
}
8585

86-
class InetNetof extends TaintFunction {
86+
private class InetNetof extends TaintFunction {
8787
InetNetof() { hasGlobalName("inet_netof") }
8888

8989
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
@@ -92,7 +92,7 @@ class InetNetof extends TaintFunction {
9292
}
9393
}
9494

95-
class InetPton extends TaintFunction, ArrayFunction {
95+
private class InetPton extends TaintFunction, ArrayFunction {
9696
InetPton() { hasGlobalName("inet_pton") }
9797

9898
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
@@ -112,7 +112,7 @@ class InetPton extends TaintFunction, ArrayFunction {
112112
override predicate hasArrayWithUnknownSize(int bufParam) { bufParam = 2 }
113113
}
114114

115-
class Gethostbyname extends TaintFunction, ArrayFunction {
115+
private class Gethostbyname extends TaintFunction, ArrayFunction {
116116
Gethostbyname() { hasGlobalName("gethostbyname") }
117117

118118
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
@@ -125,7 +125,7 @@ class Gethostbyname extends TaintFunction, ArrayFunction {
125125
override predicate hasArrayWithNullTerminator(int bufParam) { bufParam = 0 }
126126
}
127127

128-
class Gethostbyaddr extends TaintFunction, ArrayFunction {
128+
private class Gethostbyaddr extends TaintFunction, ArrayFunction {
129129
Gethostbyaddr() { hasGlobalName("gethostbyaddr") }
130130

131131
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {

cpp/ql/src/semmle/code/cpp/models/implementations/Iterator.qll

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import semmle.code.cpp.models.interfaces.Iterator
1313
/**
1414
* An instantiation of the `std::iterator_traits` template.
1515
*/
16-
class IteratorTraits extends Class {
16+
private class IteratorTraits extends Class {
1717
IteratorTraits() {
1818
this.hasQualifiedName("std", "iterator_traits") and
1919
not this instanceof TemplateClass and
@@ -29,7 +29,7 @@ class IteratorTraits extends Class {
2929
/**
3030
* A type which has the typedefs expected for an iterator.
3131
*/
32-
class IteratorByTypedefs extends Class {
32+
private class IteratorByTypedefs extends Class {
3333
IteratorByTypedefs() {
3434
this.getAMember().(TypedefType).hasName("difference_type") and
3535
this.getAMember().(TypedefType).hasName("value_type") and
@@ -43,7 +43,7 @@ class IteratorByTypedefs extends Class {
4343
/**
4444
* The `std::iterator` class.
4545
*/
46-
class StdIterator extends Class {
46+
private class StdIterator extends Class {
4747
StdIterator() { this.hasQualifiedName("std", "iterator") }
4848
}
4949

@@ -81,7 +81,7 @@ private FunctionInput getIteratorArgumentInput(Operator op, int index) {
8181
/**
8282
* A non-member prefix `operator*` function for an iterator type.
8383
*/
84-
class IteratorPointerDereferenceOperator extends Operator, TaintFunction, IteratorReferenceFunction {
84+
private class IteratorPointerDereferenceOperator extends Operator, TaintFunction, IteratorReferenceFunction {
8585
FunctionInput iteratorInput;
8686

8787
IteratorPointerDereferenceOperator() {
@@ -101,7 +101,7 @@ class IteratorPointerDereferenceOperator extends Operator, TaintFunction, Iterat
101101
/**
102102
* A non-member `operator++` or `operator--` function for an iterator type.
103103
*/
104-
class IteratorCrementOperator extends Operator, DataFlowFunction {
104+
private class IteratorCrementOperator extends Operator, DataFlowFunction {
105105
FunctionInput iteratorInput;
106106

107107
IteratorCrementOperator() {
@@ -118,7 +118,7 @@ class IteratorCrementOperator extends Operator, DataFlowFunction {
118118
/**
119119
* A non-member `operator+` function for an iterator type.
120120
*/
121-
class IteratorAddOperator extends Operator, TaintFunction {
121+
private class IteratorAddOperator extends Operator, TaintFunction {
122122
FunctionInput iteratorInput;
123123

124124
IteratorAddOperator() {
@@ -135,7 +135,7 @@ class IteratorAddOperator extends Operator, TaintFunction {
135135
/**
136136
* A non-member `operator-` function that takes a pointer difference type as its second argument.
137137
*/
138-
class IteratorSubOperator extends Operator, TaintFunction {
138+
private class IteratorSubOperator extends Operator, TaintFunction {
139139
FunctionInput iteratorInput;
140140

141141
IteratorSubOperator() {
@@ -153,7 +153,7 @@ class IteratorSubOperator extends Operator, TaintFunction {
153153
/**
154154
* A non-member `operator+=` or `operator-=` function for an iterator type.
155155
*/
156-
class IteratorAssignArithmeticOperator extends Operator, DataFlowFunction, TaintFunction {
156+
private class IteratorAssignArithmeticOperator extends Operator, DataFlowFunction, TaintFunction {
157157
IteratorAssignArithmeticOperator() {
158158
this.hasName(["operator+=", "operator-="]) and
159159
this.getDeclaringType() instanceof Iterator
@@ -192,7 +192,7 @@ class IteratorPointerDereferenceMemberOperator extends MemberFunction, TaintFunc
192192
/**
193193
* An `operator++` or `operator--` member function for an iterator type.
194194
*/
195-
class IteratorCrementMemberOperator extends MemberFunction, DataFlowFunction, TaintFunction {
195+
private class IteratorCrementMemberOperator extends MemberFunction, DataFlowFunction, TaintFunction {
196196
IteratorCrementMemberOperator() {
197197
this.hasName(["operator++", "operator--"]) and
198198
this.getDeclaringType() instanceof Iterator
@@ -215,7 +215,7 @@ class IteratorCrementMemberOperator extends MemberFunction, DataFlowFunction, Ta
215215
/**
216216
* A member `operator->` function for an iterator type.
217217
*/
218-
class IteratorFieldMemberOperator extends Operator, TaintFunction {
218+
private class IteratorFieldMemberOperator extends Operator, TaintFunction {
219219
IteratorFieldMemberOperator() {
220220
this.hasName("operator->") and
221221
this.getDeclaringType() instanceof Iterator
@@ -230,7 +230,7 @@ class IteratorFieldMemberOperator extends Operator, TaintFunction {
230230
/**
231231
* An `operator+` or `operator-` member function of an iterator class.
232232
*/
233-
class IteratorBinaryArithmeticMemberOperator extends MemberFunction, TaintFunction {
233+
private class IteratorBinaryArithmeticMemberOperator extends MemberFunction, TaintFunction {
234234
IteratorBinaryArithmeticMemberOperator() {
235235
this.hasName(["operator+", "operator-"]) and
236236
this.getDeclaringType() instanceof Iterator
@@ -245,7 +245,7 @@ class IteratorBinaryArithmeticMemberOperator extends MemberFunction, TaintFuncti
245245
/**
246246
* An `operator+=` or `operator-=` member function of an iterator class.
247247
*/
248-
class IteratorAssignArithmeticMemberOperator extends MemberFunction, DataFlowFunction, TaintFunction {
248+
private class IteratorAssignArithmeticMemberOperator extends MemberFunction, DataFlowFunction, TaintFunction {
249249
IteratorAssignArithmeticMemberOperator() {
250250
this.hasName(["operator+=", "operator-="]) and
251251
this.getDeclaringType() instanceof Iterator
@@ -268,7 +268,7 @@ class IteratorAssignArithmeticMemberOperator extends MemberFunction, DataFlowFun
268268
/**
269269
* An `operator[]` member function of an iterator class.
270270
*/
271-
class IteratorArrayMemberOperator extends MemberFunction, TaintFunction, IteratorReferenceFunction {
271+
private class IteratorArrayMemberOperator extends MemberFunction, TaintFunction, IteratorReferenceFunction {
272272
IteratorArrayMemberOperator() {
273273
this.hasName("operator[]") and
274274
this.getDeclaringType() instanceof Iterator
@@ -287,7 +287,7 @@ class IteratorArrayMemberOperator extends MemberFunction, TaintFunction, Iterato
287287
* The `hasTaintFlow` override provides flow through output iterators that return themselves with
288288
* `operator*` and use their own `operator=` to assign to the container.
289289
*/
290-
class IteratorAssignmentMemberOperator extends MemberFunction, TaintFunction {
290+
private class IteratorAssignmentMemberOperator extends MemberFunction, TaintFunction {
291291
IteratorAssignmentMemberOperator() {
292292
this.hasName("operator=") and
293293
this.getDeclaringType() instanceof Iterator and
@@ -305,7 +305,7 @@ class IteratorAssignmentMemberOperator extends MemberFunction, TaintFunction {
305305
* A `begin` or `end` member function, or a related member function, that
306306
* returns an iterator.
307307
*/
308-
class BeginOrEndFunction extends MemberFunction, TaintFunction, GetIteratorFunction {
308+
private class BeginOrEndFunction extends MemberFunction, TaintFunction, GetIteratorFunction {
309309
BeginOrEndFunction() {
310310
this
311311
.hasName(["begin", "cbegin", "rbegin", "crbegin", "end", "cend", "rend", "crend",
@@ -328,7 +328,7 @@ class BeginOrEndFunction extends MemberFunction, TaintFunction, GetIteratorFunct
328328
* The `std::front_inserter`, `std::inserter`, and `std::back_inserter`
329329
* functions.
330330
*/
331-
class InserterIteratorFunction extends GetIteratorFunction {
331+
private class InserterIteratorFunction extends GetIteratorFunction {
332332
InserterIteratorFunction() {
333333
this.hasQualifiedName("std", ["front_inserter", "inserter", "back_inserter"])
334334
}

0 commit comments

Comments
 (0)