[Lldb-commits] [lldb] r357984 - Remove unneeded #ifdef SWIGs

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 9 02:03:44 PDT 2019


Author: labath
Date: Tue Apr  9 02:03:43 2019
New Revision: 357984

URL: http://llvm.org/viewvc/llvm-project?rev=357984&view=rev
Log:
Remove unneeded #ifdef SWIGs

Summary:
Some of these were present in files which should never be read by swig
(and we also had one in the interface file, which is only read by swig).
They are probably leftovers from the time when we were running swig over
lldb headers directly.

While writing this patch, I noticed that some of the #ifdefs were
guarding public functions that were operating on lldb_private data
types. While it wasn't strictly necessary for this patch, I made these
private, as nobody should really be accessing them. This can potentially
break existing code if it happened to use these methods, though it will
only break at build time -- if someone builds against an old header, he
should still be able to link to a new lldb library, since the functions
are still there.

We could keep these public for backward compatbility, but I would argue
that if anyone was actually using these functions for anything, his code
is already broken.

Reviewers: JDevlieghere, clayborg, jingham

Subscribers: lldb-commits

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

Modified:
    lldb/trunk/include/lldb/API/SBDefines.h
    lldb/trunk/include/lldb/API/SBThread.h
    lldb/trunk/include/lldb/API/SBThreadPlan.h
    lldb/trunk/include/lldb/Core/Address.h
    lldb/trunk/include/lldb/Core/SourceManager.h
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/scripts/interface/SBFrame.i
    lldb/trunk/source/API/SBThread.cpp
    lldb/trunk/source/API/SBThreadPlan.cpp

Modified: lldb/trunk/include/lldb/API/SBDefines.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDefines.h?rev=357984&r1=357983&r2=357984&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDefines.h (original)
+++ lldb/trunk/include/lldb/API/SBDefines.h Tue Apr  9 02:03:43 2019
@@ -16,10 +16,6 @@
 #include "lldb/lldb-types.h"
 #include "lldb/lldb-versioning.h"
 
-#ifdef SWIG
-#define LLDB_API
-#endif
-
 // Forward Declarations
 namespace lldb {
 

Modified: lldb/trunk/include/lldb/API/SBThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=357984&r1=357983&r2=357984&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBThread.h (original)
+++ lldb/trunk/include/lldb/API/SBThread.h Tue Apr  9 02:03:43 2019
@@ -205,14 +205,7 @@ public:
 
   bool SafeToCallFunctions();
 
-#ifndef SWIG
-  lldb_private::Thread *operator->();
-
-  lldb_private::Thread *get();
-
-#endif
-
-protected:
+private:
   friend class SBBreakpoint;
   friend class SBBreakpointLocation;
   friend class SBBreakpointCallbackBaton;
@@ -223,16 +216,18 @@ protected:
   friend class SBValue;
   friend class lldb_private::QueueImpl;
   friend class SBQueueItem;
+  friend class SBThreadPlan;
 
   void SetThread(const lldb::ThreadSP &lldb_object_sp);
 
-#ifndef SWIG
   SBError ResumeNewPlan(lldb_private::ExecutionContext &exe_ctx,
                         lldb_private::ThreadPlan *new_plan);
-#endif
 
-private:
   lldb::ExecutionContextRefSP m_opaque_sp;
+
+  lldb_private::Thread *operator->();
+
+  lldb_private::Thread *get();
 };
 
 } // namespace lldb

Modified: lldb/trunk/include/lldb/API/SBThreadPlan.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThreadPlan.h?rev=357984&r1=357983&r2=357984&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBThreadPlan.h (original)
+++ lldb/trunk/include/lldb/API/SBThreadPlan.h Tue Apr  9 02:03:43 2019
@@ -103,11 +103,7 @@ public:
   SBThreadPlan QueueThreadPlanForStepScripted(const char *script_class_name,
                                               SBError &error);
 
-#ifndef SWIG
-  lldb_private::ThreadPlan *get();
-#endif
-
-protected:
+private:
   friend class SBBreakpoint;
   friend class SBBreakpointLocation;
   friend class SBFrame;
@@ -117,11 +113,9 @@ protected:
   friend class lldb_private::QueueImpl;
   friend class SBQueueItem;
 
-#ifndef SWIG
+  lldb_private::ThreadPlan *get();
   void SetThreadPlan(const lldb::ThreadPlanSP &lldb_object_sp);
-#endif
 
-private:
   lldb::ThreadPlanSP m_opaque_sp;
 };
 

Modified: lldb/trunk/include/lldb/Core/Address.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=357984&r1=357983&r2=357984&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Address.h (original)
+++ lldb/trunk/include/lldb/Core/Address.h Tue Apr  9 02:03:43 2019
@@ -194,9 +194,7 @@ public:
 /// \return
 ///     A const Address object reference to \a this.
 //------------------------------------------------------------------
-#ifndef SWIG
   const Address &operator=(const Address &rhs);
-#endif
 
   //------------------------------------------------------------------
   /// Clear the object's state.

