Skip to content

Commit 334013b

Browse files
authored
Mark STATISTIC variables as maybe_unused when stats are disabled. (#159103)
PR #159045 made the constructor constexpr, which allows `-Wunused-variable` to trigger. However, we don't really care if a statistic is unused if `LLVM_ENABLE_STATS` is 0.
1 parent ce073a9 commit 334013b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

llvm/include/llvm/ADT/Statistic.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,13 @@ using Statistic = NoopStatistic;
164164

165165
// STATISTIC - A macro to make definition of statistics really simple. This
166166
// automatically passes the DEBUG_TYPE of the file into the statistic.
167+
#if LLVM_ENABLE_STATS
167168
#define STATISTIC(VARNAME, DESC) \
168169
static llvm::Statistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC}
170+
#else
171+
#define STATISTIC(VARNAME, DESC) \
172+
static llvm::Statistic VARNAME [[maybe_unused]] = {DEBUG_TYPE, #VARNAME, DESC}
173+
#endif
169174

170175
// ALWAYS_ENABLED_STATISTIC - A macro to define a statistic like STATISTIC but
171176
// it is enabled even if LLVM_ENABLE_STATS is off.

0 commit comments

Comments
 (0)