-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathConsistencyCheck.ql
More file actions
35 lines (29 loc) · 1.05 KB
/
ConsistencyCheck.ql
File metadata and controls
35 lines (29 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* @name Padding Consistency Check
* @description Performs consistency checks for the padding library. This query should have no results.
* @kind table
* @id cpp/padding-consistency-check
*/
import Padding
/*
* Consistency-check: Find discrepancies between computed and actual size on LP64.
*/
/*
* from Type t, LP64 a, int padded, int bit, int real, MemberVariable v
* where padded = a.paddedSize(t) and bit = a.bitSize(t)
* and real = t.getSize() * 8 and padded != real and count(t.getSize()) = 1
* select t, a.paddedSize(t) as Padded, real, v, t.(PaddedType).memberSize(v, a)
*/
/*
* from PaddedType t, LP64 a, MemberVariable v
* where t instanceof Union and v = t.getAMember() and not exists(t.memberSize(v, a))
* select t, v, v.getType().explain()
*/
/*
* from PaddedType t, LP64 a, MemberVariable v
* where not exists(a.paddedSize(t))
* select t, t.fieldIndex(v) as i, v, t.memberSize(v, a) order by t, i
*/
from PaddedType t, LP64 a
where a.wastedSpace(t) != 0
select t, a.paddedSize(t) as size, a.wastedSpace(t) as waste order by waste desc