Modified: lldb/trunk/include/lldb/Core/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/SourceManager.h?rev=357984&r1=357983&r2=357984&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/SourceManager.h (original)
+++ lldb/trunk/include/lldb/Core/SourceManager.h Tue Apr  9 02:03:43 2019
@@ -39,7 +39,6 @@ namespace lldb_private {
 
 class SourceManager {
 public:
-#ifndef SWIG
   class File {
     friend bool operator==(const SourceManager::File &lhs,
                            const SourceManager::File &rhs);
@@ -99,11 +98,9 @@ public:
   private:
     void CommonInitializer(const FileSpec &file_spec, Target *target);
   };
-#endif // SWIG
 
   typedef std::shared_ptr<File> FileSP;
 
-#ifndef SWIG
   // The SourceFileCache class separates the source manager from the cache of
   // source files, so the cache can be stored in the Debugger, but the source
   // managers can be per target.
@@ -119,7 +116,6 @@ public:
     typedef std::map<FileSpec, FileSP> FileCache;
     FileCache m_file_cache;
   };
-#endif // SWIG
 
   //------------------------------------------------------------------
   // Constructors and Destructors

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=357984&r1=357983&r2=357984&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Tue Apr  9 02:03:43 2019
@@ -418,7 +418,6 @@ public:
 /// \see RegisterNotificationCallbacks (const Notifications&) @see
 /// UnregisterNotificationCallbacks (const Notifications&)
 //------------------------------------------------------------------
-#ifndef SWIG
   typedef struct {
     void *baton;
     void (*initialize)(void *baton, Process *process);
@@ -503,7 +502,6 @@ public:
 
     DISALLOW_COPY_AND_ASSIGN(ProcessEventData);
   };
-#endif // SWIG
 
   //------------------------------------------------------------------
   /// Construct with a shared pointer to a target, and the Process listener.
@@ -824,9 +822,7 @@ public:
 ///
 /// \see Process::Notifications
 //------------------------------------------------------------------
-#ifndef SWIG
   void RegisterNotificationCallbacks(const Process::Notifications &callbacks);
-#endif
 
 //------------------------------------------------------------------
 /// Unregister for process and thread notifications.
@@ -844,9 +840,7 @@ public:
 ///
 /// \see Process::Notifications
 //------------------------------------------------------------------
-#ifndef SWIG
   bool UnregisterNotificationCallbacks(const Process::Notifications &callbacks);
-#endif
 
   //==================================================================
   // Built in Process Control functions

Modified: lldb/trunk/scripts/interface/SBFrame.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBFrame.i?rev=357984&r1=357983&r2=357984&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBFrame.i (original)
+++ lldb/trunk/scripts/interface/SBFrame.i Tue Apr  9 02:03:43 2019
@@ -210,15 +210,12 @@ public:
     void
     Clear();
 
-#ifndef SWIG
     bool
     operator == (const lldb::SBFrame &rhs) const;
 
     bool
     operator != (const lldb::SBFrame &rhs) const;
 
-#endif
-
     %feature("docstring", "
     /// The version that doesn't supply a 'use_dynamic' value will use the
     /// target's default.

Modified: lldb/trunk/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=357984&r1=357983&r2=357984&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Tue Apr  9 02:03:43 2019
@@ -1398,21 +1398,11 @@ bool SBThread::SafeToCallFunctions() {
 }
 
 lldb_private::Thread *SBThread::operator->() {
-  LLDB_RECORD_METHOD_NO_ARGS(lldb_private::Thread *, SBThread, operator->);
-
-  ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
-  if (thread_sp)
-    return LLDB_RECORD_RESULT(thread_sp.get());
-  return nullptr;
+  return get();
 }
 
 lldb_private::Thread *SBThread::get() {
-  LLDB_RECORD_METHOD_NO_ARGS(lldb_private::Thread *, SBThread, get);
-
-  ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
-  if (thread_sp)
-    return LLDB_RECORD_RESULT(thread_sp.get());
-  return nullptr;
+  return m_opaque_sp->GetThreadSP().get();
 }
 
 namespace lldb_private {
@@ -1516,8 +1506,6 @@ void RegisterMethods<SBThread>(Registry
   LLDB_REGISTER_METHOD(lldb::SBThread, SBThread, GetCurrentExceptionBacktrace,
                        ());
   LLDB_REGISTER_METHOD(bool, SBThread, SafeToCallFunctions, ());
-  LLDB_REGISTER_METHOD(lldb_private::Thread *, SBThread, operator->,());
-  LLDB_REGISTER_METHOD(lldb_private::Thread *, SBThread, get, ());
 }
 
 }

Modified: lldb/trunk/source/API/SBThreadPlan.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThreadPlan.cpp?rev=357984&r1=357983&r2=357984&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThreadPlan.cpp (original)
+++ lldb/trunk/source/API/SBThreadPlan.cpp Tue Apr  9 02:03:43 2019
@@ -89,11 +89,7 @@ const lldb::SBThreadPlan &SBThreadPlan::
 //----------------------------------------------------------------------
 SBThreadPlan::~SBThreadPlan() {}
 
-lldb_private::ThreadPlan *SBThreadPlan::get() {
-  LLDB_RECORD_METHOD_NO_ARGS(lldb_private::ThreadPlan *, SBThreadPlan, get);
-
-  return LLDB_RECORD_RESULT(m_opaque_sp.get());
-}
+lldb_private::ThreadPlan *SBThreadPlan::get() { return m_opaque_sp.get(); }
 
 bool SBThreadPlan::IsValid() const {
   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, IsValid);
@@ -402,7 +398,6 @@ void RegisterMethods<SBThreadPlan>(Regis
   LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *));
   LLDB_REGISTER_METHOD(const lldb::SBThreadPlan &,
                        SBThreadPlan, operator=,(const lldb::SBThreadPlan &));
-  LLDB_REGISTER_METHOD(lldb_private::ThreadPlan *, SBThreadPlan, get, ());
   LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, IsValid, ());
   LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, operator bool, ());
   LLDB_REGISTER_METHOD(void, SBThreadPlan, Clear, ());




More information about the lldb-commits mailing list