[Lldb-commits] [lldb] [lldb-dap] Creating a 'capabilities' event helper. (PR #142831)
John Harrison via lldb-commits
lldb-commits at lists.llvm.org
Thu Jun 5 16:50:51 PDT 2025
ashgti wrote:
I also added some unit tests for the new 'CapabilitiesEventBody' serialization logic. But I have a style question.
The existing `Capabilities` type doesn't initialize its fields, so if I use the aggregate I have to include all the fields. However, we could initialize the values and then the aggregate initializer is short, but that leads to my style questions.
```c++
// style 1, no initializers:
struct Capabilities {
llvm::DenseSet<AdapterFeature> supportedFeatures;
std::optional<std::vector<ExceptionBreakpointsFilter>> exceptionBreakpointFilters;
std::optional<std::vector<std::string>> completionTriggerCharacters;
....
};
// all fields must be set or we get a warning on `-Wmissing-field-initializers`
Capabilities cap{
/*supportedFeatures=*/{...},
/*exceptionBreakpointFilters=*/std::nullopt,
/*completionTriggerCharacters=*/std::nullopt
...
};
// style 2, = initial value:
struct Capabilities {
llvm::DenseSet<AdapterFeature> supportedFeatures = {};
std::optional<std::vector<ExceptionBreakpointsFilter>> exceptionBreakpointFilters = std::nullopt;
std::optional<std::vector<std::string>> completionTriggerCharacters = std::nullopt;
....
};
Capabilities cap{/*supportedFeatures=*/{...}}; // no need to specify the nullopts.
// style 3, brace initializers:
struct Capabilities {
llvm::DenseSet<AdapterFeature> supportedFeatures{};
std::optional<std::vector<ExceptionBreakpointsFilter>> exceptionBreakpointFilters{};
std::optional<std::vector<std::string>> completionTriggerCharacters{};
....
};
Capabilities cap{/*supportedFeatures=*/{...}}; // no need to specify the nullopts.
```
https://github.com/llvm/llvm-project/pull/142831
More information about the lldb-commits
mailing list