@@ -1103,69 +1103,44 @@ void ClangExpressionDeclMap::LookupInModulesDeclVendor(
1103
1103
NameSearchContext &context, ConstString name, unsigned current_id) {
1104
1104
Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
1105
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
- }
1106
+ auto *modules_decl_vendor = m_target->GetClangModulesDeclVendor ();
1107
+ if (!modules_decl_vendor)
1108
+ return ;
1137
1109
1138
- MaybeRegisterFunctionBody (copied_function_decl);
1110
+ bool append = false ;
1111
+ uint32_t max_matches = 1 ;
1112
+ std::vector<clang::NamedDecl *> decls;
1139
1113
1140
- context.AddNamedDecl (copied_function_decl);
1114
+ if (!modules_decl_vendor->FindDecls (name, append, max_matches, decls))
1115
+ return ;
1141
1116
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
- }
1117
+ assert (!decls.empty () && " FindDecls returned true but no decls?" );
1118
+ clang::NamedDecl *const decl_from_modules = decls[0 ];
1151
1119
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 ;
1120
+ LLDB_LOG (log,
1121
+ " CAS::FEVD[{0}] Matching decl found for "
1122
+ " \" {1}\" in the modules" ,
1123
+ current_id, name);
1155
1124
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);
1125
+ clang::Decl *copied_decl = CopyDecl (decl_from_modules);
1126
+ if (!copied_decl) {
1127
+ LLDB_LOG (log,
1128
+ " CAS::FEVD[{0}] - Couldn't export a "
1129
+ " declaration from the modules" ,
1130
+ current_id);
1131
+ return ;
1132
+ }
1161
1133
1162
- return ;
1163
- }
1134
+ if ( auto copied_function = dyn_cast<clang::FunctionDecl>(copied_decl)) {
1135
+ MaybeRegisterFunctionBody (copied_function);
1164
1136
1165
- context.AddNamedDecl (copied_var_decl );
1137
+ context.AddNamedDecl (copied_function );
1166
1138
1167
- context.m_found .variable = true ;
1168
- }
1139
+ context.m_found .function_with_type_info = true ;
1140
+ context.m_found .function = true ;
1141
+ } else if (auto copied_var = dyn_cast<clang::VarDecl>(copied_decl)) {
1142
+ context.AddNamedDecl (copied_var);
1143
+ context.m_found .variable = true ;
1169
1144
}
1170
1145
}
1171
1146
0 commit comments