@@ -14,15 +14,35 @@ import cpp
1414import codingstandards.c.misra
1515import codingstandards.c.Pointers
1616
17- class MemCmpMoveCpy extends BuiltInFunction {
18- MemCmpMoveCpy ( ) { this .getName ( ) .regexpMatch ( ".+mem(cmp|cpy|move).+" ) }
17+ class MemCmpMoveCpy extends Function {
18+ // Couldn't extend BuiltInFunction because it misses `memcmp`
19+ MemCmpMoveCpy ( ) { this .getName ( ) .regexpMatch ( "mem(cmp|cpy|move)" ) }
20+ }
21+
22+ query predicate memfunArgTypes ( FunctionCall fc , Type dstType , Type srcType ) {
23+ (
24+ fc .getArgument ( 0 ) .getUnspecifiedType ( ) instanceof PointerType and
25+ fc .getArgument ( 1 ) .getUnspecifiedType ( ) instanceof PointerType
26+ or
27+ fc .getArgument ( 0 ) .getUnspecifiedType ( ) instanceof ArrayType and
28+ fc .getArgument ( 1 ) .getUnspecifiedType ( ) instanceof ArrayType
29+ ) and
30+ dstType = fc .getArgument ( 0 ) .getUnspecifiedType ( ) and
31+ srcType = fc .getArgument ( 1 ) .getUnspecifiedType ( )
1932}
2033
2134from FunctionCall fc
2235where
2336 not isExcluded ( fc ,
2437 StandardLibraryFunctionTypesPackage:: memcpyMemmoveMemcmpArgNotPointersToCompatibleTypesQuery ( ) ) and
2538 exists ( MemCmpMoveCpy memfun | fc .getTarget ( ) = memfun |
39+ (
40+ fc .getArgument ( 0 ) .getUnspecifiedType ( ) instanceof PointerType and
41+ fc .getArgument ( 1 ) .getUnspecifiedType ( ) instanceof PointerType
42+ or
43+ fc .getArgument ( 0 ) .getUnspecifiedType ( ) instanceof ArrayType and
44+ fc .getArgument ( 1 ) .getUnspecifiedType ( ) instanceof ArrayType
45+ ) and
2646 fc .getArgument ( 0 ) .getUnspecifiedType ( ) = fc .getArgument ( 1 ) .getUnspecifiedType ( )
2747 )
2848select fc , fc .getArgument ( 0 ) .getUnspecifiedType ( ) , fc .getArgument ( 1 ) .getUnspecifiedType ( )
0 commit comments