Skip to content

Commit 055485d

Browse files
C++: Work around lack of size for enum type
1 parent 26525fc commit 055485d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ class Enum extends UserType, IntegralOrEnumType {
1616
*/
1717
override string explain() { result = "enum " + this.getName() }
1818

19+
override int getSize() {
20+
// Workaround for extractor bug CPP-348: No size information for enums.
21+
// If the extractor didn't provide a size, assume four bytes.
22+
result = UserType.super.getSize() or
23+
not exists(UserType.super.getSize()) and result = 4
24+
}
25+
1926
/** See `Type.isDeeplyConst` and `Type.isDeeplyConstBelow`. Internal. */
2027
override predicate isDeeplyConstBelow() { any() } // No subparts
2128

0 commit comments

Comments
 (0)