Skip to content

Commit 81db3d7

Browse files
Merge pull request #3876 from adrian-prantl/sunset-earger-context-warnings
Remove eager propagation of SwiftASTContext warnings to Target.
2 parents cdd2e1c + 38d470c commit 81db3d7

File tree

3 files changed

+3
-50
lines changed

3 files changed

+3
-50
lines changed

lldb/include/lldb/Target/Target.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,16 +1458,7 @@ class Target : public std::enable_shared_from_this<Target>,
14581458
return m_use_scratch_typesystem_per_module;
14591459
}
14601460

1461-
private:
1462-
std::mutex m_swift_messages_mutex;
1463-
std::unordered_set<std::string> m_swift_messages_issued;
1464-
14651461
public:
1466-
/// Register that a message (uniquely identified by \p Key) about a Swift
1467-
/// context is about to be displayed to the user. Returns true iff the message
1468-
/// has not already been displayed.
1469-
bool RegisterSwiftContextMessageKey(std::string Key);
1470-
14711462
StackFrameRecognizerManager &GetFrameRecognizerManager() {
14721463
return *m_frame_recognizer_manager_up;
14731464
}

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,7 +1947,7 @@ static SwiftASTContext *GetModuleSwiftASTContext(Module &module) {
19471947
/// its module SwiftASTContext to Target.
19481948
static void
19491949
ProcessModule(ModuleSP module_sp, std::string m_description,
1950-
bool use_all_compiler_flags, Target &target,
1950+
bool use_all_compiler_flags, Target &target, llvm::Triple triple,
19511951
std::vector<std::string> &module_search_paths,
19521952
std::vector<std::pair<std::string, bool>> &framework_search_paths,
19531953
std::vector<std::string> &extra_clang_args) {
@@ -2023,37 +2023,6 @@ ProcessModule(ModuleSP module_sp, std::string m_description,
20232023
if (!HasSwiftModules(*module_sp))
20242024
return;
20252025

2026-
SwiftASTContext *ast_context = GetModuleSwiftASTContext(*module_sp);
2027-
if (!ast_context || ast_context->HasFatalErrors() ||
2028-
!ast_context->GetClangImporter()) {
2029-
// Make sure we warn about this module load failure, the one
2030-
// that comes from loading types often gets swallowed up and not
2031-
// seen, this is the only reliable point where we can show this.
2032-
// But only do it once per UUID so we don't overwhelm the user
2033-
// with warnings.
2034-
UUID module_uuid(module_sp->GetUUID());
2035-
bool unique_message =
2036-
target.RegisterSwiftContextMessageKey(module_uuid.GetAsString());
2037-
if (!unique_message)
2038-
return;
2039-
std::string buf;
2040-
{
2041-
llvm::raw_string_ostream ss(buf);
2042-
module_sp->GetDescription(ss, eDescriptionLevelBrief);
2043-
if (ast_context && ast_context->HasFatalErrors())
2044-
ss << ": " << ast_context->GetFatalErrors().AsCString("unknown error");
2045-
}
2046-
target.GetDebugger().GetErrorStreamSP()->Printf(
2047-
"Error while loading Swift module:\n%s\n"
2048-
"Debug info from this module will be unavailable in the "
2049-
"debugger.\n\n",
2050-
buf.c_str());
2051-
return;
2052-
}
2053-
2054-
if (ast_context->HasErrors())
2055-
return;
2056-
20572026
// Load search path options from the module.
20582027
if (!use_all_compiler_flags &&
20592028
target.GetExecutableModulePointer() != module_sp.get())
@@ -2069,7 +2038,6 @@ ProcessModule(ModuleSP module_sp, std::string m_description,
20692038
// older versions of the same .swiftinterface.
20702039
if (auto dsym = GetDSYMBundle(*module_sp)) {
20712040
llvm::SmallString<256> path(*dsym);
2072-
llvm::Triple triple(ast_context->GetTriple());
20732041
StringRef arch = llvm::Triple::getArchTypeName(triple.getArch());
20742042
llvm::sys::path::append(path, "Contents", "Resources", "Swift", arch);
20752043
bool exists = false;
@@ -2281,11 +2249,10 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
22812249
const bool use_all_compiler_flags =
22822250
!got_serialized_options || target.GetUseAllCompilerFlags();
22832251

2284-
warmup_astcontexts();
22852252
for (size_t mi = 0; mi != num_images; ++mi) {
22862253
std::vector<std::string> extra_clang_args;
22872254
ProcessModule(target.GetImages().GetModuleAtIndex(mi), m_description,
2288-
use_all_compiler_flags, target, module_search_paths,
2255+
use_all_compiler_flags, target, triple, module_search_paths,
22892256
framework_search_paths, extra_clang_args);
22902257
swift_ast_sp->AddExtraClangArgs(extra_clang_args);
22912258
}
@@ -5103,7 +5070,7 @@ void SwiftASTContextForExpressions::ModulesDidLoad(ModuleList &module_list) {
51035070
std::vector<std::string> extra_clang_args;
51045071
lldb::ModuleSP module_sp = module_list.GetModuleAtIndex(mi);
51055072
ProcessModule(module_sp, m_description, use_all_compiler_flags, *target_sp,
5106-
module_search_paths, framework_search_paths,
5073+
GetTriple(), module_search_paths, framework_search_paths,
51075074
extra_clang_args);
51085075
// If the use-all-compiler-flags setting is enabled, the expression
51095076
// context is supposed to merge all search paths from all dylibs.

lldb/source/Target/Target.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4875,10 +4875,5 @@ std::recursive_mutex &Target::GetAPIMutex() {
48754875
return m_mutex;
48764876
}
48774877

4878-
bool Target::RegisterSwiftContextMessageKey(std::string Key) {
4879-
std::unique_lock<std::mutex> guard{m_swift_messages_mutex};
4880-
return m_swift_messages_issued.insert(std::move(Key)).second;
4881-
}
4882-
48834878
/// Get metrics associated with this target in JSON format.
48844879
llvm::json::Value Target::ReportStatistics() { return m_stats.ToJSON(*this); }

0 commit comments

Comments
 (0)