sourcegraph / scip-clang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support code nav for dependent members in headers relying on definitions in unincluded headers

varungandhi-src opened this issue · comments

The title of the issue is a bit of a mouthful, but you can see this in #330

The problem is that template code in the iosfwd header accesses members inside forward-declared templated types, i.e. the definition is not transitively included by iosfwd itself. Rather, some other header is responsible for making sure that the right definition is included if needed.

So you can have a situation like the following:

  1. A.cpp only includes such a fwd-header (maybe it doesn't rely on any API inside). - When A.cpp is indexed, the fwd-header is also indexed.
  2. B.cpp includes the header with the definition as well as the fwd-header. - When B.cpp is indexed, the fwd-header is skipped for indexing, since in terms of preprocessor effects, there is no change.

Had the fwd-header be included in B.cpp, the result of indexing would've been different.

I'm not sure about what the best way to address this is. One thing we could do is handle templates/dependent names differently, and don't perform the header skipping optimization for them. Later, we can merge information across headers. But this may cause a lot of temporary data to be generated due to heavy use of templates in stdlib headers. 🤕