File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed
c/misra/src/rules/RULE-21-13 Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change 1212
1313import cpp
1414import codingstandards.c.misra
15- import codingstandards.cpp.ReadErrorsAndEOF
15+ import codingstandards.cpp.CharFunctions
1616import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
1717
18- class CtypeFunction extends Function {
19- CtypeFunction ( ) { this .getADeclaration ( ) .getAFile ( ) .( HeaderFile ) .getBaseName ( ) = "ctype.h" }
20- }
21-
22- from FunctionCall ctypeCall
18+ from UseOfToOrIsChar ctypeCall
2319where
2420 not isExcluded ( ctypeCall ,
2521 StandardLibraryFunctionTypesPackage:: ctypeFunctionArgNotUnsignedCharOrEofQuery ( ) ) and
26- not exists ( CtypeFunction ctype , Expr ctypeCallArgument |
27- ctype = ctypeCall .getTarget ( ) and
28- ctypeCallArgument = ctypeCall .getAnArgument ( ) .getExplicitlyConverted ( )
22+ not exists ( Expr ctypeCallArgument |
23+ ctypeCallArgument = ctypeCall .getConvertedArgument ( ) .getExplicitlyConverted ( )
2924 |
3025 /* The argument's value should be in the EOF + `unsigned char` range. */
3126 - 1 <= lowerBound ( ctypeCallArgument ) and upperBound ( ctypeCallArgument ) <= 255
32- ) and
33- /* Only report control flow that is feasible (to avoid <ctype.h> functions implemented as macro). */
34- ctypeCall .getBasicBlock ( ) .isReachable ( )
27+ )
3528select ctypeCall ,
3629 "The <ctype.h> function " + ctypeCall + " accepts an argument " +
37- ctypeCall .getAnArgument ( ) .toString ( ) + " that is not an unsigned char nor an EOF."
30+ ctypeCall .getConvertedArgument ( ) .toString ( ) + " that is not an unsigned char nor an EOF."
You can’t perform that action at this time.
0 commit comments