Skip to content

Commit

Permalink
Merge pull request #7049 from jdmpapin/vlog-tag-name-count-assert
Browse files Browse the repository at this point in the history
Check that _vlogTable size matches TR_VlogTag with static_assert()
  • Loading branch information
dsouzai authored Jun 30, 2023
2 parents 6b5f1b7 + eb1fe9c commit 3fd2813
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions compiler/env/VerboseLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,13 @@ void TR_VerboseLog::initialize(void *config)
{
_config = config;
}

// This is never called. It's just a place to put static_assert() where
// definitions in this file are available (for e.g. array initializers) and
// where private members of TR_VerboseLog are also visible.
void TR_VerboseLog::privateStaticAsserts()
{
static_assert(
sizeof(_vlogTable) / sizeof(_vlogTable[0]) == TR_Vlog_numTags,
"TR_VlogTag and _vlogTable are out of sync");
}
4 changes: 4 additions & 0 deletions compiler/env/VerboseLog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ class TR_VerboseLog

//only called once early on, after we can print to the vlog
static void initialize(void *config);

private:

static void privateStaticAsserts();

static void vwrite(const char *format, va_list args); //defined in each front end
static void writeTimeStamp();
static const char *_vlogTable[];
Expand Down

0 comments on commit 3fd2813

Please sign in to comment.