[Lldb-commits] [lldb] 2279f77 - [lldb] Add an LLDB_DEPRECATED macro similar to LLVM_DEPRECATED
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Thu Apr 6 14:56:42 PDT 2023
Author: Jonas Devlieghere
Date: 2023-04-06T14:56:34-07:00
New Revision: 2279f77d2855d9caa0ece466462d34bcfdf4fb3d
URL: https://github.com/llvm/llvm-project/commit/2279f77d2855d9caa0ece466462d34bcfdf4fb3d
DIFF: https://github.com/llvm/llvm-project/commit/2279f77d2855d9caa0ece466462d34bcfdf4fb3d.diff
LOG: [lldb] Add an LLDB_DEPRECATED macro similar to LLVM_DEPRECATED
Add an LLDB_DEPRECATED macro similar to LLVM_DEPRECATED. We cannot
directly reuse the LLVM one, because it's defined in Compiler.h which is
not something we can include in the SB API.
For the SB API, the macro is undef'd if:
1. We're building the SWIG bindings. We might still want to expose
deprecated methods to our scripting users.
2. We're targeting anything older than C++14 as the [[deprecated]]
attribute was added for C++14 and the SB API can be used by
projects compiling against an older language version.
Differential revision: https://reviews.llvm.org/D147736
Added:
Modified:
lldb/include/lldb/API/SBDefines.h
lldb/include/lldb/API/SBTarget.h
lldb/include/lldb/lldb-defines.h
Removed:
################################################################################
diff --git a/lldb/include/lldb/API/SBDefines.h b/lldb/include/lldb/API/SBDefines.h
index e7f8ca7b35f0..4f04cd1f5057 100644
--- a/lldb/include/lldb/API/SBDefines.h
+++ b/lldb/include/lldb/API/SBDefines.h
@@ -27,6 +27,14 @@
#endif
#endif
+// Don't add the deprecated attribute when generating the bindings or when
+// building for anything older than C++14 which is the first version that
+// supports the attribute.
+#if defined(SWIG) or _cplusplus < 201402L
+#undef LLDB_DEPRECATED
+#define LLDB_DEPRECATED(MSG, FIX)
+#endif
+
// Forward Declarations
namespace lldb {
diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 404e9059c2bc..a67a26fd7c39 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -390,7 +390,8 @@ class LLDB_API SBTarget {
/// \return
/// An error to indicate success, fail, and any reason for
/// failure.
- [[deprecated("Use SetModuleLoadAddress(lldb::SBModule, uint64_t)")]]
+ LLDB_DEPRECATED("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/lldb-defines.h b/lldb/include/lldb/lldb-defines.h
index 3d23d697b542..1cf86eff72cb 100644
--- a/lldb/include/lldb/lldb-defines.h
+++ b/lldb/include/lldb/lldb-defines.h
@@ -125,4 +125,10 @@
#define UNUSED_IF_ASSERT_DISABLED(x) ((void)(x))
+#if defined(__clang__)
+#define LLDB_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
+#else
+#define LLDB_DEPRECATED(MSG, FIX) [[deprecated(MSG)]]
+#endif
+
#endif // LLDB_LLDB_DEFINES_H
More information about the lldb-commits
mailing list