Skip to content

[pull] swift/release/5.3 from apple:swift/release/5.3 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9af1072
[lldb] Update for removal of SourceFile::addImports
hamishknight Apr 13, 2020
f53d12b
[lldb] Resolve imports before manipulating AST
hamishknight Apr 14, 2020
05f5e2a
[AArch64][GlobalISel] Fixup <32b heterogeneous regbanks of G_PHIs jus…
aemerson Feb 24, 2020
750e49c
Revert "[InstCombine] fold zext of masked bit set/clear"
kadircet Jan 8, 2020
803d1b1
[lldb] Update for removal of SourceFile::addImports (#1079)
hamishknight Apr 20, 2020
ca0260d
Merge commit '7733347fca02' from apple/stable/20200108 into swift/master
Apr 21, 2020
7733347
Merge pull request #1086 from apple/pr-61468474
aemerson Apr 21, 2020
e038c78
Merge commit 'b7867f6ff1ec' from apple/stable/20200108 into swift/master
Apr 21, 2020
b7867f6
Merge pull request #1100 from apple/PR-59994008
ahatanaka Apr 21, 2020
87b6ab2
[lldb/Test] Decode stdout and stderr in case it contains Unicode.
JDevlieghere Apr 21, 2020
07e680a
[lldb/Test] XFAIL TestDataFormatterObjCNSError except for gmodules.
JDevlieghere Mar 26, 2020
715aa78
[VirtualFileSystem] Support directory entries in the YAMLVFSWriter
JDevlieghere Mar 27, 2020
83dca65
Re-land "[FileCollector] Add a method to add a whole directory and it…
JDevlieghere Mar 30, 2020
1d9a5be
[lldb/Reproducers] Always collect the whole dSYM in the reproducer
JDevlieghere Mar 30, 2020
a9abe89
Merge commit '150d68ed3f9c' from apple/stable/20200108 into swift/master
Apr 21, 2020
150d68e
Merge pull request #1101 from JDevlieghere/🍒/20200108/2de52422acf0466…
JDevlieghere Apr 21, 2020
724a15c
Implement TypeSystemSwiftTypeRef::GetArrayElementType() (NFC)
adrian-prantl Apr 17, 2020
3666548
Merge pull request #1090 from adrian-prantl/GetArrayElementType
adrian-prantl Apr 21, 2020
c9e31f7
[apple/stable/20200108] Fix ambiguity
JDevlieghere Apr 21, 2020
e8a928d
Unbreak ASan runtime in the simulators.
delcypher Apr 21, 2020
b574910
Add missing call to `Symbolizer::LateInitialize()` in UBSan's standal…
delcypher Apr 21, 2020
c1aa619
Merge pull request #1102 from JDevlieghere/🍒/20200108/1d9a5bea33c6b9b…
JDevlieghere Apr 22, 2020
de1720d
Merge commit 'c1aa61938dd2' from apple/stable/20200108 into swift/master
Apr 22, 2020
c94d846
Merge pull request #1103 from danliew-apple/cherry-pick-62067724
danliew-apple Apr 22, 2020
4ee92ef
Merge pull request #1104 from danliew-apple/cherry-pick-62083617
danliew-apple Apr 22, 2020
dcc89a2
Merge commit '4ee92ef9e7a0' from apple/stable/20200108 into swift/master
Apr 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ bool DlAddrSymbolizer::SymbolizeData(uptr addr, DataInfo *datainfo) {

#define K_ATOS_ENV_VAR "__check_mach_ports_lookup"

// This cannot live in `AtosSymbolizerProcess` because instances of that object
// are allocated by the internal allocator which under ASan is poisoned with
// kAsanInternalHeapMagic.
static char kAtosMachPortEnvEntry[] = K_ATOS_ENV_VAR "=000000000000000";

class AtosSymbolizerProcess : public SymbolizerProcess {
public:
explicit AtosSymbolizerProcess(const char *path)
Expand All @@ -69,7 +74,7 @@ class AtosSymbolizerProcess : public SymbolizerProcess {
// We use `putenv()` rather than `setenv()` so that we can later directly
// write into the storage without LibC getting involved to change what the
// variable is set to
int result = putenv(mach_port_env_var_entry_);
int result = putenv(kAtosMachPortEnvEntry);
CHECK_EQ(result, 0);
}
}
Expand All @@ -95,12 +100,13 @@ class AtosSymbolizerProcess : public SymbolizerProcess {
// for our task port. We can't call `setenv()` here because it might call
// malloc/realloc. To avoid that we instead update the
// `mach_port_env_var_entry_` variable with our current PID.
uptr count = internal_snprintf(mach_port_env_var_entry_,
sizeof(mach_port_env_var_entry_),
uptr count = internal_snprintf(kAtosMachPortEnvEntry,
sizeof(kAtosMachPortEnvEntry),
K_ATOS_ENV_VAR "=%s", pid_str_);
CHECK_GE(count, sizeof(K_ATOS_ENV_VAR) + internal_strlen(pid_str_));
// Document our assumption but without calling `getenv()` in normal
// builds.
DCHECK(getenv(K_ATOS_ENV_VAR));
DCHECK_EQ(internal_strcmp(getenv(K_ATOS_ENV_VAR), pid_str_), 0);
}

Expand All @@ -127,9 +133,10 @@ class AtosSymbolizerProcess : public SymbolizerProcess {
}

char pid_str_[16];
// Space for `\0` in `kAtosEnvVar_` is reused for `=`.
char mach_port_env_var_entry_[sizeof(K_ATOS_ENV_VAR) + sizeof(pid_str_)] =
K_ATOS_ENV_VAR "=0";
// Space for `\0` in `K_ATOS_ENV_VAR` is reused for `=`.
static_assert(sizeof(kAtosMachPortEnvEntry) ==
(sizeof(K_ATOS_ENV_VAR) + sizeof(pid_str_)),
"sizes should match");
};

#undef K_ATOS_ENV_VAR
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/lib/ubsan/ubsan_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ static void CommonStandaloneInit() {
AndroidLogInit();
InitializeCoverage(common_flags()->coverage, common_flags()->coverage_dir);
CommonInit();
Symbolizer::LateInitialize();
}

void __ubsan::InitAsStandalone() {
Expand Down
43 changes: 32 additions & 11 deletions lldb/include/lldb/Symbol/SwiftASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum class IRGenDebugInfoLevel : unsigned;
class CanType;
class DependencyTracker;
class DWARFImporterDelegate;
struct ImplicitImportInfo;
class IRGenOptions;
class NominalTypeDecl;
class SearchPathOptions;
Expand Down Expand Up @@ -595,7 +596,13 @@ class SwiftASTContext : public TypeSystemSwift {
/// \return the ExtraArgs of the ClangImporterOptions.
const std::vector<std::string> &GetClangArguments();

swift::ModuleDecl *CreateModule(const SourceModule &module, Status &error);
/// Attempt to create a Swift module, returning \c nullptr and setting
/// \p error if unsuccessful.
///
/// \param importInfo Information about which modules should be implicitly
/// imported by each file of the module.
swift::ModuleDecl *CreateModule(const SourceModule &module, Status &error,
swift::ImplicitImportInfo importInfo);

// This function should only be called when all search paths
// for all items in a swift::ASTContext have been setup to
Expand Down Expand Up @@ -1064,16 +1071,30 @@ class SwiftASTContext : public TypeSystemSwift {

void SetCachedType(ConstString mangled, const lldb::TypeSP &type_sp) override;

static bool PerformUserImport(SwiftASTContext &swift_ast_context,
SymbolContext &sc,
ExecutionContextScope &exe_scope,
lldb::StackFrameWP &stack_frame_wp,
swift::SourceFile &source_file, Status &error);

static bool PerformAutoImport(SwiftASTContext &swift_ast_context,
SymbolContext &sc,
lldb::StackFrameWP &stack_frame_wp,
swift::SourceFile *source_file, Status &error);
/// Retrieves the modules that need to be implicitly imported in a given
/// execution scope. This includes the modules imported by both the compile
/// unit as well as any imports from previous expression evaluations.
static bool
GetImplicitImports(SwiftASTContext &swift_ast_context, SymbolContext &sc,
ExecutionContextScope &exe_scope,
lldb::StackFrameWP &stack_frame_wp,
llvm::SmallVectorImpl<swift::ModuleDecl *> &modules,
Status &error);

/// Cache the user's imports from a SourceFile in a given execution scope such
/// that they are carried over into future expression evaluations.
static bool CacheUserImports(SwiftASTContext &swift_ast_context,
SymbolContext &sc,
ExecutionContextScope &exe_scope,
lldb::StackFrameWP &stack_frame_wp,
swift::SourceFile &source_file, Status &error);

/// Retrieve the modules imported by the compilation unit.
static bool
GetCompileUnitImports(SwiftASTContext &swift_ast_context, SymbolContext &sc,
lldb::StackFrameWP &stack_frame_wp,
llvm::SmallVectorImpl<swift::ModuleDecl *> &modules,
Status &error);

protected:
/// This map uses the string value of ConstStrings as the key, and the
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/Utility/Reproducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class FileProvider : public Provider<FileProvider> {
return m_collector;
}

void recordInterestingDirectory(const llvm::Twine &dir);

void Keep() override {
auto mapping = GetRoot().CopyByAppendingPathComponent(Info::file);
// Temporary files that are removed during execution can cause copy errors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1197,35 +1197,40 @@ static llvm::Expected<ParsedExpression> ParseAndImport(
snprintf(expr_name_buf, sizeof(expr_name_buf), "__lldb_expr_%u",
options.GetExpressionNumber());

// Gather the modules that need to be implicitly imported.
// The Swift stdlib needs to be imported before the SwiftLanguageRuntime can
// be used.
Status implicit_import_error;
llvm::SmallVector<swift::ModuleDecl *, 16> additional_imports;
if (!SwiftASTContext::GetImplicitImports(*swift_ast_context, sc, exe_scope,
stack_frame_wp, additional_imports,
implicit_import_error)) {
return make_error<ModuleImportError>(llvm::Twine("in implicit-import:\n") +
implicit_import_error.AsCString());
}

swift::ImplicitImportInfo importInfo;
importInfo.StdlibKind = swift::ImplicitStdlibKind::Stdlib;
for (auto *module : additional_imports)
importInfo.AdditionalModules.emplace_back(module, /*exported*/ false);

auto module_id = ast_context->getIdentifier(expr_name_buf);
auto &module = *swift::ModuleDecl::create(module_id, *ast_context);
const auto implicit_import_kind =
swift::SourceFile::ImplicitModuleImportKind::Stdlib;
auto &module = *swift::ModuleDecl::create(module_id, *ast_context,
importInfo);

swift::SourceFileKind source_file_kind = swift::SourceFileKind::Library;

if (playground || repl) {
source_file_kind = swift::SourceFileKind::Main;
}

// Create the source file. Note, we disable delayed parsing for the
// swift expression parser.
swift::SourceFile *source_file = new (*ast_context) swift::SourceFile(
module, source_file_kind, buffer_id, implicit_import_kind,
/*Keep tokens*/ false, /*KeepSyntaxTree*/ false,
module, source_file_kind, buffer_id, /*Keep tokens*/ false,
/*KeepSyntaxTree*/ false,
swift::SourceFile::ParsingFlags::DisableDelayedBodies);
module.addFile(*source_file);


// The Swift stdlib needs to be imported before the
// SwiftLanguageRuntime can be used.
Status auto_import_error;
if (!SwiftASTContext::PerformAutoImport(*swift_ast_context, sc,
stack_frame_wp, source_file,
auto_import_error))
return make_error<ModuleImportError>(llvm::Twine("in auto-import:\n") +
auto_import_error.AsCString());

// Swift Modules that rely on shared libraries (not frameworks)
// don't record the link information in the swiftmodule file, so we
// can't really make them work without outside information.
Expand Down Expand Up @@ -1276,6 +1281,13 @@ static llvm::Expected<ParsedExpression> ParseAndImport(
// inserting them in.
swift_ast_context->AddDebuggerClient(external_lookup);

if (swift_ast_context->HasErrors())
return make_error<SwiftASTContextError>();

// Resolve the file's imports, including the implicit ones returned from
// GetImplicitImports.
swift::performImportResolution(*source_file);

if (swift_ast_context->HasErrors())
return make_error<SwiftASTContextError>();

Expand Down Expand Up @@ -1327,21 +1339,16 @@ static llvm::Expected<ParsedExpression> ParseAndImport(
stack_frame_sp.reset();
}

swift::performImportResolution(*source_file);

if (swift_ast_context->HasErrors())
return make_error<SwiftASTContextError>();

// Do the auto-importing after Name Binding, that's when the Imports
// for the source file are figured out.
// Cache the source file's imports such that they're accessible to future
// expression evaluations.
{
std::lock_guard<std::recursive_mutex> global_context_locker(
IRExecutionUnit::GetLLVMGlobalContextMutex());

Status auto_import_error;
if (!SwiftASTContext::PerformUserImport(*swift_ast_context, sc, exe_scope,
stack_frame_wp, *source_file,
auto_import_error)) {
if (!SwiftASTContext::CacheUserImports(*swift_ast_context, sc, exe_scope,
stack_frame_wp, *source_file,
auto_import_error)) {
return make_error<ModuleImportError>(llvm::Twine("in user-import:\n") +
auto_import_error.AsCString());
}
Expand Down
14 changes: 6 additions & 8 deletions lldb/source/Plugins/ExpressionParser/Swift/SwiftREPL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,18 +566,16 @@ void SwiftREPL::CompleteCode(const std::string &current_code,
repl_module =
swift_ast->GetModule(completion_module_info, error);
if (repl_module == nullptr) {
repl_module = swift_ast->CreateModule(completion_module_info, error);
const swift::SourceFile::ImplicitModuleImportKind implicit_import_kind =
swift::SourceFile::ImplicitModuleImportKind::Stdlib;
swift::ImplicitImportInfo importInfo;
importInfo.StdlibKind = swift::ImplicitStdlibKind::Stdlib;
repl_module = swift_ast->CreateModule(completion_module_info, error,
importInfo);
llvm::Optional<unsigned> bufferID;
swift::SourceFile *repl_source_file = new (*ast)
swift::SourceFile(*repl_module, swift::SourceFileKind::REPL, bufferID,
implicit_import_kind, /*Keep tokens*/false);

// Given this file is empty and only exists to import the standard
// library, we can go ahead and just mark it as having been type checked.
repl_source_file->ASTStage = swift::SourceFile::TypeChecked;
/*Keep tokens*/false);
repl_module->addFile(*repl_source_file);
swift::performImportResolution(*repl_source_file);
m_completion_module_initialized = true;
}
if (repl_module) {
Expand Down
Loading