Python clang does not search system include paths

十年热恋 提交于 2019-12-05 11:53:45

This question has been up for some time, so I'll attempt to answer it myself.

It seems that even Clang itself uses mostly hardcoded paths.

It enumerates candidate paths and adds the ones that fit under the current context. This can be seen in clang/lib/Frontend/InitHeaderSearch.cpp. E.g.,

AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
                           "i686-apple-darwin10", "", "x86_64", triple);
AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
                           "i686-apple-darwin8", "", "", triple);

// ...

For Linux, this code has the notice:

llvm_unreachable("Include management is handled in the driver.");

Under clang/lib/Driver/ we can find more of these paths in files such as ToolChains.cpp, CrossWindowsToolChain.cpp and MinGWToolChain.cpp.

What I was hoping for was that the code in InitHeaderSearch.cpp would be exposed to Python through libclang.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!