From 13b8c33c7979da7635ede33fef531c40d3652433 Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Tue, 2 Jan 2024 14:08:08 -0800 Subject: [PATCH] Disable bugprone-unchecked-optional-access due to false positives (#3553) I think this check doesn't offer enough value to try to work around the false positives. We probably will, at times, check the contents of an optional without validating because structurally we know it must have a value. Here though, I believe the `while` will be doing a check of the value; we shouldn't need a more explicit check. --- .clang-tidy | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index 5856dc790236..3e78e16875b6 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,6 +5,12 @@ --- # - bugprone-exception-escape finds issues like out-of-memory in main(). We # don't use exceptions, so it's unlikely to find real issues. +# - bugprone-unchecked-optional-access in clang-tidy 16 has false positives on +# code like: +# while (auto name_ref = insts().Get(inst_id).TryAs()) { +# inst_id = name_ref->value_id; +# ^ unchecked access to optional value +# } # - google-readability-function-size overlaps with readability-function-size. # - modernize-use-nodiscard is disabled because it only fixes const methods, # not non-const, which yields distracting results on accessors. @@ -12,7 +18,8 @@ # modernize-pass-by-value. Checks: -*, bugprone-*, -bugprone-branch-clone, -bugprone-easily-swappable-parameters, - -bugprone-exception-escape, -bugprone-narrowing-conversions, google-*, + -bugprone-exception-escape, -bugprone-narrowing-conversions, + -bugprone-unchecked-optional-access, google-*, -google-readability-function-size, -google-readability-todo, misc-definitions-in-headers, misc-misplaced-const, misc-redundant-expression, misc-static-assert, misc-unconventional-assign-operator,