Fix clang-tidy cppcoreguidelines-macro-usage findings (macros as constants)

This commit is contained in:
Tim Wojtulewicz 2025-05-09 11:57:58 -07:00
parent d6d56d330b
commit ad99a6821e
16 changed files with 96 additions and 80 deletions

View file

@ -20,29 +20,29 @@ namespace zeek::detail {
// to the event engine.
// Does not change script-level state (though may change internal state).
#define ATTR_NO_SCRIPT_SIDE_EFFECTS 0x1
constexpr unsigned int ATTR_NO_SCRIPT_SIDE_EFFECTS = 0x1;
// Does not change any Zeek state, internal or external. (May change
// state outside of Zeek, such as file system elements.) Implies
// ATTR_NO_SCRIPT_SIDE_EFFECTS.
#define ATTR_NO_ZEEK_SIDE_EFFECTS 0x2
constexpr unsigned int ATTR_NO_ZEEK_SIDE_EFFECTS = 0x2;
// Calls made with the same arguments yield the same results, if made
// after full Zeek initialization. Implies ATTR_NO_ZEEK_SIDE_EFFECTS.
#define ATTR_IDEMPOTENT 0x4
constexpr unsigned int ATTR_IDEMPOTENT = 0x4;
// Calls with constant arguments can always be folded, even prior to
// full Zeek initialization. Such functions must not have the potential
// to generate errors. Implies ATTR_IDEMPOTENT.
#define ATTR_FOLDABLE 0x8
constexpr unsigned int ATTR_FOLDABLE = 0x8;
// The event engine knows about this script function and may call it
// during its processing.
#define ATTR_SPECIAL_SCRIPT_FUNC 0x10
constexpr unsigned int ATTR_SPECIAL_SCRIPT_FUNC = 0x10;
// ZAM knows about this script function and will replace it with specialized
// instructions.
#define ATTR_ZAM_REPLACEABLE_SCRIPT_FUNC 0x20
constexpr unsigned int ATTR_ZAM_REPLACEABLE_SCRIPT_FUNC = 0x20;
static std::unordered_map<std::string, unsigned int> func_attrs = {
// Script functions.

View file

@ -718,8 +718,12 @@ bool has_AST_node_unknown_to_script_opt(const ProfileFunc* prof, bool /* is_ZAM
STMT_ASSERT,
// STMT_EXTERN,
// STMT_STD_FUNCTION,
#define SCRIPT_OPT_NUM_STMTS 24
};
// This should be the total number of entries in the set above, including
// the commented values.
constexpr int SCRIPT_OPT_NUM_STMTS = 24;
// clang-format on
// Fail compilation if NUM_STMT in StmtEnums.h changes.
@ -803,8 +807,12 @@ bool has_AST_node_unknown_to_script_opt(const ProfileFunc* prof, bool /* is_ZAM
// EXPR_ANY_INDEX,
// EXPR_SCRIPT_OPT_BUILTIN,
// EXPR_NOP,
#define SCRIPT_OPT_NUM_EXPRS 70
};
// This should be the total number of entries in the set above, including
// the commented values.
constexpr int SCRIPT_OPT_NUM_EXPRS = 70;
// clang-format on
// Fail compilation if NUM_EXPRS in Expr.h changes.