Re: [PATCH] C++: fix-it hints suggesting accessors for private fields

2017-05-01 Thread Jason Merrill
On Thu, Apr 27, 2017 at 7:23 AM, Nathan Sidwell wrote: > On 04/26/2017 12:34 PM, David Malcolm wrote: > >> Thanks - yes; that gives information on the const vs non-const of the >> "this" parameter, but doesn't say whether the argument was const vs non >> -const. > > >> However, within: >> >> int t

Re: [PATCH] C++: fix-it hints suggesting accessors for private fields

2017-04-27 Thread Nathan Sidwell
On 04/26/2017 12:34 PM, David Malcolm wrote: Thanks - yes; that gives information on the const vs non-const of the "this" parameter, but doesn't say whether the argument was const vs non -const. However, within: int test_const_ptr (const t1 *ptr) { return ptr->m_color; } from which we can

Re: [PATCH] C++: fix-it hints suggesting accessors for private fields

2017-04-26 Thread David Malcolm
On Tue, 2017-04-25 at 18:22 -0400, Nathan Sidwell wrote: > On 04/25/2017 04:01 PM, David Malcolm wrote: > > On Tue, 2017-04-25 at 12:11 -0400, Nathan Sidwell wrote: > > > On 04/25/2017 11:58 AM, David Malcolm wrote: > > > > > > > { return FIELD; } > > > I tried adding the kind of filtering yo

Re: [PATCH] C++: fix-it hints suggesting accessors for private fields

2017-04-25 Thread Nathan Sidwell
On 04/25/2017 04:01 PM, David Malcolm wrote: On Tue, 2017-04-25 at 12:11 -0400, Nathan Sidwell wrote: On 04/25/2017 11:58 AM, David Malcolm wrote: { return FIELD; } I tried adding the kind of filtering you suggest, but the binfo doesn't seem to have info on const vs non-const qualificat

Re: [PATCH] C++: fix-it hints suggesting accessors for private fields

2017-04-25 Thread David Malcolm
On Tue, 2017-04-25 at 12:11 -0400, Nathan Sidwell wrote: > On 04/25/2017 11:58 AM, David Malcolm wrote: > > >{ return FIELD; } > > > > for the correct field, favoring returning T to returning T&. > > Hm, that seems the poorer choice (unless you can suggest both). > After > all the T& case

Re: [PATCH] C++: fix-it hints suggesting accessors for private fields

2017-04-25 Thread Nathan Sidwell
On 04/25/2017 11:58 AM, David Malcolm wrote: { return FIELD; } for the correct field, favoring returning T to returning T&. Hm, that seems the poorer choice (unless you can suggest both). After all the T& case will meet the rvalue case (const-qualifiers ignoring). I suppose if thing is

Re: [PATCH] C++: fix-it hints suggesting accessors for private fields

2017-04-25 Thread David Malcolm
On Tue, 2017-04-25 at 07:49 -0400, Nathan Sidwell wrote: > On 04/25/2017 07:46 AM, Nathan Sidwell wrote: > > On 04/24/2017 04:06 PM, David Malcolm wrote: > > > > > test.cc:12:13: note: field ‘int foo::m_field’ can be accessed via > > > ‘int > > > foo::get_field() const’ > > > return f->m_fiel

Re: [PATCH] C++: fix-it hints suggesting accessors for private fields

2017-04-25 Thread Nathan Sidwell
On 04/25/2017 07:46 AM, Nathan Sidwell wrote: On 04/24/2017 04:06 PM, David Malcolm wrote: test.cc:12:13: note: field ‘int foo::m_field’ can be accessed via ‘int foo::get_field() const’ return f->m_field; ^~~ get_field() Assuming that an IDE can offer to ap

Re: [PATCH] C++: fix-it hints suggesting accessors for private fields

2017-04-25 Thread Nathan Sidwell
On 04/24/2017 04:06 PM, David Malcolm wrote: test.cc:12:13: note: field ‘int foo::m_field’ can be accessed via ‘int foo::get_field() const’ return f->m_field; ^~~ get_field() Assuming that an IDE can offer to apply fix-it hints, this should make it easier to