@@ -1754,6 +1754,20 @@ static std::string GetSDKPathFromDebugInfo(std::string m_description,
1754
1754
return GetSDKPath (m_description, sdk);
1755
1755
}
1756
1756
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
+
1757
1771
// / Detect whether a Swift module was "imported" by DWARFImporter.
1758
1772
// / All this *really* means is that it couldn't be loaded through any
1759
1773
// / other mechanism.
@@ -1879,16 +1893,10 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
1879
1893
llvm::raw_svector_ostream errs (error);
1880
1894
// Implicit search paths will be discovered by ValidateSecionModules().
1881
1895
bool discover_implicit_search_paths = false ;
1882
-
1883
1896
auto ast_file_datas = module .GetASTData (eLanguageTypeSwift);
1884
1897
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);
1892
1900
1893
1901
// If no N_AST symbols exist, this is not an error.
1894
1902
if (!buffers.empty ())
@@ -2207,16 +2215,10 @@ static void ProcessModule(
2207
2215
llvm::SmallString<0 > error;
2208
2216
llvm::raw_svector_ostream errs (error);
2209
2217
swift::CompilerInvocation invocation;
2210
-
2211
2218
auto ast_file_datas = module_sp->GetASTData (eLanguageTypeSwift);
2212
2219
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);
2220
2222
2221
2223
// If no N_AST symbols exist, this is not an error.
2222
2224
if (!buffers.empty ())
0 commit comments