Manually merge remote-tracking branch 'upstream/master' into HEAD

This commit is contained in:
Nathan Hawes
2020-08-04 13:47:48 -07:00
150 changed files with 3925 additions and 1866 deletions

View File

@@ -44,17 +44,26 @@ swift::CompilerInvocation::CompilerInvocation() {
}
void CompilerInvocation::computeRuntimeResourcePathFromExecutablePath(
StringRef mainExecutablePath, llvm::SmallString<128> &runtimeResourcePath) {
runtimeResourcePath.assign(mainExecutablePath);
StringRef mainExecutablePath, bool shared,
llvm::SmallVectorImpl<char> &runtimeResourcePath) {
runtimeResourcePath.append(mainExecutablePath.begin(),
mainExecutablePath.end());
llvm::sys::path::remove_filename(runtimeResourcePath); // Remove /swift
llvm::sys::path::remove_filename(runtimeResourcePath); // Remove /bin
llvm::sys::path::append(runtimeResourcePath, "lib", "swift");
appendSwiftLibDir(runtimeResourcePath, shared);
}
void CompilerInvocation::appendSwiftLibDir(llvm::SmallVectorImpl<char> &path,
bool shared) {
llvm::sys::path::append(path, "lib", shared ? "swift" : "swift_static");
}
void CompilerInvocation::setMainExecutablePath(StringRef Path) {
FrontendOpts.MainExecutablePath = Path.str();
llvm::SmallString<128> LibPath;
computeRuntimeResourcePathFromExecutablePath(Path, LibPath);
computeRuntimeResourcePathFromExecutablePath(
Path, FrontendOpts.UseSharedResourceFolder, LibPath);
setRuntimeResourcePath(LibPath.str());
llvm::SmallString<128> DiagnosticDocsPath(Path);
@@ -1727,11 +1736,10 @@ static bool ParseMigratorArgs(MigratorOptions &Opts,
}
bool CompilerInvocation::parseArgs(
ArrayRef<const char *> Args,
DiagnosticEngine &Diags,
ArrayRef<const char *> Args, DiagnosticEngine &Diags,
SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>>
*ConfigurationFileBuffers,
StringRef workingDirectory) {
StringRef workingDirectory, StringRef mainExecutablePath) {
using namespace options;
if (Args.empty())
@@ -1762,6 +1770,10 @@ bool CompilerInvocation::parseArgs(
return true;
}
if (!mainExecutablePath.empty()) {
setMainExecutablePath(mainExecutablePath);
}
ParseModuleInterfaceArgs(ModuleInterfaceOpts, ParsedArgs);
SaveModuleInterfaceArgs(ModuleInterfaceOpts, FrontendOpts, ParsedArgs, Diags);