This is an exploratory patch, an attempt to solve bugs.llvm.org/show_bug.cgi?id=47400
That bug report shows a simple test case where the constexpr variable, declared outside the scope of the lambda but used within the lambda, is simply unknown in the DebugInfo. This is different from a gcc compilation where gdb knows the symbol, and knows that the value is "optimized out".
The problem is constexpr variables like n_steps (see example in the bug report) are not captured and so do not appear in the record type. These still appear in the AST so if we gather them it is possible to emit static data member. As a proof of concept, this is prototyped here. I didn't think about exactly which variables should be gathered but this might be a framework. This is a little hacky since the constexpr variable is not really a static member of the lambda but the use is roughly correct.
clang-format: please reformat the code