With this patch there should be no more namespaces without closing comment
Details
- Reviewers
ldionne • Quuxplusone var-const Mordante - Group Reviewers
Restricted Project - Commits
- rG9c52a19e32ae: [libc++][NFC] Add namespace comments in ranges
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/include/__ranges/reverse_view.h | ||
---|---|---|
117 | Here, in line 123 and line 129 clang-tidy claims these definitions can lead to ODR-violations. Is inline implied by it being a template or something else and therefore this is a clang-tidy bug or is this actually potentially an ODR-violation and this is a libc++ bug? |
The patch itself LGTM, but there's indeed an interesting side question about the linkage of variable templates.
libcxx/include/__ranges/reverse_view.h | ||
---|---|---|
117 | I'll use cppreference instead of the standard here because everything I found in the Standard was much harder to understand than cppreference. My understanding is that the __is_reverse_view base template has the usual linkage for templates, which is extern inline (more precisely linkonce_odr in LLVM lingo). See external linkage at https://en.cppreference.com/w/cpp/language/storage_duration. However, the __is_reverse_view<reverse_view<_Tp>> specialization is a variable, not a variable template, so this part of https://en.cppreference.com/w/cpp/language/storage_duration / internal linkage applies to it instead:
Naively, this would mean that __is_reverse_view<reverse_view<_Tp>> has internal linkage, and hence clang-tidy is right to flag this. However, according to https://stackoverflow.com/a/48078494/627587, it appears that the rule doesn't actually apply, and so clang-tidy would in fact be wrong to flag this. Perhaps clang-tidy doesn't implement the resolution of CWG1713? Also, one way to know for sure would be to look at the LLVM bitcode emitted, and confirm that __is_reverse_view<reverse_view<_Tp>> has linkoncde_odr linkage. If so, then clang-tidy would definitely be wrong to flag this. |
libcxx/include/__iterator/iter_move.h | ||
---|---|---|
76 | PSA: This will merge-conflict when rebased. | |
libcxx/include/__ranges/reverse_view.h | ||
117 | My understanding is that the variables instantiated from these templates behave the same as any other variables instantiated from templates — they shouldn't need inline for correctness, any more than a variable template (or function template) needs inline for correctness. Also, in __ranges/join_view.h, I would change | |
libcxx/include/cstddef | ||
159 | Suggest adding a blank line before this one. |
libcxx/include/__ranges/reverse_view.h | ||
---|---|---|
117 | This is now #53519. I'll make a PR later to add inline to the constexpr variables. |
PSA: This will merge-conflict when rebased.