A bit of help with Clang C++ header search paths

Hi,

Here's my understanding of how include paths for the C++ Standard Library work in Clang (this assumes -stdlib=libc++):

1. Based on the platform, the driver looks at various things like the installation path for Clang and passes `-internal-isystem <some-path>/c++/v1` to CC1.
2. The driver also passes -isysroot to CC1 if its own command-line contained -isysroot.
3. CC1 adds the path passed in -internal-isystem as the first search path in the search list.
4. CC1 looks at -isysroot and adds `<SYSROOT>/usr/include/c++/v1` to the header search paths (after whatever was specified in `-internal-isystem`). If no -isysroot was specified, `/` is used (and so `/usr/include/c++/v1` is added).
5. Any path that doesn't exist is removed from the list of search paths.

Is this accurate? If so, I'm wondering why CC1 adds `<SYSROOT>/usr/include/c++/v1` to the search paths in (4) -- it seems like it should rely solely on the `-internal-isystem` path passed to it by the driver? Why isn't that the case?

Thanks,
Louis

It looks like I just answered my question with this comment found in CC1:

void InitHeaderSearch::AddDefaultIncludePaths(…) {
// NB: This code path is going away. All of the logic is moving into the
// driver which has the information necessary to do target-specific
// selections of default include paths. Each target which moves there will be
// exempted from this logic here until we can delete the entire pile of code.

So it looks like this only happens on a few platforms (including Darwin), and this is just technical debt we need to get rid of. That makes sense to me and I’ll try to take a stab at it.

Louis