Skip to content

Commit 7f49059

Browse files
committed
Addressing review comments
Reduced the category to minorAnalysis. Handled bools via a instanceof with BoolType. Formatted the query correctly.
1 parent f01737a commit 7f49059

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212
import cpp
1313

1414
predicate allowedTypedefs(TypedefType t) {
15-
t.getName() = ["I64", "U64", "I32", "U32", "I16", "U16", "I8", "U8", "F64", "F32",
16-
"int64_t", "uint64_t", "int32_t", "uint32_t", "int16_t", "uint16_t", "int8_t", "uint8_t"]
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+
]
1720
}
1821

1922
/**
@@ -39,14 +42,16 @@ Type getAUsedType(Type t) {
3942
}
4043

4144
predicate problematic(IntegralType t) {
42-
// 'bool' is allowed as it represents a 'true' or 'false' value
43-
t.getName() != ["bool"]
45+
// List any exceptions that should be allowed.
46+
any()
4447
}
4548

4649
from Declaration d, Type usedType
4750
where
4851
usedType = getAUsedType*(getAnImmediateUsedType(d)) and
4952
problematic(usedType) and
53+
// Allow uses of boolean types where defined by the language.
54+
not usedType instanceof BoolType and
5055
// Ignore violations for which we do not have a valid location.
5156
not d.getLocation() instanceof UnknownLocation
5257
select d,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
2-
category: majorAnalysis
2+
category: minorAnalysis
33
---
4-
* The query "Basic Integral Types" in JPL_C has been updated to allow C standard integer types (uint8_t etc.) and 'bool'.
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.

0 commit comments

Comments
 (0)