ClangImporter: run Clang with a proper executable path

Clang deduces its installation directory from the `argv[0]` parameter (see clang/lib/Frontend/CreateInvocationFromCommandLine.cpp), and the default include search paths are computed based on the installation directory.

This change allows compiling Swift code that imports the C++ stdlib without having to manually specify the include search path of `std` headers.
This commit is contained in:
Egor Zhdan
2021-04-01 21:58:13 +03:00
parent 0b3164203b
commit 6650a891f1
7 changed files with 37 additions and 2 deletions

View File

@@ -597,6 +597,10 @@ namespace swift {
/// Options for controlling the behavior of the Clang importer.
class ClangImporterOptions final {
public:
/// The path to the Clang compiler executable.
/// Used to detect the default include paths.
std::string clangPath = "clang";
/// The module cache path which the Clang importer should use.
std::string ModuleCachePath;