xiaobai created this revision. xiaobai added a reviewer: LLDB. Herald added a project: LLDB.
lldb-forward.h is convenient in many ways, but having clang-based class forward declarations in there makes it easy to proliferate uses of clang outside of plugins. Removing them makes you much more conscious of when you're using something from clang and marks where we're using things from clang in non-plugins. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D73935 Files: lldb/include/lldb/Target/Target.h lldb/include/lldb/lldb-forward.h lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
Index: lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp =================================================================== --- lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp +++ lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp @@ -21,7 +21,7 @@ namespace { struct FakeClangExpressionDeclMap : public ClangExpressionDeclMap { - FakeClangExpressionDeclMap(const ClangASTImporterSP &importer) + FakeClangExpressionDeclMap(const std::shared_ptr<ClangASTImporter> &importer) : ClangExpressionDeclMap(false, nullptr, lldb::TargetSP(), importer, nullptr) { m_scratch_context = clang_utils::createAST(); @@ -58,7 +58,7 @@ SubsystemRAII<FileSystem, HostInfo> subsystems; /// The ClangASTImporter used during the test. - ClangASTImporterSP importer; + std::shared_ptr<ClangASTImporter> importer; /// The ExpressionDeclMap for the current test case. std::unique_ptr<FakeClangExpressionDeclMap> decl_map; Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h =================================================================== --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -41,6 +41,8 @@ namespace lldb_private { +class ClangASTMetadata; +class ClangASTSource; class Declaration; class TypeSystemClang : public TypeSystem { Index: lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h =================================================================== --- lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h +++ lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h @@ -28,6 +28,7 @@ namespace lldb_private { +class TypeSystemClang; class UtilityFunction; class ObjCLanguageRuntime : public LanguageRuntime { Index: lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp =================================================================== --- lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp +++ lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp @@ -56,7 +56,7 @@ return; } - lldb::ClangASTImporterSP clang_ast_importer; + std::shared_ptr<ClangASTImporter> clang_ast_importer; auto *state = target_sp->GetPersistentExpressionStateForLanguage( lldb::eLanguageTypeC_plus_plus); if (state) { Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp @@ -160,7 +160,7 @@ void ClangUtilityFunction::ClangUtilityFunctionHelper::ResetDeclMap( ExecutionContext &exe_ctx, bool keep_result_in_memory) { - lldb::ClangASTImporterSP ast_importer; + std::shared_ptr<ClangASTImporter> ast_importer; auto *state = exe_ctx.GetTargetSP()->GetPersistentExpressionStateForLanguage( lldb::eLanguageTypeC); if (state) { Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -896,7 +896,7 @@ Materializer::PersistentVariableDelegate &delegate, bool keep_result_in_memory, ValueObject *ctx_obj) { - lldb::ClangASTImporterSP ast_importer; + std::shared_ptr<ClangASTImporter> ast_importer; auto *state = exe_ctx.GetTargetSP()->GetPersistentExpressionStateForLanguage( lldb::eLanguageTypeC); if (state) { Index: lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h +++ lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h @@ -18,6 +18,9 @@ namespace lldb_private { +class ClangASTImporter; +class TypeSystemClang; + /// \class ClangPersistentVariables ClangPersistentVariables.h /// "lldb/Expression/ClangPersistentVariables.h" Manages persistent values /// that need to be preserved between expression invocations. @@ -36,7 +39,7 @@ return pv->getKind() == PersistentExpressionState::eKindClang; } - lldb::ClangASTImporterSP GetClangASTImporter(); + std::shared_ptr<ClangASTImporter> GetClangASTImporter(); lldb::ExpressionVariableSP CreatePersistentVariable(const lldb::ValueObjectSP &valobj_sp) override; @@ -98,7 +101,7 @@ m_hand_loaded_clang_modules; ///< These are Clang modules we hand-loaded; ///these are the highest- ///< priority source for macros. - lldb::ClangASTImporterSP m_ast_importer_sp; + std::shared_ptr<ClangASTImporter> m_ast_importer_sp; }; } // namespace lldb_private Index: lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp @@ -101,7 +101,8 @@ return m_persistent_decls.lookup(name.GetCString()).m_decl; } -lldb::ClangASTImporterSP ClangPersistentVariables::GetClangASTImporter() { +std::shared_ptr<ClangASTImporter> +ClangPersistentVariables::GetClangASTImporter() { if (!m_ast_importer_sp) { m_ast_importer_sp = std::make_shared<ClangASTImporter>(); } Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h @@ -31,6 +31,7 @@ namespace lldb_private { class IRExecutionUnit; +class TypeSystemClang; /// \class ClangExpressionParser ClangExpressionParser.h /// "lldb/Expression/ClangExpressionParser.h" Encapsulates an instance of Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h @@ -23,6 +23,7 @@ namespace lldb_private { +class ClangExpressionDeclMap; class RecordingMemoryManager; // ClangExpressionHelper Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h @@ -28,6 +28,8 @@ namespace lldb_private { +class ClangPersistentVariables; + /// \class ClangExpressionDeclMap ClangExpressionDeclMap.h /// "lldb/Expression/ClangExpressionDeclMap.h" Manages named entities that are /// defined in LLDB's debug information. @@ -78,8 +80,8 @@ ClangExpressionDeclMap( bool keep_result_in_memory, Materializer::PersistentVariableDelegate *result_delegate, - const lldb::TargetSP &target, const lldb::ClangASTImporterSP &importer, - ValueObject *ctx_obj); + const lldb::TargetSP &target, + const std::shared_ptr<ClangASTImporter> &importer, ValueObject *ctx_obj); /// Destructor ~ClangExpressionDeclMap() override; Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -65,8 +65,8 @@ ClangExpressionDeclMap::ClangExpressionDeclMap( bool keep_result_in_memory, Materializer::PersistentVariableDelegate *result_delegate, - const lldb::TargetSP &target, const lldb::ClangASTImporterSP &importer, - ValueObject *ctx_obj) + const lldb::TargetSP &target, + const std::shared_ptr<ClangASTImporter> &importer, ValueObject *ctx_obj) : ClangASTSource(target, importer), m_found_entities(), m_struct_members(), m_keep_result_in_memory(keep_result_in_memory), m_result_delegate(result_delegate), m_ctx_obj(ctx_obj), m_parser_vars(), Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h +++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h @@ -42,7 +42,7 @@ /// \param[in] importer /// The ClangASTImporter to use. ClangASTSource(const lldb::TargetSP &target, - const lldb::ClangASTImporterSP &importer); + const std::shared_ptr<ClangASTImporter> &importer); /// Destructor ~ClangASTSource() override; @@ -379,7 +379,7 @@ /// The file manager paired with the AST context. clang::FileManager *m_file_manager; /// The target's AST importer. - lldb::ClangASTImporterSP m_ast_importer_sp; + std::shared_ptr<ClangASTImporter> m_ast_importer_sp; std::set<const clang::Decl *> m_active_lexical_decls; std::set<const char *> m_active_lookups; }; Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -49,8 +49,9 @@ }; } -ClangASTSource::ClangASTSource(const lldb::TargetSP &target, - const lldb::ClangASTImporterSP &importer) +ClangASTSource::ClangASTSource( + const lldb::TargetSP &target, + const std::shared_ptr<ClangASTImporter> &importer) : m_import_in_progress(false), m_lookups_enabled(false), m_target(target), m_ast_context(nullptr), m_ast_importer_sp(importer), m_active_lexical_decls(), m_active_lookups() { Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h +++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h @@ -31,6 +31,9 @@ namespace lldb_private { +class ClangASTMetadata; +class TypeSystemClang; + class ClangASTImporter { public: struct LayoutInfo { Index: lldb/include/lldb/lldb-forward.h =================================================================== --- lldb/include/lldb/lldb-forward.h +++ lldb/include/lldb/lldb-forward.h @@ -45,15 +45,6 @@ class Broadcaster; class BroadcasterManager; class CallFrameInfo; -class TypeSystemClang; -class ClangASTImporter; -class ClangASTMetadata; -class ClangASTSource; -class ClangExpressionDeclMap; -class ClangExpressionParser; -class ClangExpressionVariable; -class ClangModulesDeclVendor; -class ClangPersistentVariables; class CommandInterpreter; class CommandInterpreterRunOptions; class CommandObject; @@ -304,12 +295,6 @@ typedef std::shared_ptr<lldb_private::Broadcaster> BroadcasterSP; typedef std::shared_ptr<lldb_private::BroadcasterManager> BroadcasterManagerSP; typedef std::weak_ptr<lldb_private::BroadcasterManager> BroadcasterManagerWP; -typedef std::unique_ptr<lldb_private::TypeSystemClang> TypeSystemClangUP; -typedef std::shared_ptr<lldb_private::ClangASTImporter> ClangASTImporterSP; -typedef std::unique_ptr<lldb_private::ClangModulesDeclVendor> - ClangModulesDeclVendorUP; -typedef std::unique_ptr<lldb_private::ClangPersistentVariables> - ClangPersistentVariablesUP; typedef std::shared_ptr<lldb_private::UserExpression> UserExpressionSP; typedef std::shared_ptr<lldb_private::CommandObject> CommandObjectSP; typedef std::shared_ptr<lldb_private::Communication> CommunicationSP; Index: lldb/include/lldb/Target/Target.h =================================================================== --- lldb/include/lldb/Target/Target.h +++ lldb/include/lldb/Target/Target.h @@ -36,6 +36,8 @@ namespace lldb_private { +class ClangModulesDeclVendor; + OptionEnumValues GetDynamicValueTypes(); enum InlineStrategy { @@ -1302,7 +1304,7 @@ typedef std::map<lldb::LanguageType, lldb::REPLSP> REPLMap; REPLMap m_repl_map; - lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_up; + std::unique_ptr<ClangModulesDeclVendor> m_clang_modules_decl_vendor_up; lldb::SourceManagerUP m_source_manager_up;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits