@@ -1754,6 +1754,20 @@ static std::string GetSDKPathFromDebugInfo(std::string m_description,
17541754 return GetSDKPath (m_description, sdk);
17551755}
17561756
1757+ static std::vector<llvm::StringRef>
1758+ GetASTBuffersFromModule (const std::string &m_description,
1759+ llvm::ArrayRef<lldb::DataBufferSP> ast_file_datas,
1760+ std::string &module_name) {
1761+ LOG_PRINTF (GetLog (LLDBLog::Types), " Found %d AST file data entries in %s." ,
1762+ (int )ast_file_datas.size (), module_name.c_str ());
1763+ std::vector<llvm::StringRef> buffers;
1764+ for (auto &data : ast_file_datas)
1765+ if (data)
1766+ buffers.push_back (
1767+ StringRef ((const char *)data->GetBytes (), data->GetByteSize ()));
1768+ return buffers;
1769+ }
1770+
17571771// / Detect whether a Swift module was "imported" by DWARFImporter.
17581772// / All this *really* means is that it couldn't be loaded through any
17591773// / other mechanism.
@@ -1879,16 +1893,10 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
18791893 llvm::raw_svector_ostream errs (error);
18801894 // Implicit search paths will be discovered by ValidateSecionModules().
18811895 bool discover_implicit_search_paths = false ;
1882-
18831896 auto ast_file_datas = module .GetASTData (eLanguageTypeSwift);
18841897 std::string module_name = module .GetSpecificationDescription ();
1885- LOG_PRINTF (GetLog (LLDBLog::Types), " Found %d AST file data entries in %s." ,
1886- (int )ast_file_datas.size (), module_name.c_str ());
1887- std::vector<llvm::StringRef> buffers;
1888- for (auto &data : ast_file_datas)
1889- if (data)
1890- buffers.push_back (
1891- StringRef ((const char *)data->GetBytes (), data->GetByteSize ()));
1898+ std::vector<llvm::StringRef> buffers =
1899+ GetASTBuffersFromModule (m_description, ast_file_datas, module_name);
18921900
18931901 // If no N_AST symbols exist, this is not an error.
18941902 if (!buffers.empty ())
@@ -2207,16 +2215,10 @@ static void ProcessModule(
22072215 llvm::SmallString<0 > error;
22082216 llvm::raw_svector_ostream errs (error);
22092217 swift::CompilerInvocation invocation;
2210-
22112218 auto ast_file_datas = module_sp->GetASTData (eLanguageTypeSwift);
22122219 std::string module_name = module_sp->GetSpecificationDescription ();
2213- LOG_PRINTF (GetLog (LLDBLog::Types), " Found %d AST file data entries in %s." ,
2214- (int )ast_file_datas.size (), module_name.c_str ());
2215- std::vector<llvm::StringRef> buffers;
2216- for (auto &data : ast_file_datas)
2217- if (data)
2218- buffers.push_back (
2219- StringRef ((const char *)data->GetBytes (), data->GetByteSize ()));
2220+ std::vector<llvm::StringRef> buffers =
2221+ GetASTBuffersFromModule (m_description, ast_file_datas, module_name);
22202222
22212223 // If no N_AST symbols exist, this is not an error.
22222224 if (!buffers.empty ())
0 commit comments