Skip to content

Commit de2fb03

Browse files
authored
Merge pull request #18980 from LeStarch/jpl-c-basic-integral-types-fix
Fixing BasicIntTypes to allow C Standard Integers and 'bool'
2 parents fba7bcd + 7b5d604 commit de2fb03

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

cpp/ql/src/JPL_C/LOC-3/Rule 17/BasicIntTypes.ql

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
import cpp
1313

1414
predicate allowedTypedefs(TypedefType t) {
15-
t.getName() = ["I64", "U64", "I32", "U32", "I16", "U16", "I8", "U8", "F64", "F32"]
15+
t.getName() =
16+
[
17+
"I64", "U64", "I32", "U32", "I16", "U16", "I8", "U8", "F64", "F32", "int64_t", "uint64_t",
18+
"int32_t", "uint32_t", "int16_t", "uint16_t", "int8_t", "uint8_t"
19+
]
1620
}
1721

1822
/**
@@ -46,6 +50,8 @@ from Declaration d, Type usedType
4650
where
4751
usedType = getAUsedType*(getAnImmediateUsedType(d)) and
4852
problematic(usedType) and
53+
// Allow uses of boolean types where defined by the language.
54+
not usedType instanceof BoolType and
4955
// Ignore violations for which we do not have a valid location.
5056
not d.getLocation() instanceof UnknownLocation
5157
select d,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The query "Use of basic integral type" (`cpp/jpl-c/basic-int-types`) no longer produces alerts for the standard fixed width integer types (`int8_t`, `uint8_t`, etc.), and the `_Bool` and `bool` types.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
| test.c:6:26:6:26 | x | x uses the basic integral type unsigned char rather than a typedef with size and signedness. |
2-
| test.c:7:20:7:20 | x | x uses the basic integral type unsigned char rather than a typedef with size and signedness. |
3-
| test.c:10:16:10:20 | test7 | test7 uses the basic integral type unsigned char rather than a typedef with size and signedness. |

0 commit comments

Comments
 (0)