@@ -4142,21 +4142,36 @@ void SwiftASTContext::RegisterSectionModules(
4142
4142
if (!section_list)
4143
4143
return ;
4144
4144
4145
- SectionSP section_sp (
4146
- section_list->FindSectionByType (eSectionTypeSwiftModules, true ));
4147
- if (section_sp) {
4145
+ auto parse_ast_section = [&](llvm::StringRef section_data_ref, size_t n,
4146
+ size_t total) {
4147
+ llvm::SmallVector<std::string, 4 > swift_modules;
4148
+ if (!swift::parseASTSection (*loader, section_data_ref, swift_modules)) {
4149
+ LOG_PRINTF (LIBLLDB_LOG_TYPES,
4150
+ " failed to parse AST section %zu/%zu in image \" %s\" ." , n,
4151
+ total, module .GetFileSpec ().GetFilename ().GetCString ());
4152
+ return ;
4153
+ }
4154
+
4155
+ // Collect the Swift module names referenced by the AST.
4156
+ for (auto module_name : swift_modules) {
4157
+ module_names.push_back (module_name);
4158
+ LOG_PRINTF (LIBLLDB_LOG_TYPES,
4159
+ " parsed module \" %s\" from Swift AST section %zu/%zu in "
4160
+ " image \" %s\" ." ,
4161
+ module_name.c_str (), n, total,
4162
+ module .GetFileSpec ().GetFilename ().GetCString ());
4163
+ }
4164
+ };
4165
+
4166
+ if (auto section_sp =
4167
+ section_list->FindSectionByType (eSectionTypeSwiftModules, true )) {
4148
4168
DataExtractor section_data;
4149
4169
4150
4170
if (section_sp->GetSectionData (section_data)) {
4151
4171
llvm::StringRef section_data_ref (
4152
4172
(const char *)section_data.GetDataStart (),
4153
4173
section_data.GetByteSize ());
4154
- llvm::SmallVector<std::string, 4 > llvm_modules;
4155
- if (swift::parseASTSection (*loader, section_data_ref, llvm_modules)) {
4156
- for (auto module_name : llvm_modules)
4157
- module_names.push_back (module_name);
4158
- return ;
4159
- }
4174
+ parse_ast_section (section_data_ref, 1 , 1 );
4160
4175
}
4161
4176
} else {
4162
4177
if (m_ast_file_data_map.find (&module ) != m_ast_file_data_map.end ())
@@ -4176,37 +4191,15 @@ void SwiftASTContext::RegisterSectionModules(
4176
4191
4177
4192
// Retrieve the module names from the AST blobs retrieved
4178
4193
// from the symbol vendor.
4179
- size_t parse_fail_count = 0 ;
4180
- size_t ast_number = 0 ;
4194
+ size_t i = 0 ;
4181
4195
for (auto ast_file_data_sp : ast_file_datas) {
4182
4196
// Parse the AST section info from the AST blob.
4183
- ++ast_number;
4184
4197
llvm::StringRef section_data_ref (
4185
4198
(const char *)ast_file_data_sp->GetBytes (),
4186
4199
ast_file_data_sp->GetByteSize ());
4187
- llvm::SmallVector<std::string, 4 > swift_modules;
4188
- if (swift::parseASTSection (*loader, section_data_ref, swift_modules)) {
4189
- // Collect the Swift module names referenced by the AST.
4190
- for (auto module_name : swift_modules) {
4191
- module_names.push_back (module_name);
4192
- LOG_PRINTF (LIBLLDB_LOG_TYPES,
4193
- " parsed module \" %s\" from Swift AST section %zu of %zu." ,
4194
- module_name.c_str (), ast_number, ast_file_datas.size ());
4195
- }
4196
- } else {
4197
- // Keep track of the fact that we failed to parse the AST section
4198
- // info.
4199
- LOG_PRINTF (LIBLLDB_LOG_TYPES, " failed to parse AST section %zu of %zu." ,
4200
- ast_number, ast_file_datas.size ());
4201
- ++parse_fail_count;
4202
- }
4203
- }
4204
- if (!ast_file_datas.empty () && (parse_fail_count == 0 )) {
4205
- // We found AST data entries and we successfully parsed all of them.
4206
- return ;
4200
+ parse_ast_section (section_data_ref, ++i, ast_file_datas.size ());
4207
4201
}
4208
4202
}
4209
- return ;
4210
4203
}
4211
4204
4212
4205
void SwiftASTContext::ValidateSectionModules (
0 commit comments