diff options
author | Raphael Isemann <teemperor@gmail.com> | 2019-11-21 10:45:04 +0100 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2019-11-21 11:03:24 +0100 |
commit | 337151f41e78f42df1eedbb86479888a2c5d0a04 (patch) | |
tree | 36adbd600e511d94bf8f30d4cac96a35e477f00d | |
parent | ba6f906854263375cff3257d22d241a8a259cf77 (diff) | |
download | bcm5719-llvm-337151f41e78f42df1eedbb86479888a2c5d0a04.tar.gz bcm5719-llvm-337151f41e78f42df1eedbb86479888a2c5d0a04.zip |
[lldb][NFC] Move searching for the local variable namespace into own function
-rw-r--r-- | lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp | 51 | ||||
-rw-r--r-- | lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h | 11 |
2 files changed, 38 insertions, 24 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 31bf55ca4af..f2d5ded7d98 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1073,6 +1073,32 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context, } } +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; + } + } + } +} + void ClangExpressionDeclMap::FindExternalVisibleDecls( NameSearchContext &context, lldb::ModuleSP module_sp, CompilerDeclContext &namespace_decl, unsigned int current_id) { @@ -1113,30 +1139,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( return; } if (name == ConstString(g_lldb_local_vars_namespace_cstr)) { - 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(name.GetCString(), - 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; - } - } - } - + LookupLocalVarNamespace(sym_ctx, context); return; } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h index 93342dace77..b599e2802d1 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h @@ -410,6 +410,17 @@ private: /// for logging purposes. void LookUpLldbObjCClass(NameSearchContext &context, unsigned int current_id); + /// Handles looking up the synthetic namespace that contains our local + /// variables for the current frame. + /// + /// \param[in] sym_ctx + /// The current SymbolContext of this frame. + /// + /// \param[in] context + /// The NameSearchContext that can construct Decls for this name. + void LookupLocalVarNamespace(SymbolContext &sym_ctx, + NameSearchContext &context); + /// Given a target, find a variable that matches the given name and type. /// /// \param[in] target |