@@ -20,31 +20,23 @@ class CtypeFunction extends Function {
2020 CtypeFunction ( ) { this .getADeclaration ( ) .getAFile ( ) .( HeaderFile ) .getShortName ( ) = "_ctype" }
2121}
2222
23- predicate unsignedCharRange ( int lower , int upper , EOFInvocation eof ) {
24- exists ( UnsignedCharType unsignedChar |
25- lower = typeLowerBound ( unsignedChar ) and
26- upper = upperBound ( eof .getExpr ( ) ) and
27- typeLowerBound ( unsignedChar ) <= lowerBound ( eof .getExpr ( ) ) and
28- upperBound ( eof .getExpr ( ) ) <= typeUpperBound ( unsignedChar )
29- )
30- }
31-
32- predicate isEquivToEOF ( Expr expr ) {
33- exists ( EOFInvocation eof | DataFlow:: localFlow ( DataFlow:: exprNode ( eof .getExpr ( ) ) , DataFlow:: exprNode ( expr ) ) )
34- }
35-
3623from FunctionCall ctypeCall
3724where
3825 not isExcluded ( ctypeCall ,
3926 StandardLibraryFunctionTypesPackage:: ctypeFunctionArgNotUnsignedCharOrEofQuery ( ) ) and
40- exists ( CtypeFunction ctype , UnsignedCharType unsignedChar |
27+ not exists ( CtypeFunction ctype , UnsignedCharType unsignedChar |
4128 ctypeCall = ctype .getACallToThisFunction ( )
4229 |
43- /* The argument's value should be in the `unsigned char` range. */
30+ /* The argument's value should be in the `unsigned char` range. */
4431 typeLowerBound ( unsignedChar ) <= lowerBound ( ctypeCall .getAnArgument ( ) .getExplicitlyConverted ( ) ) and // consider casts
4532 upperBound ( ctypeCall .getAnArgument ( ) .getExplicitlyConverted ( ) ) <= typeUpperBound ( unsignedChar )
4633 or
47- /* The argument's value is reachable from EOF. */
48- exists ( EOFInvocation eof | DataFlow:: localFlow ( DataFlow:: exprNode ( eof .getExpr ( ) ) , DataFlow:: exprNode ( ctypeCall .getAnArgument ( ) ) ) )
34+ /* The argument's value is reachable from EOF. */
35+ exists ( EOFInvocation eof |
36+ DataFlow:: localFlow ( DataFlow:: exprNode ( eof .getExpr ( ) ) ,
37+ DataFlow:: exprNode ( ctypeCall .getAnArgument ( ) ) )
38+ )
4939 )
50- select ctypeCall , ctypeCall .getAnArgument ( )
40+ select ctypeCall ,
41+ "The <ctype.h> function $@ accepts an argument $@ that is not unsigned char nor an EOF." ,
42+ ctypeCall , ctypeCall .getTarget ( ) , ctypeCall .getAnArgument ( ) , ctypeCall .getAnArgument ( ) .toString ( )
0 commit comments