[Lldb-commits] [lldb] 1e0d395 - [lldb][NFC] Do an early exit in LookupLocalVarNamespace and LookUpLldbObjCClass
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Sat Nov 23 13:49:02 PST 2019
Author: Raphael Isemann
Date: 2019-11-23T22:48:09+01:00
New Revision: 1e0d395480b3cc4d1364aab74a81ce5ba29a470c
URL: https://github.com/llvm/llvm-project/commit/1e0d395480b3cc4d1364aab74a81ce5ba29a470c
DIFF: https://github.com/llvm/llvm-project/commit/1e0d395480b3cc4d1364aab74a81ce5ba29a470c.diff
LOG: [lldb][NFC] Do an early exit in LookupLocalVarNamespace and LookUpLldbObjCClass
Added:
Modified:
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
Removed:
################################################################################
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 60759be0eb0f..30c0ddd3f2a0 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1039,64 +1039,72 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
lldb::VariableSP self_var = vars->FindVariable(ConstString("self"));
- if (self_var && self_var->IsInScope(frame) &&
- self_var->LocationIsValidForFrame(frame)) {
- Type *self_type = self_var->GetType();
+ if (!self_var)
+ return;
+ if (!self_var->IsInScope(frame))
+ return;
+ if (!self_var->LocationIsValidForFrame(frame))
+ return;
- if (!self_type)
- return;
+ Type *self_type = self_var->GetType();
- CompilerType self_clang_type = self_type->GetFullCompilerType();
+ if (!self_type)
+ return;
- if (ClangASTContext::IsObjCClassType(self_clang_type)) {
- return;
- } else if (ClangASTContext::IsObjCObjectPointerType(self_clang_type)) {
- self_clang_type = self_clang_type.GetPointeeType();
+ CompilerType self_clang_type = self_type->GetFullCompilerType();
- if (!self_clang_type)
- return;
+ if (ClangASTContext::IsObjCClassType(self_clang_type)) {
+ return;
+ }
+ if (!ClangASTContext::IsObjCObjectPointerType(self_clang_type))
+ return;
+ self_clang_type = self_clang_type.GetPointeeType();
- if (log) {
- ASTDumper ast_dumper(self_type->GetFullCompilerType());
- LLDB_LOGF(log, " FEVD[%u] Adding type for $__lldb_objc_class: %s",
- current_id, ast_dumper.GetCString());
- }
+ if (!self_clang_type)
+ return;
- TypeFromUser class_user_type(self_clang_type);
+ if (log) {
+ ASTDumper ast_dumper(self_type->GetFullCompilerType());
+ LLDB_LOGF(log, " FEVD[%u] Adding type for $__lldb_objc_class: %s",
+ current_id, ast_dumper.GetCString());
+ }
- AddOneType(context, class_user_type, current_id);
+ TypeFromUser class_user_type(self_clang_type);
- TypeFromUser self_user_type(self_type->GetFullCompilerType());
+ AddOneType(context, class_user_type, current_id);
- m_struct_vars->m_object_pointer_type = self_user_type;
- }
- }
+ TypeFromUser self_user_type(self_type->GetFullCompilerType());
+
+ m_struct_vars->m_object_pointer_type = self_user_type;
}
void ClangExpressionDeclMap::LookupLocalVarNamespace(
- SymbolContext &sym_ctx, NameSearchContext &context) {
- CompilerDeclContext frame_decl_context = sym_ctx.block != nullptr
- ? sym_ctx.block->GetDeclContext()
- : CompilerDeclContext();
-
- if (frame_decl_context) {
- ClangASTContext *frame_ast = llvm::dyn_cast_or_null<ClangASTContext>(
- frame_decl_context.GetTypeSystem());
-
- ClangASTContext *map_ast = ClangASTContext::GetASTContext(m_ast_context);
- if (frame_ast && map_ast) {
- clang::NamespaceDecl *namespace_decl =
- map_ast->GetUniqueNamespaceDeclaration(
- g_lldb_local_vars_namespace_cstr, nullptr);
- if (namespace_decl) {
- context.AddNamedDecl(namespace_decl);
- clang::DeclContext *clang_decl_ctx =
- clang::Decl::castToDeclContext(namespace_decl);
- clang_decl_ctx->setHasExternalVisibleStorage(true);
- context.m_found.local_vars_nsp = true;
- }
- }
- }
+ SymbolContext &sym_ctx, NameSearchContext &name_context) {
+ if (sym_ctx.block == nullptr)
+ return;
+
+ CompilerDeclContext frame_decl_context = sym_ctx.block->GetDeclContext();
+ if (!frame_decl_context)
+ return;
+
+ ClangASTContext *frame_ast = llvm::dyn_cast_or_null<ClangASTContext>(
+ frame_decl_context.GetTypeSystem());
+ if (!frame_ast)
+ return;
+
+ ClangASTContext *map_ast = ClangASTContext::GetASTContext(m_ast_context);
+ if (!map_ast)
+ return;
+
+ clang::NamespaceDecl *namespace_decl = map_ast->GetUniqueNamespaceDeclaration(
+ g_lldb_local_vars_namespace_cstr, nullptr);
+ if (!namespace_decl)
+ return;
+
+ name_context.AddNamedDecl(namespace_decl);
+ clang::DeclContext *ctxt = clang::Decl::castToDeclContext(namespace_decl);
+ ctxt->setHasExternalVisibleStorage(true);
+ name_context.m_found.local_vars_nsp = true;
}
void ClangExpressionDeclMap::LookupInModulesDeclVendor(
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
index 506a6952caad..1f308edf20cf 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
@@ -416,10 +416,10 @@ class ClangExpressionDeclMap : public ClangASTSource {
/// \param[in] sym_ctx
/// The current SymbolContext of this frame.
///
- /// \param[in] context
+ /// \param[in] name_context
/// The NameSearchContext that can construct Decls for this name.
void LookupLocalVarNamespace(SymbolContext &sym_ctx,
- NameSearchContext &context);
+ NameSearchContext &name_context);
/// Lookup entities in the ClangModulesDeclVendor.
/// \param[in] context
More information about the lldb-commits
mailing list