Skip to content

Commit 2d898af

Browse files
author
Matthew Gretton-Dann
committed
C++: Add library support for char8_t type.
1 parent 79b3a99 commit 2d898af

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

cpp/ql/src/semmle/code/cpp/Type.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ private predicate isIntegralType(@builtintype type, int kind) {
376376
kind = 43
377377
or
378378
kind = 44
379+
or
380+
kind = 51
379381
)
380382
}
381383

@@ -993,6 +995,18 @@ class WideCharType extends IntegralType {
993995
override string getCanonicalQLClass() { result = "WideCharType" }
994996
}
995997

998+
/**
999+
* The C/C++ `char8_t` type. This is available starting with C++20.
1000+
* ```
1001+
* char8_t c8;
1002+
* ```
1003+
*/
1004+
class Char8Type extends IntegralType {
1005+
Char8Type() { builtintypes(underlyingElement(this), _, 51, _, _, _) }
1006+
1007+
override string getCanonicalQLClass() { result = "Char8Type" }
1008+
}
1009+
9961010
/**
9971011
* The C/C++ `char16_t` type. This is available starting with C11 and C++11.
9981012
* ```

cpp/ql/src/semmle/code/cpp/padding/Padding.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ abstract class Architecture extends string {
7474
or
7575
t instanceof WideCharType and result = wideCharSize()
7676
or
77+
t instanceof Char8Type and result = 8
78+
or
7779
t instanceof Char16Type and result = 16
7880
or
7981
t instanceof Char32Type and result = 32

0 commit comments

Comments
 (0)