[PATCH] D155475: [Clang][Sema] Add -Wctad-selects-copy to diagnose copy deduction candidate

Nikolas Klauser via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 14 10:02:27 PDT 2023


philnik added inline comments.


================
Comment at: clang/lib/Sema/SemaInit.cpp:10932
+    DiagnoseCTADCopy();
+  } else if (!PP.getSourceManager().isInSystemHeader(Template->getLocation())) {
+    DiagnoseCTADCopy();
----------------
cor3ntin wrote:
> So the idea here is that the standard library would have protected against that by providing deduction guides?
> Which is funny because the original issue was reported because they did not.
> Do you have an example of when we should not emit the diagnostic for a library type?
> 
> @ldionne @philnik Opinions on this warning?
I think this definitely has to be suppressed in system headers somehow. e.g. `as_rvalue_view` uses the copy ctor CTAD to avoid double-wrapping iterators. (see https://github.com/llvm/llvm-project/blob/main/libcxx/include/__ranges/as_rvalue_view.h#L75). OTOH I'm not sure whether this should be suppressed if the type is from a system header, since `reverse_iterator{some-other-reverse-iterator}` might not be intended either, regardless of deduction guides.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155475/new/

https://reviews.llvm.org/D155475



More information about the cfe-commits mailing list