Re: r291905 - [Sema] Add warning for unused lambda captures

2017-02-16 Thread Aaron Ballman via cfe-commits
On Wed, Feb 15, 2017 at 7:42 PM, Richard Smith via cfe-commits wrote: > https://bugs.llvm.org/show_bug.cgi?id=31977 makes the good point that this > is warning on a certain idiomatic use of capture-by-value to extend the > lifetime of an RAII object; consider: > > shared_ptr p = /*...*/; > int

Re: r291905 - [Sema] Add warning for unused lambda captures

2017-02-15 Thread Richard Smith via cfe-commits
https://bugs.llvm.org/show_bug.cgi?id=31977 makes the good point that this is warning on a certain idiomatic use of capture-by-value to extend the lifetime of an RAII object; consider: shared_ptr p = /*...*/; int *q = &p->n; return [=, p] { return *q++; } Here, we'll warn that the capture o

Re: r291905 - [Sema] Add warning for unused lambda captures

2017-01-26 Thread Aaron Ballman via cfe-commits
On Mon, Jan 23, 2017 at 5:55 PM, Nico Weber wrote: > On Mon, Jan 23, 2017 at 5:29 PM, Aaron Ballman > wrote: >> >> On Mon, Jan 23, 2017 at 5:00 PM, Nico Weber via cfe-commits >> wrote: >> > On Sun, Jan 22, 2017 at 6:17 AM, Malcolm Parsons >> > >> > wrote: >> >> >> >> On 20 January 2017 at 21:32

Re: r291905 - [Sema] Add warning for unused lambda captures

2017-01-23 Thread Nico Weber via cfe-commits
On Mon, Jan 23, 2017 at 5:29 PM, Aaron Ballman wrote: > On Mon, Jan 23, 2017 at 5:00 PM, Nico Weber via cfe-commits > wrote: > > On Sun, Jan 22, 2017 at 6:17 AM, Malcolm Parsons < > malcolm.pars...@gmail.com> > > wrote: > >> > >> On 20 January 2017 at 21:32, Nico Weber wrote: > >> > This warns

Re: r291905 - [Sema] Add warning for unused lambda captures

2017-01-23 Thread Aaron Ballman via cfe-commits
On Mon, Jan 23, 2017 at 5:00 PM, Nico Weber via cfe-commits wrote: > On Sun, Jan 22, 2017 at 6:17 AM, Malcolm Parsons > wrote: >> >> On 20 January 2017 at 21:32, Nico Weber wrote: >> > This warns about code like >> > >> > constexpr int foo = 4; >> > [&foo]() { use(foo); } >> > >> > That's co

Re: r291905 - [Sema] Add warning for unused lambda captures

2017-01-23 Thread Nico Weber via cfe-commits
On Sun, Jan 22, 2017 at 6:17 AM, Malcolm Parsons wrote: > On 20 January 2017 at 21:32, Nico Weber wrote: > > This warns about code like > > > > constexpr int foo = 4; > > [&foo]() { use(foo); } > > > > That's correct, but removing &foo then makes MSVC complain about this > code > > like "err

Re: r291905 - [Sema] Add warning for unused lambda captures

2017-01-22 Thread Malcolm Parsons via cfe-commits
On 20 January 2017 at 21:32, Nico Weber wrote: > This warns about code like > > constexpr int foo = 4; > [&foo]() { use(foo); } > > That's correct, but removing &foo then makes MSVC complain about this code > like "error C3493: 'foo' cannot be implicitly captured because no default > capture m

Re: r291905 - [Sema] Add warning for unused lambda captures

2017-01-20 Thread Nico Weber via cfe-commits
This warns about code like constexpr int foo = 4; [&foo]() { use(foo); } That's correct, but removing &foo then makes MSVC complain about this code like "error C3493: 'foo' cannot be implicitly captured because no default capture mode has been specified". A workaround is to make foo static co

Re: r291905 - [Sema] Add warning for unused lambda captures

2017-01-15 Thread Daniel Jasper via cfe-commits
Sorry, for the noise. This is probably not the revision that caused this. On Mon, Jan 16, 2017 at 1:08 AM, Daniel Jasper wrote: > This patch seems to break on some of our code. Reproducer: > > $ cat /tmp/ctor.cc > template > struct A { > A() {} > }; > > template > class B : T { > using T::

Re: r291905 - [Sema] Add warning for unused lambda captures

2017-01-15 Thread Daniel Jasper via cfe-commits
This patch seems to break on some of our code. Reproducer: $ cat /tmp/ctor.cc template struct A { A() {} }; template class B : T { using T::T; }; struct C { B> d; C(A b) : d(b) {} }; djasper@dj:~/llvm/release$ bin/clang -cc1 -std=c++11 /tmp/ctor.cc /tmp/ctor.cc:13:17: error: no matchi

r291905 - [Sema] Add warning for unused lambda captures

2017-01-13 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons Date: Fri Jan 13 09:01:06 2017 New Revision: 291905 URL: http://llvm.org/viewvc/llvm-project?rev=291905&view=rev Log: [Sema] Add warning for unused lambda captures Summary: Warn when a lambda explicitly captures something that is not used in its body. The warning is part