[clang] [clang-tools-extra] [clang-tidy] For bugprone-unchecked-optional-access add simple BoolModel option (PR #240848)
Zeyi Xu via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 10 17:59:30 PST 2026
================
@@ -324,3 +326,15 @@ to `optional::value()`. Diagnostics for `operator*()` and
intentionally rely on `value()` for defined, guarded access while still
flagging UB-prone operator dereferences. Default is `false`.
```
+
+```{option} BoolModel
+Can be set to `SAT` (default) or `Simple`. The flow-sensitive analysis uses
+boolean formulas to model whether an `optional<T>` object has a value among
+other conditions. The analysis checks that, during accesses, the "has a value"
+state is provably true. The `SAT` model uses a SAT solver for this proof, so
+it can handle {ref}`branches with correlated conditions <correlated-branches>`
+and branches that contain ORs. The `Simple` model does a more limited tracking
+of boolean constants, and evaluates formulas without backtracking given
+assumptions at branch points, and does not introduce ORs for joins. As a result,
+the `Simple` model is faster but may have more false positives.
----------------
zeyi2 wrote:
Hi, in clang-tidy documentations we typically put default value at the end.
An [example in other checks](https://clang.llvm.org/extra/clang-tidy/checks/bugprone/empty-catch.html#cmdoption-arg-IgnoreCatchWithKeywords):
> IgnoreCatchWithKeywords
>
> This option can be used to ignore specific catch statements containing certain keywords. If a catch
> statement body contains (case-insensitive) any of the keywords listed in this semicolon-separated
> option, then the catch will be ignored, and no warning will be raised. Default value: [at]TODO;[at]FIXME.
https://github.com/llvm/llvm-project/pull/240848
More information about the cfe-commits
mailing list