diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-12-09 13:28:42 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2023-12-09 13:28:42 +0000 |
| commit | b1c73532ee8997fe5dfbeb7d223027bdf99758a0 (patch) | |
| tree | 7d6e51c294ab6719475d660217aa0c0ad0526292 /lldb/source/Plugins/ExpressionParser | |
| parent | 7fa27ce4a07f19b07799a767fc29416f3b625afb (diff) | |
Diffstat (limited to 'lldb/source/Plugins/ExpressionParser')
10 files changed, 28 insertions, 119 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 2826b102625f..5d109feb3d39 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -902,7 +902,6 @@ void ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo( // We want that 'to' is actually complete after this function so let's // tell the ASTImporter that 'to' was imported from 'from'. MapImported(from, to); - ASTImporter::Imported(from, to); Log *log = GetLog(LLDBLog::Expressions); @@ -1028,7 +1027,7 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from, // Some decls shouldn't be tracked here because they were not created by // copying 'from' to 'to'. Just exit early for those. if (m_decls_to_ignore.count(to)) - return clang::ASTImporter::Imported(from, to); + return; // Transfer module ownership information. auto *from_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>( @@ -1081,12 +1080,6 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from, if (!to_context_md->hasOrigin(to) || user_id != LLDB_INVALID_UID) to_context_md->setOrigin(to, origin); - ImporterDelegateSP direct_completer = - m_main.GetDelegate(&to->getASTContext(), origin.ctx); - - if (direct_completer.get() != this) - direct_completer->ASTImporter::Imported(origin.decl, to); - LLDB_LOG(log, " [ClangASTImporter] Propagated origin " "(Decl*){0}/(ASTContext*){1} from (ASTContext*){2} to " diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h index 9430ab5b0464..d8d519693f10 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h @@ -53,7 +53,7 @@ class ClangPersistentVariables; /// struct so that it can be passed to the JITted version of the IR. /// /// Fourth and finally, it "dematerializes" the struct after the JITted code -/// has has executed, placing the new values back where it found the old ones. +/// has executed, placing the new values back where it found the old ones. class ClangExpressionDeclMap : public ClangASTSource { public: /// Constructor diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index f3d6ea26b30d..f6856b1a2558 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -71,7 +71,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/Module.h" -#include "lldb/Core/StreamFile.h" #include "lldb/Expression/IRExecutionUnit.h" #include "lldb/Expression/IRInterpreter.h" #include "lldb/Host/File.h" @@ -576,6 +575,7 @@ ClangExpressionParser::ClangExpressionParser( lang_opts.GNUMode = true; lang_opts.GNUKeywords = true; lang_opts.CPlusPlus11 = true; + lang_opts.BuiltinHeadersInSystemModules = true; // The Darwin libc expects this macro to be set. lang_opts.GNUCVersion = 40201; @@ -1078,13 +1078,14 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager, // While parsing the Sema will call this consumer with the provided // completion suggestions. if (completion_consumer) { - auto main_file = source_mgr.getFileEntryForID(source_mgr.getMainFileID()); + auto main_file = + source_mgr.getFileEntryRefForID(source_mgr.getMainFileID()); auto &PP = m_compiler->getPreprocessor(); // Lines and columns start at 1 in Clang, but code completion positions are // indexed from 0, so we need to add 1 to the line and column here. ++completion_line; ++completion_column; - PP.SetCodeCompletionPoint(main_file, completion_line, completion_column); + PP.SetCodeCompletionPoint(*main_file, completion_line, completion_column); } ASTConsumer *ast_transformer = diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp index 74c1212791be..68bdd96e8adb 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -27,7 +27,6 @@ #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" -#include "lldb/Core/StreamFile.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Expression/ExpressionSourceCode.h" #include "lldb/Expression/IRExecutionUnit.h" @@ -873,7 +872,7 @@ bool ClangUserExpression::Complete(ExecutionContext &exe_ctx, } lldb::addr_t ClangUserExpression::GetCppObjectPointer( - lldb::StackFrameSP frame_sp, ConstString &object_name, Status &err) { + lldb::StackFrameSP frame_sp, llvm::StringRef object_name, Status &err) { auto valobj_sp = GetObjectPointerValueObject(std::move(frame_sp), object_name, err); @@ -890,9 +889,9 @@ lldb::addr_t ClangUserExpression::GetCppObjectPointer( lldb::addr_t ret = valobj_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); if (ret == LLDB_INVALID_ADDRESS) { - err.SetErrorStringWithFormat( - "Couldn't load '%s' because its value couldn't be evaluated", - object_name.AsCString()); + err.SetErrorStringWithFormatv( + "Couldn't load '{0}' because its value couldn't be evaluated", + object_name); return LLDB_INVALID_ADDRESS; } @@ -911,19 +910,18 @@ bool ClangUserExpression::AddArguments(ExecutionContext &exe_ctx, if (!frame_sp) return true; - ConstString object_name; - - if (m_in_cplusplus_method) { - object_name.SetCString("this"); - } else if (m_in_objectivec_method) { - object_name.SetCString("self"); - } else { + if (!m_in_cplusplus_method && !m_in_objectivec_method) { diagnostic_manager.PutString( eDiagnosticSeverityError, "need object pointer but don't know the language"); return false; } + static constexpr llvm::StringLiteral g_cplusplus_object_name("this"); + static constexpr llvm::StringLiteral g_objc_object_name("self"); + llvm::StringRef object_name = + m_in_cplusplus_method ? g_cplusplus_object_name : g_objc_object_name; + Status object_ptr_error; if (m_ctx_obj) { @@ -943,14 +941,14 @@ bool ClangUserExpression::AddArguments(ExecutionContext &exe_ctx, } if (!object_ptr_error.Success()) { - exe_ctx.GetTargetRef().GetDebugger().GetAsyncOutputStream()->Printf( - "warning: `%s' is not accessible (substituting 0). %s\n", - object_name.AsCString(), object_ptr_error.AsCString()); + exe_ctx.GetTargetRef().GetDebugger().GetAsyncOutputStream()->Format( + "warning: `{0}' is not accessible (substituting 0). {1}\n", + object_name, object_ptr_error.AsCString()); object_ptr = 0; } if (m_in_objectivec_method) { - ConstString cmd_name("_cmd"); + static constexpr llvm::StringLiteral cmd_name("_cmd"); cmd_ptr = GetObjectPointer(frame_sp, cmd_name, object_ptr_error); diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h index 0fbeff7f6143..7a8c095f6118 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h @@ -204,7 +204,7 @@ private: bool for_completion); lldb::addr_t GetCppObjectPointer(lldb::StackFrameSP frame, - ConstString &object_name, Status &err); + llvm::StringRef object_name, Status &err); /// Defines how the current expression should be wrapped. ClangExpressionSourceCode::WrapKind GetWrapKind() const; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp index 371605d427ad..56d6cf19ee4c 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp @@ -17,7 +17,6 @@ #include "lldb/Core/Module.h" -#include "lldb/Core/StreamFile.h" #include "lldb/Expression/IRExecutionUnit.h" #include "lldb/Host/Host.h" #include "lldb/Target/ExecutionContext.h" diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp index cd7d1ff6148b..bc0f5993aad0 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp @@ -273,7 +273,7 @@ protected: PointerType *GetI8PtrTy() { if (!m_i8ptr_ty) - m_i8ptr_ty = llvm::Type::getInt8PtrTy(m_module.getContext()); + m_i8ptr_ty = llvm::PointerType::getUnqual(m_module.getContext()); return m_i8ptr_ty; } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp index 1b7e86bb187f..33e5dd0015ae 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -404,7 +404,7 @@ bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str, Type *ns_str_ty = ns_str->getType(); - Type *i8_ptr_ty = Type::getInt8PtrTy(m_module->getContext()); + Type *i8_ptr_ty = PointerType::getUnqual(m_module->getContext()); Type *i32_ty = Type::getInt32Ty(m_module->getContext()); Type *i8_ty = Type::getInt8Ty(m_module->getContext()); @@ -801,11 +801,11 @@ bool IRForTarget::RewriteObjCSelector(Instruction *selector_load) { // is uint8_t* // Type *sel_type = StructType::get(m_module->getContext()); // Type *sel_ptr_type = PointerType::getUnqual(sel_type); - Type *sel_ptr_type = Type::getInt8PtrTy(m_module->getContext()); + Type *sel_ptr_type = PointerType::getUnqual(m_module->getContext()); Type *type_array[1]; - type_array[0] = llvm::Type::getInt8PtrTy(m_module->getContext()); + type_array[0] = llvm::PointerType::getUnqual(m_module->getContext()); ArrayRef<Type *> srN_arg_types(type_array, 1); @@ -1641,14 +1641,6 @@ bool IRForTarget::runOnModule(Module &llvm_module) { } } - llvm::Type *int8_ty = Type::getInt8Ty(m_module->getContext()); - - m_reloc_placeholder = new llvm::GlobalVariable( - (*m_module), int8_ty, false /* IsConstant */, - GlobalVariable::InternalLinkage, Constant::getNullValue(int8_ty), - "reloc_placeholder", nullptr /* InsertBefore */, - GlobalVariable::NotThreadLocal /* ThreadLocal */, 0 /* AddressSpace */); - //////////////////////////////////////////////////////////// // Replace $__lldb_expr_result with a persistent variable // diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h index eb93952e2b3c..a924187ba04c 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h @@ -111,43 +111,6 @@ private: /// True on success; false otherwise. bool FixFunctionLinkage(llvm::Function &llvm_function); - /// A module-level pass to replace all function pointers with their - /// integer equivalents. - - /// The top-level pass implementation - /// - /// \param[in] llvm_function - /// The function currently being processed. - /// - /// \return - /// True on success; false otherwise. - bool HasSideEffects(llvm::Function &llvm_function); - - /// A function-level pass to check whether the function has side - /// effects. - - /// Get the address of a function, and a location to put the complete Value - /// of the function if one is available. - /// - /// \param[in] function - /// The function to find the location of. - /// - /// \param[out] ptr - /// The location of the function in the target. - /// - /// \param[out] name - /// The resolved name of the function (matters for intrinsics). - /// - /// \param[out] value_ptr - /// A variable to put the function's completed Value* in, or NULL - /// if the Value* shouldn't be stored anywhere. - /// - /// \return - /// The pointer. - LookupResult GetFunctionAddress(llvm::Function *function, uint64_t &ptr, - lldb_private::ConstString &name, - llvm::Constant **&value_ptr); - /// A function-level pass to take the generated global value /// $__lldb_expr_result and make it into a persistent variable. Also see /// ASTResultSynthesizer. @@ -170,30 +133,6 @@ public: private: clang::NamedDecl *DeclForGlobal(llvm::GlobalValue *global); - /// Set the constant result variable m_const_result to the provided - /// constant, assuming it can be evaluated. The result variable will be - /// reset to NULL later if the expression has side effects. - /// - /// \param[in] initializer - /// The constant initializer for the variable. - /// - /// \param[in] name - /// The name of the result variable. - /// - /// \param[in] type - /// The Clang type of the result variable. - void MaybeSetConstantResult(llvm::Constant *initializer, - lldb_private::ConstString name, - lldb_private::TypeFromParser type); - - /// If the IR represents a cast of a variable, set m_const_result to the - /// result of the cast. The result variable will be reset to - /// NULL latger if the expression has side effects. - /// - /// \param[in] type - /// The Clang type of the result variable. - void MaybeSetCastResult(lldb_private::TypeFromParser type); - /// The top-level pass implementation /// /// \param[in] llvm_function @@ -409,15 +348,9 @@ private: lldb_private::Stream &m_error_stream; /// The execution unit containing the IR being created. lldb_private::IRExecutionUnit &m_execution_unit; - /// If non-NULL, the store instruction that writes to the result variable. If - /// m_has_side_effects is true, this is NULL. - llvm::StoreInst *m_result_store = nullptr; /// True if the function's result in the AST is a pointer (see comments in /// ASTResultSynthesizer::SynthesizeBodyResult) bool m_result_is_pointer = false; - /// A placeholder that will be replaced by a pointer to the final location of - /// the static allocation. - llvm::GlobalVariable *m_reloc_placeholder = nullptr; class FunctionValueCache { public: @@ -454,13 +387,6 @@ private: FunctionValueCache &value_maker, FunctionValueCache &entry_instruction_finder, lldb_private::Stream &error_stream); - - /// Commit the allocation in m_data_allocator and use its final location to - /// replace m_reloc_placeholder. - /// - /// \return - /// True on success; false otherwise - bool CompleteDataAllocation(); }; #endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_IRFORTARGET_H diff --git a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp index a67cc8e10c17..da59855a9f16 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp @@ -62,9 +62,9 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type, clang::DeclContext *context = const_cast<DeclContext *>(m_decl_context); if (extern_c) { - context = LinkageSpecDecl::Create( - ast, context, SourceLocation(), SourceLocation(), - clang::LinkageSpecDecl::LanguageIDs::lang_c, false); + context = LinkageSpecDecl::Create(ast, context, SourceLocation(), + SourceLocation(), + clang::LinkageSpecLanguageIDs::C, false); // FIXME: The LinkageSpecDecl here should be added to m_decl_context. } |
