[Qt-creator] ** Caution Message may be spoofed ** Re: Find references of virtual functions?

Murphy, Sean smurphy at walbro.com
Mon Sep 14 15:12:58 CEST 2020


> > Anyhow, given it's a virtual, how can you know at compile time if
> > you're calling GrandChild::foo() or not?
> >
> > Abstract *blah = getFoo();
> > blah->foo(); // might call Grandchild::foo(), or not
> 
> FWIW, there are at least 3 cases when it is certainly known at compile time
> which overload is called:
> 
> 1) if object is referenced by value:
> 
>   Grandchild blah;
>   blah.foo();
> 
> 2) fully qualified method call:
> 
>   Grandchild *blah = getFoo();
>   blah->Grandchild::foo(); // or Base::foo() etc.
> 
> 3) when foo() is final in Grandchild:
> 
>   Grandchild *blah = getFoo();
>   blah->foo();

Thanks Konstantin, for clarifying better than my initial post did. The 3 examples 
above are exactly what I'm referring to. There are instances in the codebase 
where it should be pretty well determined at compile time which overload is 
going to get used, and I only want to see the ones that match for my use case 
(trying to find the impact of changing the behavior of just one of inherited 
classes' overloads).

But currently find all references doesn't give me the option to disregard ones 
that clearly can't be the one I'm trying to find. And because the Search Results 
pane only gives the single line of code that contains the symbol, I often don't 
have enough context there to determine which overload is going to be called, 
forcing me to click on most of the search result entries to then manually 
evaluate whether that chunk of code is likely calling the broken function or not.

Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com


More information about the Qt-creator mailing list