[Lldb-commits] [lldb] 7c9ebdd - [lldb] Remove clang classes from lldb-forward.h

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 4 14:24:13 PST 2020


Author: Alex Langford
Date: 2020-02-04T14:23:58-08:00
New Revision: 7c9ebdd3d6ae405dc6702e544453a51862daf948

URL: https://github.com/llvm/llvm-project/commit/7c9ebdd3d6ae405dc6702e544453a51862daf948
DIFF: https://github.com/llvm/llvm-project/commit/7c9ebdd3d6ae405dc6702e544453a51862daf948.diff

LOG: [lldb] Remove clang classes from lldb-forward.h

Summary:
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.

Differential Revision: https://reviews.llvm.org/D73935

Added: 
    

Modified: 
    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

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h
index 414a66970590..5ea63027d609 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -36,6 +36,8 @@
 
 namespace lldb_private {
 
+class ClangModulesDeclVendor;
+
 OptionEnumValues GetDynamicValueTypes();
 
 enum InlineStrategy {
@@ -1302,7 +1304,7 @@ class Target : public std::enable_shared_from_this<Target>,
   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;
 

diff  --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index f5e345d22419..0ca5d031b3e5 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -45,15 +45,6 @@ class BroadcastEventSpec;
 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::BreakpointResolver> BreakpointResolverSP;
 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;

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
index b05a89c2a685..6d0d774c9f9d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
@@ -31,6 +31,9 @@
 
 namespace lldb_private {
 
+class ClangASTMetadata;
+class TypeSystemClang;
+
 class ClangASTImporter {
 public:
   struct LayoutInfo {

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index d1560b2987c3..cce3ce67a622 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -49,8 +49,9 @@ class ScopedLexicalDeclEraser {
 };
 }
 
-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() {

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
index aeb06b3652f0..fcdefd9b0a52 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
@@ -42,7 +42,7 @@ class ClangASTSource : public clang::ExternalASTSource,
   /// \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 @@ class ClangASTSource : public clang::ExternalASTSource,
   /// 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;
 };

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 58094e025268..6254080ed5c7 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -65,8 +65,8 @@ const char *g_lldb_local_vars_namespace_cstr = "$__lldb_local_vars";
 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(),

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
index 8609b9661c7f..790ac0ccfc35 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
+++ b/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 @@ class ClangExpressionDeclMap : public ClangASTSource {
   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;

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
index 66bb65263d03..a31a1ea81678 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
@@ -23,6 +23,7 @@ class ASTConsumer;
 
 namespace lldb_private {
 
+class ClangExpressionDeclMap;
 class RecordingMemoryManager;
 
 // ClangExpressionHelper

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
index 8a8709dd8e40..2767e2c8f4f8 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -31,6 +31,7 @@ class CompilerInstance;
 namespace lldb_private {
 
 class IRExecutionUnit;
+class TypeSystemClang;
 
 /// \class ClangExpressionParser ClangExpressionParser.h
 /// "lldb/Expression/ClangExpressionParser.h" Encapsulates an instance of

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
index da26c6a3d9a6..3cbedf80755a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
@@ -101,7 +101,8 @@ ClangPersistentVariables::GetPersistentDecl(ConstString name) {
   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>();
   }

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
index b72e43a5157e..86fc4307e330 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
+++ b/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 @@ class ClangPersistentVariables : public PersistentExpressionState {
     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 @@ class ClangPersistentVariables : public PersistentExpressionState {
       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

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
index 492ab15d58f2..1bdc0d158593 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -896,7 +896,7 @@ void ClangUserExpression::ClangUserExpressionHelper::ResetDeclMap(
     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) {

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
index 5e97e951fe3b..ae519658e501 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -160,7 +160,7 @@ bool ClangUtilityFunction::Install(DiagnosticManager &diagnostic_manager,
 
 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) {

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
index e5f19a66f119..42f6bd9ffb7b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -56,7 +56,7 @@ class BlockPointerSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
       return;
     }
 
-    lldb::ClangASTImporterSP clang_ast_importer;
+    std::shared_ptr<ClangASTImporter> clang_ast_importer;
     auto *state = target_sp->GetPersistentExpressionStateForLanguage(
         lldb::eLanguageTypeC_plus_plus);
     if (state) {

diff  --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
index 71a8a41665ce..cbc1f4bffb74 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
@@ -28,6 +28,7 @@ class CommandObjectObjC_ClassTable_Dump;
 
 namespace lldb_private {
 
+class TypeSystemClang;
 class UtilityFunction;
 
 class ObjCLanguageRuntime : public LanguageRuntime {

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 8d6ef30b58d2..db03595e970b 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -41,6 +41,8 @@ class PDBASTParser;
 
 namespace lldb_private {
 
+class ClangASTMetadata;
+class ClangASTSource;
 class Declaration;
 
 class TypeSystemClang : public TypeSystem {

diff  --git a/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp b/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
index 7d1e0ed3b365..d1bfc3210bb4 100644
--- a/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
+++ b/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
@@ -21,7 +21,7 @@ using namespace lldb;
 
 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 @@ struct ClangExpressionDeclMapTest : public testing::Test {
   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;
 


        


More information about the lldb-commits mailing list