<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>So, Clang does have a warning for deprecated copy, except that it's buried in -Wdeprecated without its own flag. There's a few other differences too. GCC will warn once per call to the deprecated function while Clang will warn once per deprecated function. GCC will not consider functions that are "= default" or "= delete" while Clang will. That means for "struct S { ~S() = default; };" using S's implicit copy constructor will cause Clang to warn while GCC does not. GCC uses "user-provided" while Clang says "user-declared"</div><div><br></div><div>$ cat test.cc</div><div><div>struct S {</div><div> ~S();</div><div>};</div><div><br></div><div>S s = s;</div></div><div><br></div><div>$ gcc test.cc -Wdeprecated-copy</div><div><div>test.cc:5:7: warning: implicitly-declared 'constexpr S::S(const S&)' is deprecated [-Wdeprecated-copy]</div><div>5 | S s = s;</div><div> | ^</div><div>test.cc:2:3: note: because 'S' has user-provided 'S::~S()'</div><div>2 | ~S();</div><div> | ^</div></div><div><br></div><div>$ clang test.cc -Wdeprecated</div><div><div>test:2:3: warning: definition of implicit copy constructor for 'S' is deprecated because it has a user-declared destructor [-Wdeprecated]</div><div> ~S();<br></div><div> ^<br></div><div>test:5:7: note: in implicit copy constructor for 'S' first required here<br></div><div>S s = s;<br></div><div> ^<br></div></div><div><br></div><div>This is a patch to give Clang a -Wdeprecated-copy, which also ignores explicitly defaulted/deleted functions like GCC.</div><div><a href="https://reviews.llvm.org/D52860">https://reviews.llvm.org/D52860</a><br></div><div><br></div><div>On Thu, Sep 13, 2018 at 9:22 AM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br></div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Great to see GCC catching the deprecated ctor case - would be great to get that implemented in Clang at some point (& enabled for LLVM builds). (rtrieu@)<br>The vector one looks like a false positive? You're allowed to form a pointer to an element one past the end of a singular object but it looks like that's what GCC's warning on.<br>Initializer list - maybe a false positive too, given ArrayRef is intended to refer to a temporary object - I think the initializer_list's lifetime is to teh end of the full expression where it was written, so this can still be OK.<br>The ORC/redundant-move one looks correct - I wonder why Clang didn't diagnose that (rtrieu@)?<br><br><div class="gmail_quote"><div dir="ltr">On Thu, Sep 13, 2018 at 12:13 AM Dávid Bolvanský via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hello,<div><br></div><div>GCC 9.0 introduces a new warning checkers and some of them found possible issues in LLVM.</div><div><br></div><div><div>In file included from /home/davidbolvansky/trunk/llvm/include/llvm/Analysis/LazyCallGraph.h:38,</div><div> from /home/davidbolvansky/trunk/llvm/unittests/Analysis/LazyCallGraphTest.cpp:10:</div><div>/home/davidbolvansky/trunk/llvm/include/llvm/ADT/ArrayRef.h: In instantiation of ‘llvm::ArrayRef<T>::ArrayRef(const std::initializer_list<_Tp>&) [with T = llvm::LazyCallGraph::Node*]’:</div><div>/home/davidbolvansky/trunk/llvm/unittests/Analysis/LazyCallGraphTest.cpp:1169:52: required from here</div><div>/home/davidbolvansky/trunk/llvm/include/llvm/ADT/ArrayRef.h:102:37: warning: initializing ‘llvm::ArrayRef<llvm::LazyCallGraph::Node*>::Data’ from ‘std::initializer_list<llvm::LazyCallGraph::Node*>::begin’ does not extend the lifetime of the underlying array [-Winit-list-lifetime]</div></div><div><br></div><div><div>In file included from /home/davidbolvansky/trunk/llvm/unittests/ADT/SmallVectorTest.cpp:14:</div><div>/home/davidbolvansky/trunk/llvm/include/llvm/ADT/SmallVector.h: In member function ‘virtual void {anonymous}::SmallVectorTest_InitializerList_Test::TestBody()’:</div><div>/home/davidbolvansky/trunk/llvm/include/llvm/ADT/SmallVector.h:502:7: warning: array subscript 1 is outside array bounds of ‘int [1]’ [-Warray-bounds]</div><div>502 | ++EltPtr;</div></div><div><div>/home/davidbolvansky/trunk/llvm/unittests/ADT/SmallVectorTest.cpp:994:30: note: while referencing ‘<anonymous>’</div><div>994 | V2.insert(V2.begin() + 1, 5);</div></div><div><br></div><div><div>/home/davidbolvansky/trunk/llvm/unittests/ExecutionEngine/Orc/CompileOnDemandLayerTest.cpp:79:40: required from here</div><div>/home/davidbolvansky/trunk/llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h:314:29: warning: redundant move in return statement [-Wredundant-move]</div><div>314 | return std::move(Err);</div></div><div><br></div><div><div>In file included from /home/davidbolvansky/trunk/llvm/utils/unittest/googlemock/include/gmock/gmock-spec-builders.h:75,</div><div> from /home/davidbolvansky/trunk/llvm/utils/unittest/googlemock/include/gmock/gmock-generated-function-mockers.h:43,</div><div> from /home/davidbolvansky/trunk/llvm/utils/unittest/googlemock/include/gmock/gmock.h:61,</div><div> from /home/davidbolvansky/trunk/llvm/include/llvm/Testing/Support/Error.h:17,</div><div> from /home/davidbolvansky/trunk/llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp:15:</div><div>/home/davidbolvansky/trunk/llvm/utils/unittest/googlemock/include/gmock/gmock-matchers.h: In instantiation of ‘testing::internal::PredicateFormatterFromMatcher<M>::PredicateFormatterFromMatcher(M) [with M = llvm::FailedMatcher]’:</div><div>/home/davidbolvansky/trunk/llvm/utils/unittest/googlemock/include/gmock/gmock-matchers.h:1880:10: required from ‘testing::internal::PredicateFormatterFromMatcher<M> testing::internal::MakePredicateFormatterFromMatcher(M) [with M = llvm::FailedMatcher]’</div><div>/home/davidbolvansky/trunk/llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp:96:3: required from here</div><div>/home/davidbolvansky/trunk/llvm/utils/unittest/googlemock/include/gmock/gmock-matchers.h:1836:75: warning: implicitly-declared ‘constexpr llvm::FailedMatcher::FailedMatcher(const llvm::FailedMatcher&)’ is deprecated [-Wdeprecated-copy]</div><div>1836 | explicit PredicateFormatterFromMatcher(M m) : matcher_(internal::move(m)) {}</div><div> | ^</div><div>In file included from /home/davidbolvansky/trunk/llvm/utils/unittest/googletest/include/gtest/gtest-printers.h:103,</div><div> from /home/davidbolvansky/trunk/llvm/include/llvm/Testing/Support/SupportHelpers.h:16,</div><div> from /home/davidbolvansky/trunk/llvm/include/llvm/Testing/Support/Error.h:15,</div><div> from /home/davidbolvansky/trunk/llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp:15:</div><div>/home/davidbolvansky/trunk/llvm/utils/unittest/googletest/include/gtest/internal/gtest-port.h:873:8: note: because ‘llvm::FailedMatcher’ has user-provided ‘void llvm::FailedMatcher::operator=(const llvm::FailedMatcher&)’</div><div>873 | void operator=(type const &)</div><div> | ^~~~~~~~</div><div>/home/davidbolvansky/trunk/llvm/utils/unittest/googlemock/include/gmock/gmock-generated-matchers.h:1417:5: note: in expansion of macro ‘GTEST_DISALLOW_ASSIGN_’</div><div>1417 | GTEST_DISALLOW_ASSIGN_(name##Matcher);\</div><div> | ^~~~~~~~~~~~~~~~~~~~~~</div><div>/home/davidbolvansky/trunk/llvm/include/llvm/Testing/Support/Error.h:145:1: note: in expansion of macro ‘MATCHER’</div><div>145 | MATCHER(Failed, "") { return !arg.Success(); }</div></div><div><br></div><div><div><br></div><div><br></div><div><br></div></div><div><br></div><div><br></div></div></div></div></div></div></div></div></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>
</blockquote></div></div></div></div></div></div></div></div></div>