[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)
Jan Voung via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 14 07:57:11 PST 2024
jvoung wrote:
> I don't think we can ignore a TU simply because it has the Google Test header included, which this will do. This would ignore real problems, such as
That is true (and we've considered that -- FWIW, ymand and our team have been maintaining this checker).
But as is, we are currently seeing many false positives in test files, and it becomes harder for developers to spot such true positives, given the FP noise to filter through.
Would it help if this was instead a checker option?
> The issue with the Google Test macros seems to be, that the dataflow check does not understand using a helper for the cast to `bool` like this:
>
> ```c++
> ...
> if (const auto wrapped_check = Converter{v})
> ;
> else
> return;
> auto val = *v;
> }
> ```
Thanks, that's definitely part of it. If we handle `EXPECT_TRUE` as well (and other `EXPECT_...` forms), EXPECT [does not](https://godbolt.org/z/6Tbxae9jq) have a `return` so would need special handling (otherwise looks like both branches go to the `*v`).
https://github.com/llvm/llvm-project/pull/115051
More information about the cfe-commits
mailing list