44 */
55
66import cpp
7- import semmle.code.cpp.models.interfaces.DataFlow
8- import semmle.code.cpp.models.interfaces.Taint
97
108/**
119 * A C++ function declared as a member of a class [N4140 9.3]. This includes
@@ -164,7 +162,7 @@ class ConstMemberFunction extends MemberFunction {
164162 * };
165163 * ```
166164 */
167- class Constructor extends MemberFunction , TaintFunction {
165+ class Constructor extends MemberFunction {
168166 Constructor ( ) { functions ( underlyingElement ( this ) , _, 2 ) }
169167
170168 override string getCanonicalQLClass ( ) { result = "Constructor" }
@@ -194,16 +192,6 @@ class Constructor extends MemberFunction, TaintFunction {
194192 ConstructorInit getInitializer ( int i ) {
195193 exprparents ( unresolveElement ( result ) , i , underlyingElement ( this ) )
196194 }
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- }
207195}
208196
209197/**
@@ -278,7 +266,7 @@ private predicate hasMoveSignature(MemberFunction f) {
278266 * desired instead, see the member predicate
279267 * `mayNotBeCopyConstructorInInstantiation`.
280268 */
281- class CopyConstructor extends Constructor , DataFlowFunction {
269+ class CopyConstructor extends Constructor {
282270 CopyConstructor ( ) {
283271 hasCopySignature ( this ) and
284272 (
@@ -310,12 +298,6 @@ class CopyConstructor extends Constructor, DataFlowFunction {
310298 getDeclaringType ( ) instanceof TemplateClass and
311299 getNumberOfParameters ( ) > 1
312300 }
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- }
319301}
320302
321303/**
@@ -341,7 +323,7 @@ class CopyConstructor extends Constructor, DataFlowFunction {
341323 * desired instead, see the member predicate
342324 * `mayNotBeMoveConstructorInInstantiation`.
343325 */
344- class MoveConstructor extends Constructor , DataFlowFunction {
326+ class MoveConstructor extends Constructor {
345327 MoveConstructor ( ) {
346328 hasMoveSignature ( this ) and
347329 (
@@ -373,12 +355,6 @@ class MoveConstructor extends Constructor, DataFlowFunction {
373355 getDeclaringType ( ) instanceof TemplateClass and
374356 getNumberOfParameters ( ) > 1
375357 }
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- }
382358}
383359
384360/**
@@ -467,7 +443,7 @@ class ConversionOperator extends MemberFunction, ImplicitConversionFunction {
467443 * takes exactly one parameter of type `T`, `T&`, `const T&`, `volatile
468444 * T&`, or `const volatile T&`.
469445 */
470- class CopyAssignmentOperator extends Operator , TaintFunction {
446+ class CopyAssignmentOperator extends Operator {
471447 CopyAssignmentOperator ( ) {
472448 hasName ( "operator=" ) and
473449 (
@@ -482,17 +458,6 @@ class CopyAssignmentOperator extends Operator, TaintFunction {
482458 }
483459
484460 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- }
496461}
497462
498463/**
@@ -510,7 +475,7 @@ class CopyAssignmentOperator extends Operator, TaintFunction {
510475 * takes exactly one parameter of type `T&&`, `const T&&`, `volatile T&&`,
511476 * or `const volatile T&&`.
512477 */
513- class MoveAssignmentOperator extends Operator , TaintFunction {
478+ class MoveAssignmentOperator extends Operator {
514479 MoveAssignmentOperator ( ) {
515480 hasName ( "operator=" ) and
516481 hasMoveSignature ( this ) and
@@ -519,15 +484,4 @@ class MoveAssignmentOperator extends Operator, TaintFunction {
519484 }
520485
521486 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- }
533487}
0 commit comments