halide / Halide

a language for fast, portable data-parallel computation
https://halide-lang.org
Other
5.91k stars 1.07k forks source link

Use std::optional to clean up some code and prevent use-after-free bugs #8484

Open abadams opened 1 day ago

abadams commented 1 day ago

A lot of this code was pre C++-17, and could be improved using std::optional. This would have avoided #8482 and arguably the bug underlying #8469

abadams commented 1 day ago

clang-tidy is flagging this as an unchecked use of a std::optional:

    if (is_interleaved_ramp(mul->a, scope, result) &&
            (b = as_const_int(mul->b))) {
            result->base = simplify(result->base * (int)(*b));

... that's checked, right?

We also have it complaining about this:

           internal_assert(event);
            if (*event == halide_trace_begin_realization || *event == halide_trace_end_realization) 

because it doesn't see the assert as checking. Perhaps I should just disable that clang-tidy check.