@@ -771,19 +771,64 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
771
771
ClangASTSource::FindExternalVisibleDecls (context);
772
772
}
773
773
774
+ void ClangExpressionDeclMap::MaybeRegisterFunctionBody (
775
+ FunctionDecl *copied_function_decl) {
776
+ if (copied_function_decl->getBody () && m_parser_vars->m_code_gen ) {
777
+ clang::DeclGroupRef decl_group_ref (copied_function_decl);
778
+ m_parser_vars->m_code_gen ->HandleTopLevelDecl (decl_group_ref);
779
+ }
780
+ }
781
+
782
+ void ClangExpressionDeclMap::SearchPersistenDecls (NameSearchContext &context,
783
+ const ConstString name,
784
+ unsigned int current_id) {
785
+ Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
786
+ Target *target = m_parser_vars->m_exe_ctx .GetTargetPtr ();
787
+ if (!target)
788
+ return ;
789
+
790
+ ClangASTContext *scratch_clang_ast_context =
791
+ target->GetScratchClangASTContext ();
792
+
793
+ if (!scratch_clang_ast_context)
794
+ return ;
795
+
796
+ ASTContext *scratch_ast_context = scratch_clang_ast_context->getASTContext ();
797
+
798
+ if (!scratch_ast_context)
799
+ return ;
800
+
801
+ NamedDecl *persistent_decl =
802
+ m_parser_vars->m_persistent_vars ->GetPersistentDecl (name);
803
+
804
+ if (!persistent_decl)
805
+ return ;
806
+
807
+ Decl *parser_persistent_decl = CopyDecl (persistent_decl);
808
+
809
+ if (!parser_persistent_decl)
810
+ return ;
811
+
812
+ NamedDecl *parser_named_decl = dyn_cast<NamedDecl>(parser_persistent_decl);
813
+
814
+ if (!parser_named_decl)
815
+ return ;
816
+
817
+ if (clang::FunctionDecl *parser_function_decl =
818
+ llvm::dyn_cast<clang::FunctionDecl>(parser_named_decl)) {
819
+ MaybeRegisterFunctionBody (parser_function_decl);
820
+ }
821
+
822
+ LLDB_LOGF (log, " CEDM::FEVD[%u] Found persistent decl %s" , current_id,
823
+ name.GetCString ());
824
+
825
+ context.AddNamedDecl (parser_named_decl);
826
+ }
774
827
void ClangExpressionDeclMap::FindExternalVisibleDecls (
775
828
NameSearchContext &context, lldb::ModuleSP module_sp,
776
829
CompilerDeclContext &namespace_decl, unsigned int current_id) {
777
830
assert (m_ast_context);
778
831
779
- std::function<void (clang::FunctionDecl *)> MaybeRegisterFunctionBody =
780
- [this ](clang::FunctionDecl *copied_function_decl) {
781
- if (copied_function_decl->getBody () && m_parser_vars->m_code_gen ) {
782
- DeclGroupRef decl_group_ref (copied_function_decl);
783
- m_parser_vars->m_code_gen ->HandleTopLevelDecl (decl_group_ref);
784
- }
785
- };
786
-
787
832
Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
788
833
789
834
SymbolContextList sc_list;
@@ -802,51 +847,8 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
802
847
lldb::eSymbolContextBlock);
803
848
804
849
// Try the persistent decls, which take precedence over all else.
805
- if (!namespace_decl) {
806
- do {
807
- if (!target)
808
- break ;
809
-
810
- ClangASTContext *scratch_clang_ast_context =
811
- target->GetScratchClangASTContext ();
812
-
813
- if (!scratch_clang_ast_context)
814
- break ;
815
-
816
- ASTContext *scratch_ast_context =
817
- scratch_clang_ast_context->getASTContext ();
818
-
819
- if (!scratch_ast_context)
820
- break ;
821
-
822
- NamedDecl *persistent_decl =
823
- m_parser_vars->m_persistent_vars ->GetPersistentDecl (name);
824
-
825
- if (!persistent_decl)
826
- break ;
827
-
828
- Decl *parser_persistent_decl = CopyDecl (persistent_decl);
829
-
830
- if (!parser_persistent_decl)
831
- break ;
832
-
833
- NamedDecl *parser_named_decl =
834
- dyn_cast<NamedDecl>(parser_persistent_decl);
835
-
836
- if (!parser_named_decl)
837
- break ;
838
-
839
- if (clang::FunctionDecl *parser_function_decl =
840
- llvm::dyn_cast<clang::FunctionDecl>(parser_named_decl)) {
841
- MaybeRegisterFunctionBody (parser_function_decl);
842
- }
843
-
844
- LLDB_LOGF (log, " CEDM::FEVD[%u] Found persistent decl %s" , current_id,
845
- name.GetCString ());
846
-
847
- context.AddNamedDecl (parser_named_decl);
848
- } while (false );
849
- }
850
+ if (!namespace_decl)
851
+ SearchPersistenDecls (context, name, current_id);
850
852
851
853
if (name.GetCString ()[0 ] == ' $' && !namespace_decl) {
852
854
static ConstString g_lldb_class_name (" $__lldb_class" );
0 commit comments