MaskRay / ccls

C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting
Apache License 2.0
3.73k stars 254 forks source link

failure to find reference to child virtual override in template class #906

Open Jacob-Burckhardt opened 1 year ago

Jacob-Burckhardt commented 1 year ago

Observed behavior

When the cursor is on Child::joe definition, xref-find-references finds nothing. It should have found the call to joe in main().

template<typename T>
struct Parent {
   virtual void joe()=0;
};

template<typename T>
struct Child : public Parent<T> {
   virtual void joe() {}; // line 8
};

int main() {
   Child<int> c;
   Parent<int> &p = c;
   p.joe();
}

If modified to remove templates, then it does find the call in main():

struct Parent {
   virtual void joe()=0;
};

struct Child : public Parent {
   virtual void joe() {};
};

int main() {
   Child c;
   Parent &p = c;
   p.joe();
}

Expected behavior

It should have found the call to joe in both of the above examples.

Steps to reproduce

  1. Put the cursor on "j" in the joe declaration on line 8 in the first code example.
  2. In emacs, run M-x xref-find-references.

System information