summaryrefslogtreecommitdiff
path: root/.clang-tidy
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-03-15 00:56:47 +0300
committerEd Tanous <edtanous@google.com>2022-12-08 23:08:01 +0300
commit0ec8b83db7e8629c721c0e632de702bf1018f58f (patch)
tree207fa734b40162e4953f4c8c229cbcfb4c02900d /.clang-tidy
parent7e8890c5c2b8d69c104f2db4e82fb06c40374c08 (diff)
downloadbmcweb-0ec8b83db7e8629c721c0e632de702bf1018f58f.tar.xz
Generate Redfish enums from schemas
OpenBMC tends to have a significant problem in doing the appropriate lookups from the schema files, and many bugs have been injected by users picking a bad enum, or mistyping the casing of an enum value. At the same time, nlohmann::json has recently added first class support for enums, https://json.nlohmann.me/features/enum_conversion/ This commit attempts to build a set of redfish includes file with all the available Redfish enums in an easy to use enum class. This makes it very clear which enums are supported by the schemas we produce, and adds very little to no extra boilerplate on the human-written code we produced previously. Note, in the generated enum class, because of our use of the clang-tidy check for macros, the clang-tidy check needs an exception for these macros that don't technically follow the coding standard. This seems like a reasonable compromise, and in this case, given that nlohmann doesn't support a non-macro version of this. One question that arises is what this does to the binary size.... Under the current compiler optimizations, and with the current best practices, it leads to an overall increase in binary size of ~1200 bytes for the enum machinery, then approximately 200 bytes for every call site we switch over. We should decide if this nominal increase is reasonable. Tested: Redfish protocol validator runs with same number of failures as previously. Redfish Service Validator passes (one unrelated qemu-specific exception) Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7c7ee4db0823f7c57ecaa59620b280b53a46e2c1
Diffstat (limited to '.clang-tidy')
-rw-r--r--.clang-tidy1
1 files changed, 1 insertions, 0 deletions
diff --git a/.clang-tidy b/.clang-tidy
index bed3fadfd8..8af0822656 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -315,3 +315,4 @@ CheckOptions:
- { key: readability-identifier-naming.ParameterCase, value: camelBack }
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
- { key: readability-identifier-naming.StructCase, value: CamelCase }
+ - { key: cppcoreguidelines-macro-usage.AllowedRegexp, value: DEBUG*|NLOHMANN_JSON_SERIALIZE_ENUM }