[clang] [clang-tools-extra] [clang-tidy] For bugprone-unchecked-optional-access add simple BoolModel option (PR #240848)

via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 10 11:52:45 PST 2026


================
@@ -23,23 +24,19 @@ namespace clang::tidy::bugprone {
 /// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/unchecked-optional-access.html
 class UncheckedOptionalAccessCheck : public ClangTidyCheck {
 public:
-  UncheckedOptionalAccessCheck(StringRef Name, ClangTidyContext *Context)
-      : ClangTidyCheck(Name, Context),
-        ModelOptions{Options.get("IgnoreSmartPointerDereference", false),
-                     Options.get("IgnoreValueCalls", false)} {}
+  UncheckedOptionalAccessCheck(StringRef Name, ClangTidyContext *Context);
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
     return LangOpts.CPlusPlus;
   }
-  void storeOptions(ClangTidyOptions::OptionMap &Opts) override {
-    Options.store(Opts, "IgnoreSmartPointerDereference",
-                  ModelOptions.IgnoreSmartPointerDereference);
-    Options.store(Opts, "IgnoreValueCalls", ModelOptions.IgnoreValueCalls);
-  }
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
 
 private:
   dataflow::UncheckedOptionalAccessModelOptions ModelOptions;
+  // Note: The boolean model is an option for the framework, not the checker
----------------
EugeneZelenko wrote:

```suggestion
  // Note: The Boolean model is an option for the framework, not the checker
```

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


More information about the cfe-commits mailing list