https://github.com/5chmidti requested changes to this pull request.

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

```c++
#include <gtest/gtest.h>
#include <optional>
void issue(const absl::optional<int> &opt) {
  if (!opt.has_value())
  *opt;
}
```

---

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++
#include <optional>

struct Converter {
    template <typename T>
    Converter(T&& val) : success{static_cast<bool>(std::forward<T>(val))} {}
    operator bool() const { return success; }
    bool success;
};

void bar(std::optional<int> v) {
    switch (0)
    case 0:
    default:
        if (const auto wrapped_check = Converter{v})
            ;
        else
            return;
    auto val = *v;
}
```

https://godbolt.org/z/7EdsGYhaW

(found the FP by expanding the `ASSERT_TRUE` macro and reducing manually)

https://github.com/llvm/llvm-project/pull/115051
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to