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

Murphy, Sean smurphy at walbro.com
Mon Sep 14 16:09:44 CEST 2020


> Note that if such feature was implemented and you could find all places where
> your target overload is certainly called, there would be other call sites where it
> *might* be called and this is what "find all references" is trying to show.

Yep, agreed. And I'd be ok with that if both (or maybe more) search options were 
available.  But the issue I'm running into currently is it showing me places where 
the overload I currently care about CAN'T POSSIBLY be getting called, but because 
of how the search pane only shows the single result line I can't tell for sure without 
clicking on each one and evaluating. My updated example this morning better 
describes my hierarchy:
  class AbstractShape
  -- class Polygon : public AbstractShape
  ---- class Square : public Polygon
  ---- class Triangle : public Polygon
  Assume all classes have a function called area(), with AbstractShape::area() = 0.

In this case a Square can never be a Triangle and vice versa, but if I put the cursor in 
the definition of Square::area() in square.cpp, and find all references, the search results 
show me Triangle::area() in triangle.h/.cpp, other calls to Triangle::area() within 
triangle.cpp as well as all instances where elsewhere in the codebase we have something like: 
  Triangle t;
  t.area();
Or
  Triangle * t = dynamic_cast< Triangle *>(abstractShape);
  if(t) { t->area;}
But indeed, that is what Qt Creator currently does.

Basically if at search time I could specify between:
1. Give me all of them (Qt Creator's current behavior). So I get AbstractShape, 
Polygon, Square, and Triangle results, same as today.
2. Give me only the ones that DEFINITELY are my inherited classes version, even if that 
means I miss all the ones that MIGHT be. Which in this specific use case would work 
perfectly for me because it appears we don't seem to be doing much of Giuseppe's 
example (updated for today's example classes):
  AbstractShape *blah = getShape();
  blah->area();
Instead we seem to be doing more of
  Triangle * t = dynamic_cast< Triangle *>(abstractShape);
  if(t) { t->area;}
So for this one, I'd only get Square results - AbstractShape, Polygon, and 
Triangle instances would be excluded.
3. Give me all that DEFINITELY are my inherited class plus all that MIGHT be (so 
Giuseppe's example), but exclude any that definitely AREN'T. So for this one, I 
get the Square, AbstractShape, and Polygon, but ones that are definitely Triangle are 
excluded. 

Option 3 honestly seems like a better default behavior if you start your search in one 
of the inherited classes than what Qt Creator is currently doing. 

Sean


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


More information about the Qt-creator mailing list