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 12
12
13
13
import cpp
14
14
import codingstandards.c.misra
15
- import codingstandards.cpp.ReadErrorsAndEOF
15
+ import codingstandards.cpp.CharFunctions
16
16
import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
17
17
18
- class CtypeFunction extends Function {
19
- CtypeFunction ( ) { this .getADeclaration ( ) .getAFile ( ) .( HeaderFile ) .getBaseName ( ) = "ctype.h" }
20
- }
21
-
22
- from FunctionCall ctypeCall
18
+ from UseOfToOrIsChar ctypeCall
23
19
where
24
20
not isExcluded ( ctypeCall ,
25
21
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 ( )
29
24
|
30
25
/* The argument's value should be in the EOF + `unsigned char` range. */
31
26
- 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
+ )
35
28
select ctypeCall ,
36
29
"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