Skip to content

Commit c25057d

Browse files
committed
Add sizeOfInt() predicate
For determining the size of int on the given platform.
1 parent a2d7ee3 commit c25057d

File tree

1 file changed

+13
-0
lines changed
  • cpp/common/src/codingstandards/cpp/types

1 file changed

+13
-0
lines changed

cpp/common/src/codingstandards/cpp/types/Type.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,19 @@ predicate integralTypeBounds(IntegralType integralType, QlBuiltins::BigInt lb, Q
112112
)
113113
}
114114

115+
/**
116+
* The size of the smallest `int` type in the database in bytes.
117+
*/
118+
int sizeOfInt() {
119+
// The size of int is implementation-defined
120+
result =
121+
min(int size |
122+
size = any(IntType i | i.isSigned()).getCanonicalArithmeticType().getSize()
123+
|
124+
size
125+
)
126+
}
127+
115128
/**
116129
* Convenience class to reduce the awkwardness of how `RoutineType` and `FunctionPointerIshType`
117130
* don't have a common ancestor.

0 commit comments

Comments
 (0)