diff options
Diffstat (limited to 'include/lldb/Symbol/ClangASTContext.h')
-rw-r--r-- | include/lldb/Symbol/ClangASTContext.h | 132 |
1 files changed, 65 insertions, 67 deletions
diff --git a/include/lldb/Symbol/ClangASTContext.h b/include/lldb/Symbol/ClangASTContext.h index d0a834e01f3aa..c5d840973ae66 100644 --- a/include/lldb/Symbol/ClangASTContext.h +++ b/include/lldb/Symbol/ClangASTContext.h @@ -26,8 +26,8 @@ #include "llvm/ADT/APSInt.h" #include "llvm/ADT/SmallVector.h" -#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" #include "lldb/Core/ClangForward.h" +#include "lldb/Expression/ExpressionVariable.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/TypeSystem.h" #include "lldb/Utility/ConstString.h" @@ -52,7 +52,14 @@ public: } // Constructors and Destructors - ClangASTContext(const char *triple = nullptr); + explicit ClangASTContext(llvm::StringRef triple = ""); + explicit ClangASTContext(ArchSpec arch); + + /// Constructs a ClangASTContext that uses an existing ASTContext internally. + /// Useful when having an existing ASTContext created by Clang. + /// + /// \param existing_ctxt An existing ASTContext. + explicit ClangASTContext(clang::ASTContext &existing_ctxt); ~ClangASTContext() override; @@ -68,9 +75,8 @@ public: static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, Module *module, Target *target); - static void EnumerateSupportedLanguages( - std::set<lldb::LanguageType> &languages_for_types, - std::set<lldb::LanguageType> &languages_for_expressions); + static LanguageSet GetSupportedLanguagesForTypes(); + static LanguageSet GetSupportedLanguagesForExpressions(); static void Initialize(); @@ -80,8 +86,6 @@ public: clang::ASTContext *getASTContext(); - void setASTContext(clang::ASTContext *ast_ctx); - clang::Builtin::Context *getBuiltinContext(); clang::IdentifierTable *getIdentifierTable(); @@ -107,21 +111,11 @@ public: void setSema(clang::Sema *s); clang::Sema *getSema() { return m_sema; } - void Clear(); - const char *GetTargetTriple(); - void SetTargetTriple(const char *target_triple); - - void SetArchitecture(const ArchSpec &arch); - - bool HasExternalSource(); - void SetExternalSource( llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_up); - void RemoveExternalSource(); - bool GetCompleteDecl(clang::Decl *decl) { return ClangASTContext::GetCompleteDecl(getASTContext(), decl); } @@ -229,7 +223,8 @@ public: if (const RecordDeclType *record_decl = llvm::dyn_cast<RecordDeclType>(named_decl)) compiler_type.SetCompilerType( - ast, clang::QualType(record_decl->getTypeForDecl(), 0)); + this, clang::QualType(record_decl->getTypeForDecl(), 0) + .getAsOpaquePtr()); } } } @@ -249,7 +244,7 @@ public: &type_fields, bool packed = false); - static bool IsOperator(const char *name, + static bool IsOperator(llvm::StringRef name, clang::OverloadedOperatorKind &op_kind); // Structure, Unions, Classes @@ -395,7 +390,8 @@ public: clang::ParmVarDecl *CreateParameterDeclaration(clang::DeclContext *decl_ctx, const char *name, const CompilerType ¶m_type, - int storage); + int storage, + bool add_decl=false); void SetFunctionParameters(clang::FunctionDecl *function_decl, clang::ParmVarDecl **params, unsigned num_params); @@ -464,6 +460,8 @@ public: CompilerType DeclGetFunctionArgumentType(void *opaque_decl, size_t arg_idx) override; + CompilerType GetTypeForDecl(void *opaque_decl) override; + // CompilerDeclContext override functions std::vector<CompilerDecl> @@ -605,9 +603,6 @@ public: static bool GetCXXClassName(const CompilerType &type, std::string &class_name); - static bool GetObjCClassName(const CompilerType &type, - std::string &class_name); - // Type Completion bool GetCompleteType(lldb::opaque_compiler_type_t type) override; @@ -691,6 +686,8 @@ public: // Exploring the type + const llvm::fltSemantics &GetFloatTypeSemantics(size_t byte_size) override; + llvm::Optional<uint64_t> GetByteSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) { if (llvm::Optional<uint64_t> bit_size = GetBitSize(type, exe_scope)) @@ -707,7 +704,9 @@ public: lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override; - size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) override; + llvm::Optional<size_t> + GetTypeBitAlign(lldb::opaque_compiler_type_t type, + ExecutionContextScope *exe_scope) override; uint32_t GetNumChildren(lldb::opaque_compiler_type_t type, bool omit_empty_base_classes, @@ -855,7 +854,6 @@ public: static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern); - static bool GetHasExternalStorage(const CompilerType &type); // Tag Declarations static bool StartTagDeclarationDefinition(const CompilerType &type); @@ -878,12 +876,6 @@ public: static CompilerType CreateMemberPointerType(const CompilerType &type, const CompilerType &pointee_type); - // Converts "s" to a floating point value and place resulting floating point - // bytes in the "dst" buffer. - size_t ConvertStringToFloatValue(lldb::opaque_compiler_type_t type, - const char *s, uint8_t *dst, - size_t dst_size) override; - // Dumping types #ifndef NDEBUG /// Convenience LLVM-style dump method for use in the debugger only. @@ -894,6 +886,14 @@ public: void Dump(Stream &s); + /// Dump clang AST types from the symbol file. + /// + /// \param[in] s + /// A stream to send the dumped AST node(s) to + /// \param[in] symbol_name + /// The name of the symbol to dump, if it is empty dump all the symbols + void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name); + void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, @@ -977,43 +977,45 @@ protected: GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type); // Classes that inherit from ClangASTContext can see and modify these - // clang-format off - std::string m_target_triple; - std::unique_ptr<clang::ASTContext> m_ast_up; - std::unique_ptr<clang::LangOptions> m_language_options_up; - std::unique_ptr<clang::FileManager> m_file_manager_up; - std::unique_ptr<clang::SourceManager> m_source_manager_up; - std::unique_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_up; - std::unique_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_up; - std::shared_ptr<clang::TargetOptions> m_target_options_rp; - std::unique_ptr<clang::TargetInfo> m_target_info_up; - std::unique_ptr<clang::IdentifierTable> m_identifier_table_up; - std::unique_ptr<clang::SelectorTable> m_selector_table_up; - std::unique_ptr<clang::Builtin::Context> m_builtins_up; - std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_up; - std::unique_ptr<PDBASTParser> m_pdb_ast_parser_up; - std::unique_ptr<ClangASTSource> m_scratch_ast_source_up; - std::unique_ptr<clang::MangleContext> m_mangle_ctx_up; - CompleteTagDeclCallback m_callback_tag_decl; - CompleteObjCInterfaceDeclCallback m_callback_objc_decl; - void * m_callback_baton; - clang::ExternalASTMerger::OriginMap m_origins; - uint32_t m_pointer_byte_size; - bool m_ast_owned; - /// The sema associated that is currently used to build this ASTContext. - /// May be null if we are already done parsing this ASTContext or the - /// ASTContext wasn't created by parsing source code. - clang::Sema * m_sema = nullptr; - // clang-format on + std::string m_target_triple; + std::unique_ptr<clang::ASTContext> m_ast_up; + std::unique_ptr<clang::LangOptions> m_language_options_up; + std::unique_ptr<clang::FileManager> m_file_manager_up; + std::unique_ptr<clang::SourceManager> m_source_manager_up; + std::unique_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_up; + std::unique_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_up; + std::shared_ptr<clang::TargetOptions> m_target_options_rp; + std::unique_ptr<clang::TargetInfo> m_target_info_up; + std::unique_ptr<clang::IdentifierTable> m_identifier_table_up; + std::unique_ptr<clang::SelectorTable> m_selector_table_up; + std::unique_ptr<clang::Builtin::Context> m_builtins_up; + std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_up; + std::unique_ptr<PDBASTParser> m_pdb_ast_parser_up; + std::unique_ptr<ClangASTSource> m_scratch_ast_source_up; + std::unique_ptr<clang::MangleContext> m_mangle_ctx_up; + CompleteTagDeclCallback m_callback_tag_decl = nullptr; + CompleteObjCInterfaceDeclCallback m_callback_objc_decl = nullptr; + void *m_callback_baton = nullptr; + clang::ExternalASTMerger::OriginMap m_origins; + uint32_t m_pointer_byte_size = 0; + bool m_ast_owned = false; + /// The sema associated that is currently used to build this ASTContext. + /// May be null if we are already done parsing this ASTContext or the + /// ASTContext wasn't created by parsing source code. + clang::Sema *m_sema = nullptr; + private: // For ClangASTContext only ClangASTContext(const ClangASTContext &); const ClangASTContext &operator=(const ClangASTContext &); + /// Creates the internal ASTContext. + void CreateASTContext(); + void SetTargetTriple(llvm::StringRef target_triple); }; class ClangASTContextForExpressions : public ClangASTContext { public: - ClangASTContextForExpressions(Target &target); + ClangASTContextForExpressions(Target &target, ArchSpec arch); ~ClangASTContextForExpressions() override = default; @@ -1041,13 +1043,9 @@ public: } private: lldb::TargetWP m_target_wp; - lldb::ClangPersistentVariablesUP m_persistent_variables; ///< These are the - ///persistent - ///variables - ///associated with - ///this process for - ///the expression - ///parser. + std::unique_ptr<PersistentExpressionState> + m_persistent_variables; // These are the persistent variables associated + // with this process for the expression parser }; } // namespace lldb_private |