[clang-tools-extra] [clang-tidy] New Option Invalid Enum Default Initialization (PR #159220)

Félix-Antoine Constantin via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 17 08:53:50 PDT 2025


================
@@ -88,12 +90,22 @@ class FindEnumMember : public TypeVisitor<FindEnumMember, bool> {
 
 InvalidEnumDefaultInitializationCheck::InvalidEnumDefaultInitializationCheck(
     StringRef Name, ClangTidyContext *Context)
-    : ClangTidyCheck(Name, Context) {}
+    : ClangTidyCheck(Name, Context),
+      IgnoredEnums(utils::options::parseStringList(
+          Options.get("IgnoredEnums", "::std::errc"))) {}
----------------
felix642 wrote:

I'm wondering if there are cases where the `enum` is defined in the system header, but should not be default-initialized. 
I don't have any examples on top of my head, but I felt like it was safer to only remove this specific use case and add an option to be able to extend it in the future if we find other use cases.
This might be a bit too risky to implement in this PR, what do you think? 

https://github.com/llvm/llvm-project/pull/159220


More information about the cfe-commits mailing list