@@ -1099,6 +1099,76 @@ void ClangExpressionDeclMap::LookupLocalVarNamespace(
1099
1099
}
1100
1100
}
1101
1101
1102
+ void ClangExpressionDeclMap::LookupInModulesDeclVendor (
1103
+ NameSearchContext &context, ConstString name, unsigned current_id) {
1104
+ Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
1105
+
1106
+ if (ClangModulesDeclVendor *modules_decl_vendor =
1107
+ m_target->GetClangModulesDeclVendor ()) {
1108
+ bool append = false ;
1109
+ uint32_t max_matches = 1 ;
1110
+ std::vector<clang::NamedDecl *> decls;
1111
+
1112
+ if (!modules_decl_vendor->FindDecls (name, append, max_matches, decls))
1113
+ return ;
1114
+
1115
+ clang::NamedDecl *const decl_from_modules = decls[0 ];
1116
+
1117
+ if (llvm::isa<clang::FunctionDecl>(decl_from_modules)) {
1118
+ if (log ) {
1119
+ LLDB_LOGF (log ,
1120
+ " CAS::FEVD[%u] Matching function found for "
1121
+ " \" %s\" in the modules" ,
1122
+ current_id, name.GetCString ());
1123
+ }
1124
+
1125
+ clang::Decl *copied_decl = CopyDecl (decl_from_modules);
1126
+ clang::FunctionDecl *copied_function_decl =
1127
+ copied_decl ? dyn_cast<clang::FunctionDecl>(copied_decl) : nullptr ;
1128
+
1129
+ if (!copied_function_decl) {
1130
+ LLDB_LOGF (log ,
1131
+ " CAS::FEVD[%u] - Couldn't export a function "
1132
+ " declaration from the modules" ,
1133
+ current_id);
1134
+
1135
+ return ;
1136
+ }
1137
+
1138
+ MaybeRegisterFunctionBody (copied_function_decl);
1139
+
1140
+ context.AddNamedDecl (copied_function_decl);
1141
+
1142
+ context.m_found .function_with_type_info = true ;
1143
+ context.m_found .function = true ;
1144
+ } else if (llvm::isa<clang::VarDecl>(decl_from_modules)) {
1145
+ if (log ) {
1146
+ LLDB_LOGF (log ,
1147
+ " CAS::FEVD[%u] Matching variable found for "
1148
+ " \" %s\" in the modules" ,
1149
+ current_id, name.GetCString ());
1150
+ }
1151
+
1152
+ clang::Decl *copied_decl = CopyDecl (decl_from_modules);
1153
+ clang::VarDecl *copied_var_decl =
1154
+ copied_decl ? dyn_cast_or_null<clang::VarDecl>(copied_decl) : nullptr ;
1155
+
1156
+ if (!copied_var_decl) {
1157
+ LLDB_LOGF (log ,
1158
+ " CAS::FEVD[%u] - Couldn't export a variable "
1159
+ " declaration from the modules" ,
1160
+ current_id);
1161
+
1162
+ return ;
1163
+ }
1164
+
1165
+ context.AddNamedDecl (copied_var_decl);
1166
+
1167
+ context.m_found .variable = true ;
1168
+ }
1169
+ }
1170
+ }
1171
+
1102
1172
void ClangExpressionDeclMap::FindExternalVisibleDecls (
1103
1173
NameSearchContext &context, lldb::ModuleSP module_sp,
1104
1174
CompilerDeclContext &namespace_decl, unsigned int current_id) {
@@ -1433,78 +1503,9 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
1433
1503
}
1434
1504
}
1435
1505
1436
- if (!context.m_found .function_with_type_info ) {
1437
- // Try the modules next.
1438
-
1439
- do {
1440
- if (ClangModulesDeclVendor *modules_decl_vendor =
1441
- m_target->GetClangModulesDeclVendor ()) {
1442
- bool append = false ;
1443
- uint32_t max_matches = 1 ;
1444
- std::vector<clang::NamedDecl *> decls;
1445
-
1446
- if (!modules_decl_vendor->FindDecls (name, append, max_matches, decls))
1447
- break ;
1448
-
1449
- clang::NamedDecl *const decl_from_modules = decls[0 ];
1450
-
1451
- if (llvm::isa<clang::FunctionDecl>(decl_from_modules)) {
1452
- if (log ) {
1453
- LLDB_LOGF (log ,
1454
- " CAS::FEVD[%u] Matching function found for "
1455
- " \" %s\" in the modules" ,
1456
- current_id, name.GetCString ());
1457
- }
1458
-
1459
- clang::Decl *copied_decl = CopyDecl (decl_from_modules);
1460
- clang::FunctionDecl *copied_function_decl =
1461
- copied_decl ? dyn_cast<clang::FunctionDecl>(copied_decl)
1462
- : nullptr ;
1463
-
1464
- if (!copied_function_decl) {
1465
- LLDB_LOGF (log ,
1466
- " CAS::FEVD[%u] - Couldn't export a function "
1467
- " declaration from the modules" ,
1468
- current_id);
1469
-
1470
- break ;
1471
- }
1472
-
1473
- MaybeRegisterFunctionBody (copied_function_decl);
1474
-
1475
- context.AddNamedDecl (copied_function_decl);
1476
-
1477
- context.m_found .function_with_type_info = true ;
1478
- context.m_found .function = true ;
1479
- } else if (llvm::isa<clang::VarDecl>(decl_from_modules)) {
1480
- if (log ) {
1481
- LLDB_LOGF (log ,
1482
- " CAS::FEVD[%u] Matching variable found for "
1483
- " \" %s\" in the modules" ,
1484
- current_id, name.GetCString ());
1485
- }
1486
-
1487
- clang::Decl *copied_decl = CopyDecl (decl_from_modules);
1488
- clang::VarDecl *copied_var_decl =
1489
- copied_decl ? dyn_cast_or_null<clang::VarDecl>(copied_decl)
1490
- : nullptr ;
1491
-
1492
- if (!copied_var_decl) {
1493
- LLDB_LOGF (log ,
1494
- " CAS::FEVD[%u] - Couldn't export a variable "
1495
- " declaration from the modules" ,
1496
- current_id);
1497
-
1498
- break ;
1499
- }
1500
-
1501
- context.AddNamedDecl (copied_var_decl);
1502
-
1503
- context.m_found .variable = true ;
1504
- }
1505
- }
1506
- } while (false );
1507
- }
1506
+ // Try the modules next.
1507
+ if (!context.m_found .function_with_type_info )
1508
+ LookupInModulesDeclVendor (context, name, current_id);
1508
1509
1509
1510
if (target && !context.m_found .variable && !namespace_decl) {
1510
1511
// We couldn't find a non-symbol variable for this. Now we'll hunt for a
0 commit comments