Skip to content

Commit 9d3bd1f

Browse files
committed
updated odb code generation to include alignment check
Signed-off-by: Ethan Mahintorabi <[email protected]>
1 parent 396dd44 commit 9d3bd1f

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/odb/src/codeGenerator/schema/chip/dbModITerm.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name":"dbModITerm",
33
"needs_non_default_destructor" : "true",
4+
"assert_alignment_is_multiple_of": 8,
45
"fields":[
56
{
67
"name":"_name",

src/odb/src/codeGenerator/templates/impl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ namespace odb {
8484

8585
_{{klass.name}}::_{{klass.name}}(_dbDatabase* db)
8686
{
87+
{% if klass.assert_alignment_is_multiple_of %}
88+
// For pointer tagging the bottom log_2({{klass.assert_alignment_is_multiple_of}}) bits.
89+
static_assert(alignof(_{{klass.name}}) % {{klass.assert_alignment_is_multiple_of}} == 0);
90+
{% endif%}
8791
{% for field in klass.fields %}
8892
{% if field.bitFields %}
8993
{{field.name}} = {};

src/odb/src/db/dbModITerm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ bool _dbModITerm::operator<(const _dbModITerm& rhs) const
5757

5858
_dbModITerm::_dbModITerm(_dbDatabase* db)
5959
{
60-
// For pointer tagging the bottom 3 bits.
60+
// For pointer tagging the bottom log_2(8) bits.
6161
static_assert(alignof(_dbModITerm) % 8 == 0);
6262
_name = nullptr;
6363
}

0 commit comments

Comments
 (0)