[Lldb-commits] [lldb] 5f7a5e3 - [lldb][NFC] Early-exit in SetupDeclVendor
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Wed May 13 07:55:04 PDT 2020
Author: Raphael Isemann
Date: 2020-05-13T16:54:38+02:00
New Revision: 5f7a5e3bdba3663c8ec9704e28f75f6b2850f9f8
URL: https://github.com/llvm/llvm-project/commit/5f7a5e3bdba3663c8ec9704e28f75f6b2850f9f8
DIFF: https://github.com/llvm/llvm-project/commit/5f7a5e3bdba3663c8ec9704e28f75f6b2850f9f8.diff
LOG: [lldb][NFC] Early-exit in SetupDeclVendor
Also removed the unnecessary element-by-element copy of the std::vector
hand_imported_modules to modules_for_macros.
Added:
Modified:
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
index 2b75c4f75c63..b2c6cba3bd58 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -348,37 +348,37 @@ bool ClangUserExpression::SetupPersistentState(DiagnosticManager &diagnostic_man
}
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() {
More information about the lldb-commits
mailing list