Sometimes classes can't have a defaulted or empty special member function declared inside the class if any of the members have forward declared types as template parameters.
The Pimpl idiom is a classic example of this
In these situations it makes sense to have a defaulted special member function moved to the source file. Currently the define outline tweak will reject these defaulted special member functions.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
there's actually a slight difference between an inline defaulted special member function and an out-of-line defaulted one. the latter makes the special member "user-defined" which might cause various headaches (e.g. type is no longer "trivial"). i don't think we should make it easy for people to change trivialness of types (especially considering our experience with people thinking anything that comes from the lightbulb is a way to improve your code). on a side node, this is less of an issue in the scenario you described (i.e. when the destructor is virtual, as it already means type is non-trivial).
so if you feel like this is really useful, i guess we can change the scope a little to apply to all special members, but only when type is no longer trivial. WDYT?
thanks a lot, and sorry for the delay!
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp | ||
---|---|---|
328 | can you add a comment here saying // We should have just `= default` in this case | |
404 | i know i asked for triviality check in the first version, but thinking a little bit more about it, users might be more confused about code action's availability. as this is very subtle at a glance for anyone but the compiler. so i think it's better to just emit it always. |
can you add a comment here saying // We should have just `= default` in this case