}
static void SetupDeclVendor(ExecutionContext &exe_ctx, Target *target) {
- if (ClangModulesDeclVendor *decl_vendor =
- target->GetClangModulesDeclVendor()) {
- auto *persistent_state = llvm::cast<ClangPersistentVariables>(
- target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC));
- if (!persistent_state)
- return;
- const ClangModulesDeclVendor::ModuleVector &hand_imported_modules =
- persistent_state->GetHandLoadedClangModules();
- ClangModulesDeclVendor::ModuleVector modules_for_macros;
+ ClangModulesDeclVendor *decl_vendor = target->GetClangModulesDeclVendor();
+ if (!decl_vendor)
+ return;
- for (ClangModulesDeclVendor::ModuleID module : hand_imported_modules) {
- modules_for_macros.push_back(module);
- }
+ if (!target->GetEnableAutoImportClangModules())
+ return;
+
+ auto *persistent_state = llvm::cast<ClangPersistentVariables>(
+ target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC));
+ if (!persistent_state)
+ return;
- if (target->GetEnableAutoImportClangModules()) {
- if (StackFrame *frame = exe_ctx.GetFramePtr()) {
- if (Block *block = frame->GetFrameBlock()) {
- SymbolContext sc;
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ if (!frame)
+ return;
+
+ Block *block = frame->GetFrameBlock();
+ if (!block)
+ return;
+ SymbolContext sc;
- block->CalculateSymbolContext(&sc);
+ block->CalculateSymbolContext(&sc);
- if (sc.comp_unit) {
- StreamString error_stream;
+ if (!sc.comp_unit)
+ return;
+ StreamString error_stream;
- decl_vendor->AddModulesForCompileUnit(
- *sc.comp_unit, modules_for_macros, error_stream);
- }
- }
- }
- }
- }
+ ClangModulesDeclVendor::ModuleVector modules_for_macros =
+ persistent_state->GetHandLoadedClangModules();
+ decl_vendor->AddModulesForCompileUnit(*sc.comp_unit, modules_for_macros,
+ error_stream);
}
void ClangUserExpression::UpdateLanguageForExpr() {