xiaobai created this revision. xiaobai added reviewers: JDevlieghere, compnerd, davide, clayborg. Herald added a project: LLDB.
InferiorCallPOSIX directly grabs a ClangASTContext from the Target it has and does no error checking. I don't think these functions have a reason to know about clang specifically. Additionally, using `GetScratchTypeSystemForLanguage` forces us to do error checking since it returns an Expected. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D67427 Files: lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp Index: lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp =================================================================== --- lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp +++ lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp @@ -12,7 +12,7 @@ #include "lldb/Core/ValueObject.h" #include "lldb/Expression/DiagnosticManager.h" #include "lldb/Host/Config.h" -#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/TypeSystem.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Platform.h" @@ -79,17 +79,23 @@ AddressRange mmap_range; if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, mmap_range)) { - ClangASTContext *clang_ast_context = - process->GetTarget().GetScratchClangASTContext(); - CompilerType clang_void_ptr_type = - clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); + auto type_system_or_err = + process->GetTarget().GetScratchTypeSystemForLanguage( + eLanguageTypeC); + if (!type_system_or_err) { + llvm::consumeError(type_system_or_err.takeError()); + return false; + } + CompilerType void_ptr_type = + type_system_or_err->GetBasicTypeFromAST(eBasicTypeVoid) + .GetPointerType(); const ArchSpec arch = process->GetTarget().GetArchitecture(); MmapArgList args = process->GetTarget().GetPlatform()->GetMmapArgumentList( arch, addr, length, prot_arg, flags, fd, offset); lldb::ThreadPlanSP call_plan_sp( new ThreadPlanCallFunction(*thread, mmap_range.GetBaseAddress(), - clang_void_ptr_type, args, options)); + void_ptr_type, args, options)); if (call_plan_sp) { DiagnosticManager diagnostics; @@ -200,12 +206,16 @@ options.SetTimeout(process->GetUtilityExpressionTimeout()); options.SetTrapExceptions(trap_exceptions); - ClangASTContext *clang_ast_context = - process->GetTarget().GetScratchClangASTContext(); - CompilerType clang_void_ptr_type = - clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); + auto type_system_or_err = + process->GetTarget().GetScratchTypeSystemForLanguage(eLanguageTypeC); + if (!type_system_or_err) { + llvm::consumeError(type_system_or_err.takeError()); + return false; + } + CompilerType void_ptr_type = + type_system_or_err->GetBasicTypeFromAST(eBasicTypeVoid).GetPointerType(); lldb::ThreadPlanSP call_plan_sp( - new ThreadPlanCallFunction(*thread, *address, clang_void_ptr_type, + new ThreadPlanCallFunction(*thread, *address, void_ptr_type, llvm::ArrayRef<addr_t>(), options)); if (call_plan_sp) { DiagnosticManager diagnostics;
Index: lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp =================================================================== --- lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp +++ lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp @@ -12,7 +12,7 @@ #include "lldb/Core/ValueObject.h" #include "lldb/Expression/DiagnosticManager.h" #include "lldb/Host/Config.h" -#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/TypeSystem.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Platform.h" @@ -79,17 +79,23 @@ AddressRange mmap_range; if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, mmap_range)) { - ClangASTContext *clang_ast_context = - process->GetTarget().GetScratchClangASTContext(); - CompilerType clang_void_ptr_type = - clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); + auto type_system_or_err = + process->GetTarget().GetScratchTypeSystemForLanguage( + eLanguageTypeC); + if (!type_system_or_err) { + llvm::consumeError(type_system_or_err.takeError()); + return false; + } + CompilerType void_ptr_type = + type_system_or_err->GetBasicTypeFromAST(eBasicTypeVoid) + .GetPointerType(); const ArchSpec arch = process->GetTarget().GetArchitecture(); MmapArgList args = process->GetTarget().GetPlatform()->GetMmapArgumentList( arch, addr, length, prot_arg, flags, fd, offset); lldb::ThreadPlanSP call_plan_sp( new ThreadPlanCallFunction(*thread, mmap_range.GetBaseAddress(), - clang_void_ptr_type, args, options)); + void_ptr_type, args, options)); if (call_plan_sp) { DiagnosticManager diagnostics; @@ -200,12 +206,16 @@ options.SetTimeout(process->GetUtilityExpressionTimeout()); options.SetTrapExceptions(trap_exceptions); - ClangASTContext *clang_ast_context = - process->GetTarget().GetScratchClangASTContext(); - CompilerType clang_void_ptr_type = - clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); + auto type_system_or_err = + process->GetTarget().GetScratchTypeSystemForLanguage(eLanguageTypeC); + if (!type_system_or_err) { + llvm::consumeError(type_system_or_err.takeError()); + return false; + } + CompilerType void_ptr_type = + type_system_or_err->GetBasicTypeFromAST(eBasicTypeVoid).GetPointerType(); lldb::ThreadPlanSP call_plan_sp( - new ThreadPlanCallFunction(*thread, *address, clang_void_ptr_type, + new ThreadPlanCallFunction(*thread, *address, void_ptr_type, llvm::ArrayRef<addr_t>(), options)); if (call_plan_sp) { DiagnosticManager diagnostics;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits