[Lldb-commits] [lldb] ebec53e - [lldb] Introduce a macro to mark methods as unsupported with no replacement

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 3 11:20:22 PDT 2023


Author: Alex Langford
Date: 2023-07-03T11:17:48-07:00
New Revision: ebec53e2d7c79b519aec455d048f5f03fc2e7abe

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

LOG: [lldb] Introduce a macro to mark methods as unsupported with no replacement

We already have LLDB_DEPRECATED which is used to mark methods as
deprecated with a message and an alternative to use instead. This is
expresses an intent of "We recognize this functionality is useful but
there are some pitfalls with the interface we have exposed."

In other cases, there are no "alternative" methods to use and the code should be
refactored to avoid using a method entirely. For example,
`SBValue::Cast` should be avoided in favor of using the expression
evaluator to perform a cast. There isn't a mechanical solution, the
recommendation is to instead refactor your code.

This commit renames the existing `LLDB_DEPRECATED` to
`LLDB_DEPRECATED_FIXME`, and adds a `LLDB_DEPRECATED` macro to cover the
second scenario.

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

Added: 
    

Modified: 
    lldb/include/lldb/API/SBCommandReturnObject.h
    lldb/include/lldb/API/SBDebugger.h
    lldb/include/lldb/API/SBDefines.h
    lldb/include/lldb/API/SBFileSpec.h
    lldb/include/lldb/API/SBProcess.h
    lldb/include/lldb/API/SBStructuredData.h
    lldb/include/lldb/API/SBTarget.h
    lldb/include/lldb/API/SBValue.h
    lldb/include/lldb/lldb-defines.h

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/API/SBCommandReturnObject.h b/lldb/include/lldb/API/SBCommandReturnObject.h
index ce93b28ba84cb1..f96384a4710b16 100644
--- a/lldb/include/lldb/API/SBCommandReturnObject.h
+++ b/lldb/include/lldb/API/SBCommandReturnObject.h
@@ -47,8 +47,8 @@ class LLDB_API SBCommandReturnObject {
   const char *GetError();
 
 #ifndef SWIG
-  LLDB_DEPRECATED("Use PutOutput(SBFile) or PutOutput(FileSP)",
-                  "PutOutput(SBFile)")
+  LLDB_DEPRECATED_FIXME("Use PutOutput(SBFile) or PutOutput(FileSP)",
+                        "PutOutput(SBFile)")
   size_t PutOutput(FILE *fh);
 #endif
 
@@ -61,8 +61,8 @@ class LLDB_API SBCommandReturnObject {
   size_t GetErrorSize();
 
 #ifndef SWIG
-  LLDB_DEPRECATED("Use PutError(SBFile) or PutError(FileSP)",
-                  "PutError(SBFile)")
+  LLDB_DEPRECATED_FIXME("Use PutError(SBFile) or PutError(FileSP)",
+                        "PutError(SBFile)")
   size_t PutError(FILE *fh);
 #endif
 
@@ -87,22 +87,22 @@ class LLDB_API SBCommandReturnObject {
   bool GetDescription(lldb::SBStream &description);
 
 #ifndef SWIG
-  LLDB_DEPRECATED(
+  LLDB_DEPRECATED_FIXME(
       "Use SetImmediateOutputFile(SBFile) or SetImmediateOutputFile(FileSP)",
       "SetImmediateOutputFile(SBFile)")
   void SetImmediateOutputFile(FILE *fh);
 
-  LLDB_DEPRECATED(
+  LLDB_DEPRECATED_FIXME(
       "Use SetImmediateErrorFile(SBFile) or SetImmediateErrorFile(FileSP)",
       "SetImmediateErrorFile(SBFile)")
   void SetImmediateErrorFile(FILE *fh);
 
-  LLDB_DEPRECATED(
+  LLDB_DEPRECATED_FIXME(
       "Use SetImmediateOutputFile(SBFile) or SetImmediateOutputFile(FileSP)",
       "SetImmediateOutputFile(SBFile)")
   void SetImmediateOutputFile(FILE *fh, bool transfer_ownership);
 
-  LLDB_DEPRECATED(
+  LLDB_DEPRECATED_FIXME(
       "Use SetImmediateErrorFile(SBFile) or SetImmediateErrorFile(FileSP)",
       "SetImmediateErrorFile(SBFile)")
   void SetImmediateErrorFile(FILE *fh, bool transfer_ownership);

diff  --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h
index 5a2ea634d882d5..57199d3fcb5e68 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -115,7 +115,7 @@ class LLDB_API SBDebugger {
 
   static void Terminate();
 
-  LLDB_DEPRECATED("Use one of the other Create variants", "Create(bool)")
+  LLDB_DEPRECATED_FIXME("Use one of the other Create variants", "Create(bool)")
   static lldb::SBDebugger Create();
 
   static lldb::SBDebugger Create(bool source_init_files);
@@ -208,14 +208,13 @@ class LLDB_API SBDebugger {
   lldb::SBListener GetListener();
 
 #ifndef SWIG
-  LLDB_DEPRECATED(
+  LLDB_DEPRECATED_FIXME(
       "Use HandleProcessEvent(const SBProcess &, const SBEvent &, SBFile, "
       "SBFile) or HandleProcessEvent(const SBProcess &, const SBEvent &, "
       "FileSP, FileSP)",
       "HandleProcessEvent(const SBProcess &, const SBEvent &, SBFile, SBFile)")
   void HandleProcessEvent(const lldb::SBProcess &process,
-                          const lldb::SBEvent &event, FILE *out,
-                          FILE *err);
+                          const lldb::SBEvent &event, FILE *out, FILE *err);
 #endif
 
   void HandleProcessEvent(const lldb::SBProcess &process,
@@ -332,8 +331,8 @@ class LLDB_API SBDebugger {
                           void *baton);
 
 #ifndef SWIG
-  LLDB_DEPRECATED("Use DispatchInput(const void *, size_t)",
-                  "DispatchInput(const void *, size_t)")
+  LLDB_DEPRECATED_FIXME("Use DispatchInput(const void *, size_t)",
+                        "DispatchInput(const void *, size_t)")
   void DispatchInput(void *baton, const void *data, size_t data_len);
 #endif
 

diff  --git a/lldb/include/lldb/API/SBDefines.h b/lldb/include/lldb/API/SBDefines.h
index 15b25d08530b89..fed5094fd4d34f 100644
--- a/lldb/include/lldb/API/SBDefines.h
+++ b/lldb/include/lldb/API/SBDefines.h
@@ -34,7 +34,9 @@
 // supports the attribute.
 #if defined(SWIG) || _cplusplus < 201402L
 #undef LLDB_DEPRECATED
-#define LLDB_DEPRECATED(MSG, FIX)
+#undef LLDB_DEPRECATED_FIXME
+#define LLDB_DEPRECATED(MSG)
+#define LLDB_DEPRECATED_FIXME(MSG, FIX)
 #endif
 
 // Forward Declarations

diff  --git a/lldb/include/lldb/API/SBFileSpec.h b/lldb/include/lldb/API/SBFileSpec.h
index 48171e64e5c88c..beefa19ad7f36b 100644
--- a/lldb/include/lldb/API/SBFileSpec.h
+++ b/lldb/include/lldb/API/SBFileSpec.h
@@ -19,9 +19,10 @@ class LLDB_API SBFileSpec {
 
   SBFileSpec(const lldb::SBFileSpec &rhs);
 
-  LLDB_DEPRECATED("Use the other constructor to determine if this the file "
-                  "spec should be resolved",
-                  "SBFileSpec(const char *, bool)")
+  LLDB_DEPRECATED_FIXME(
+      "Use the other constructor to determine if this the file "
+      "spec should be resolved",
+      "SBFileSpec(const char *, bool)")
   SBFileSpec(const char *path);
 
   SBFileSpec(const char *path, bool resolve);

diff  --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h
index 76cf155d4b6186..751065c7afdaed 100644
--- a/lldb/include/lldb/API/SBProcess.h
+++ b/lldb/include/lldb/API/SBProcess.h
@@ -48,7 +48,7 @@ class LLDB_API SBProcess {
 
   const char *GetPluginName();
 
-  LLDB_DEPRECATED("Use GetPluginName()", "GetPluginName()")
+  LLDB_DEPRECATED_FIXME("Use GetPluginName()", "GetPluginName()")
   const char *GetShortPluginName();
 
   void Clear();

diff  --git a/lldb/include/lldb/API/SBStructuredData.h b/lldb/include/lldb/API/SBStructuredData.h
index 2f6263843ba283..e859f68cb2ca7a 100644
--- a/lldb/include/lldb/API/SBStructuredData.h
+++ b/lldb/include/lldb/API/SBStructuredData.h
@@ -72,8 +72,9 @@ class SBStructuredData {
   /// Return the integer value if this data structure is an integer type.
   int64_t GetSignedIntegerValue(int64_t fail_value = 0) const;
 
-  LLDB_DEPRECATED("Specify if the value is signed or unsigned",
-                  "uint64_t GetUnsignedIntegerValue(uint64_t fail_value = 0)")
+  LLDB_DEPRECATED_FIXME(
+      "Specify if the value is signed or unsigned",
+      "uint64_t GetUnsignedIntegerValue(uint64_t fail_value = 0)")
   uint64_t GetIntegerValue(uint64_t fail_value = 0) const;
 
   /// Return the floating point value if this data structure is a floating

diff  --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index ea5212ea56d935..07bd6a8b76d2f1 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -396,8 +396,8 @@ class LLDB_API SBTarget {
   /// \return
   ///     An error to indicate success, fail, and any reason for
   ///     failure.
-  LLDB_DEPRECATED("Use SetModuleLoadAddress(lldb::SBModule, uint64_t)",
-                  "SetModuleLoadAddress(lldb::SBModule, uint64_t)")
+  LLDB_DEPRECATED_FIXME("Use SetModuleLoadAddress(lldb::SBModule, uint64_t)",
+                        "SetModuleLoadAddress(lldb::SBModule, uint64_t)")
   lldb::SBError SetModuleLoadAddress(lldb::SBModule module,
                                      int64_t sections_offset);
 #endif

diff  --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index 408298a743ec03..e288dbf4c298ae 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -105,8 +105,8 @@ class LLDB_API SBValue {
 
   const char *GetLocation();
 
-  LLDB_DEPRECATED("Use the variant that takes an SBError &",
-                  "SetValueFromCString(const char *, SBError &)")
+  LLDB_DEPRECATED_FIXME("Use the variant that takes an SBError &",
+                        "SetValueFromCString(const char *, SBError &)")
   bool SetValueFromCString(const char *value_str);
 
   bool SetValueFromCString(const char *value_str, lldb::SBError &error);
@@ -124,7 +124,7 @@ class LLDB_API SBValue {
   lldb::SBValue CreateChildAtOffset(const char *name, uint32_t offset,
                                     lldb::SBType type);
 
-  LLDB_DEPRECATED("Use the expression evaluator to perform type casting", "")
+  LLDB_DEPRECATED("Use the expression evaluator to perform type casting")
   lldb::SBValue Cast(lldb::SBType type);
 
   lldb::SBValue CreateValueFromExpression(const char *name,
@@ -295,7 +295,7 @@ class LLDB_API SBValue {
 
   lldb::SBValue Dereference();
 
-  LLDB_DEPRECATED("Use GetType().IsPointerType() instead", "")
+  LLDB_DEPRECATED("Use GetType().IsPointerType() instead")
   bool TypeIsPointerType();
 
   lldb::SBType GetType();

diff  --git a/lldb/include/lldb/lldb-defines.h b/lldb/include/lldb/lldb-defines.h
index 1cf86eff72cbee..5e43f55224f520 100644
--- a/lldb/include/lldb/lldb-defines.h
+++ b/lldb/include/lldb/lldb-defines.h
@@ -125,10 +125,13 @@
 
 #define UNUSED_IF_ASSERT_DISABLED(x) ((void)(x))
 
+#define LLDB_DEPRECATED(MSG)                                                   \
+  [[deprecated("This method is no longer supported: " MSG)]]
+
 #if defined(__clang__)
-#define LLDB_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
+#define LLDB_DEPRECATED_FIXME(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
 #else
-#define LLDB_DEPRECATED(MSG, FIX) [[deprecated(MSG)]]
+#define LLDB_DEPRECATED_FIXME(MSG, FIX) LLDB_DEPRECATED(MSG)
 #endif
 
 #endif // LLDB_LLDB_DEFINES_H


        


More information about the lldb-commits mailing list