[Qt-creator] Virtual functions resolving

Orgad Shaneh orgads at gmail.com
Wed Nov 21 07:45:01 CET 2012


On Tue, Nov 20, 2012 at 10:29 PM, Orgad Shaneh <orgads at gmail.com> wrote:

> Hello,
>
> Following QTCREATORBUG-6067<https://bugreports.qt-project.org/browse/QTCREATORBUG-6067> (navigation
> in overrides/parents of a method), I'd like to suggest a new approach for
> function overrides navigation.
>
> I'll use the following snippet for reference. I'll try to make it as
> minimal as possible:
> class MostBasic
> {
>   virtual void v(); // 1
> }
>
> class Base : public MostBasic
> {
>   void v(); // 2
> }
>
> class Derived : public Base {}
>
> class MostDerived : public Derived
> {
>   void v(); // 3
> }
>
> void foo()
> {
>   MostBasic().v(); // 4
>   Base().v(); // 5
>   Derived().v(); // 6
>   MostDerived().v(); // 7
> }
>
> I'll divide the discussion into 2 use-cases:
> 1. Find Usages
> 2. Follow Symbol
>
> 0. Currently Find Usages mixes usages (references) with declarations. This
> is mostly useful for renames. When users (at least me and some people I
> asked :)) look for usages, they usually are not interested in declarations.
> To address this, I suggest adding a combobox in the C++ Usages search pane
> that will filter 'Declarations', 'Usages' or 'All'. The pane could be
> renamed respectively (C++ References? C++ Symbols?)
>
> 1. Conceptually, when users call Find Usages, they want to know which
> calls can reach this piece of code. For virtual functions, calls to 'lower'
> (i.e. more concrete) types which implement the function, will not reach the
> function in 'higher' types.
> For example, Find Usages on Base::v (usages only, we'll leave declarations
> for later) should only list entries 4 and 5 and 6. 7 is not calling Base::v
> since it is reimplemented in MostDerived.
>
> 2. Follow Symbol has complementary behavior. Conceptually, following a
> symbol means 'where will this call lead?'. Again, for virtual functions the
> answer is complex, since a call for a basic type can lead to a more
> concrete type.
> For example, Follow Symbol on entries 5 or 6 (here referring to
> declarations) should list entries 2 and 3, but not 1, since a call to Base,
> which implements v() itself, can not lead to MostBasic.
> To address this, I suggest adding a new action which will open a C++
> Usages search pane with declarations only, containing only relevant entries.
>
>
> Currently, handling function overrides doesn't seem to have high priority
> (for example QTCREATORBUG-5876<https://bugreports.qt-project.org/browse/QTCREATORBUG-5876> which
> was a real pain! It was open for more than a year until I finally solved it
> myself).
>
> I'd like to hear your opinions on these issues. Are my suggestions
> feasible? Would they require rewriting half of libcplusplus?
>
> Thanks,
> - Orgad
>

Another related bug report:
QTCREATORBUG-7486<https://bugreports.qt-project.org/browse/QTCREATORBUG-7486>
.

- Orgad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20121121/b3fa5c90/attachment.html>


More information about the Qt-creator mailing list