4
4
*/
5
5
6
6
import cpp
7
- import semmle.code.cpp.models.interfaces.DataFlow
8
- import semmle.code.cpp.models.interfaces.Taint
9
7
10
8
/**
11
9
* A C++ function declared as a member of a class [N4140 9.3]. This includes
@@ -164,7 +162,7 @@ class ConstMemberFunction extends MemberFunction {
164
162
* };
165
163
* ```
166
164
*/
167
- class Constructor extends MemberFunction , TaintFunction {
165
+ class Constructor extends MemberFunction {
168
166
Constructor ( ) { functions ( underlyingElement ( this ) , _, 2 ) }
169
167
170
168
override string getCanonicalQLClass ( ) { result = "Constructor" }
@@ -194,16 +192,6 @@ class Constructor extends MemberFunction, TaintFunction {
194
192
ConstructorInit getInitializer ( int i ) {
195
193
exprparents ( unresolveElement ( result ) , i , underlyingElement ( this ) )
196
194
}
197
-
198
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
199
- // taint flow from any constructor argument to the returned object
200
- exists ( int idx |
201
- input .isParameter ( idx ) and
202
- output .isReturnValue ( ) and
203
- not this .( CopyConstructor ) .hasDataFlow ( input , output ) and // don't duplicate where we have data flow
204
- not this .( MoveConstructor ) .hasDataFlow ( input , output ) // don't duplicate where we have data flow
205
- )
206
- }
207
195
}
208
196
209
197
/**
@@ -278,7 +266,7 @@ private predicate hasMoveSignature(MemberFunction f) {
278
266
* desired instead, see the member predicate
279
267
* `mayNotBeCopyConstructorInInstantiation`.
280
268
*/
281
- class CopyConstructor extends Constructor , DataFlowFunction {
269
+ class CopyConstructor extends Constructor {
282
270
CopyConstructor ( ) {
283
271
hasCopySignature ( this ) and
284
272
(
@@ -310,12 +298,6 @@ class CopyConstructor extends Constructor, DataFlowFunction {
310
298
getDeclaringType ( ) instanceof TemplateClass and
311
299
getNumberOfParameters ( ) > 1
312
300
}
313
-
314
- override predicate hasDataFlow ( FunctionInput input , FunctionOutput output ) {
315
- // data flow from the first constructor argument to the returned object
316
- input .isParameter ( 0 ) and
317
- output .isReturnValue ( )
318
- }
319
301
}
320
302
321
303
/**
@@ -341,7 +323,7 @@ class CopyConstructor extends Constructor, DataFlowFunction {
341
323
* desired instead, see the member predicate
342
324
* `mayNotBeMoveConstructorInInstantiation`.
343
325
*/
344
- class MoveConstructor extends Constructor , DataFlowFunction {
326
+ class MoveConstructor extends Constructor {
345
327
MoveConstructor ( ) {
346
328
hasMoveSignature ( this ) and
347
329
(
@@ -373,12 +355,6 @@ class MoveConstructor extends Constructor, DataFlowFunction {
373
355
getDeclaringType ( ) instanceof TemplateClass and
374
356
getNumberOfParameters ( ) > 1
375
357
}
376
-
377
- override predicate hasDataFlow ( FunctionInput input , FunctionOutput output ) {
378
- // data flow from the first constructor argument to the returned object
379
- input .isParameter ( 0 ) and
380
- output .isReturnValue ( )
381
- }
382
358
}
383
359
384
360
/**
@@ -467,7 +443,7 @@ class ConversionOperator extends MemberFunction, ImplicitConversionFunction {
467
443
* takes exactly one parameter of type `T`, `T&`, `const T&`, `volatile
468
444
* T&`, or `const volatile T&`.
469
445
*/
470
- class CopyAssignmentOperator extends Operator , TaintFunction {
446
+ class CopyAssignmentOperator extends Operator {
471
447
CopyAssignmentOperator ( ) {
472
448
hasName ( "operator=" ) and
473
449
(
@@ -482,17 +458,6 @@ class CopyAssignmentOperator extends Operator, TaintFunction {
482
458
}
483
459
484
460
override string getCanonicalQLClass ( ) { result = "CopyAssignmentOperator" }
485
-
486
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
487
- // taint flow from argument to self
488
- input .isParameterDeref ( 0 ) and
489
- output .isQualifierObject ( )
490
- or
491
- // taint flow from argument to return value
492
- input .isParameterDeref ( 0 ) and
493
- output .isReturnValueDeref ( )
494
- // TODO: it would be more accurate to model copy assignment as data flow
495
- }
496
461
}
497
462
498
463
/**
@@ -510,7 +475,7 @@ class CopyAssignmentOperator extends Operator, TaintFunction {
510
475
* takes exactly one parameter of type `T&&`, `const T&&`, `volatile T&&`,
511
476
* or `const volatile T&&`.
512
477
*/
513
- class MoveAssignmentOperator extends Operator , TaintFunction {
478
+ class MoveAssignmentOperator extends Operator {
514
479
MoveAssignmentOperator ( ) {
515
480
hasName ( "operator=" ) and
516
481
hasMoveSignature ( this ) and
@@ -519,15 +484,4 @@ class MoveAssignmentOperator extends Operator, TaintFunction {
519
484
}
520
485
521
486
override string getCanonicalQLClass ( ) { result = "MoveAssignmentOperator" }
522
-
523
- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
524
- // taint flow from argument to self
525
- input .isParameterDeref ( 0 ) and
526
- output .isQualifierObject ( )
527
- or
528
- // taint flow from argument to return value
529
- input .isParameterDeref ( 0 ) and
530
- output .isReturnValueDeref ( )
531
- // TODO: it would be more accurate to model move assignment as data flow
532
- }
533
487
}
0 commit comments