[Lldb-commits] [lldb] [lldb] Disable warning about codecvt_utf8 deprecation (NFC) (PR #112446)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 16 07:13:57 PDT 2024
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/112446
>From 4c53565414c95ddd49050363d3302452cbb99b27 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Tue, 15 Oct 2024 15:19:16 -0700
Subject: [PATCH 1/2] [lldb] Disable warning about codecvt_utf8 deprecation
(NFC)
Disable -Wdeprecated-declarations for codecvt_utf8 in Editline. This is
in preparation for #112276 which narrows the scope of
-Wno-deprecated-declarations for building LLDB.
---
lldb/include/lldb/Host/Editline.h | 22 ++++++++++++++++++++++
lldb/source/Host/common/Editline.cpp | 2 ++
2 files changed, 24 insertions(+)
diff --git a/lldb/include/lldb/Host/Editline.h b/lldb/include/lldb/Host/Editline.h
index 9049b106f02a34..f5d461d32b72fa 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -57,6 +57,26 @@
#include "llvm/ADT/FunctionExtras.h"
+#if defined(__clang__) && defined(__has_warning)
+#if __has_warning("-Wimplicit-fallthrough")
+#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
+#define RESTORE_DEPRECATED_DECLARATION_WARNINGS _Pragma("clang diagnostic pop")
+#endif
+#elif defined(__GNUC__) && __GNUC__ > 6
+#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+#define RESTORE_DEPRECATED_DECLARATION_WARNINGS _Pragma("GCC diagnostic pop")
+#endif
+#ifndef EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
+#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
+#endif
+#ifndef EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
+#define EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
+#endif
+
namespace lldb_private {
namespace line_editor {
@@ -367,7 +387,9 @@ class Editline {
void SetGetCharacterFunction(EditlineGetCharCallbackType callbackFn);
#if LLDB_EDITLINE_USE_WCHAR
+ EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
std::wstring_convert<std::codecvt_utf8<wchar_t>> m_utf8conv;
+ EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
#endif
::EditLine *m_editline = nullptr;
EditlineHistorySP m_history_sp;
diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp
index 561ec228cdb23f..b5b8d46c0721cf 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -1574,7 +1574,9 @@ bool Editline::CompleteCharacter(char ch, EditLineGetCharType &out) {
out = (unsigned char)ch;
return true;
#else
+ EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
std::codecvt_utf8<wchar_t> cvt;
+ EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
llvm::SmallString<4> input;
for (;;) {
const char *from_next;
>From 206f4725a7b58f6ffa8f2420b800c17d5b9a52e4 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Wed, 16 Oct 2024 07:13:07 -0700
Subject: [PATCH 2/2] Address Pavel's feedback
- Rename macro and include LLDB prefix.
- Fix copy/paste error.
- Define empty macro in else block.
---
lldb/include/lldb/Host/Editline.h | 23 ++++++++++-------------
lldb/source/Host/common/Editline.cpp | 2 +-
2 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/lldb/include/lldb/Host/Editline.h b/lldb/include/lldb/Host/Editline.h
index f5d461d32b72fa..a02f90891599ad 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -58,23 +58,20 @@
#include "llvm/ADT/FunctionExtras.h"
#if defined(__clang__) && defined(__has_warning)
-#if __has_warning("-Wimplicit-fallthrough")
-#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS \
+#if __has_warning("-Wdeprecated-declarations")
+#define LLDB_DEPRECATED_WARNING_DISABLE \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
-#define RESTORE_DEPRECATED_DECLARATION_WARNINGS _Pragma("clang diagnostic pop")
+#define LLDB_DEPRECATED_WARNING_RESTORE _Pragma("clang diagnostic pop")
#endif
#elif defined(__GNUC__) && __GNUC__ > 6
-#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS \
+#define LLDB_DEPRECATED_WARNING_DISABLE \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
-#define RESTORE_DEPRECATED_DECLARATION_WARNINGS _Pragma("GCC diagnostic pop")
-#endif
-#ifndef EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
-#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
-#endif
-#ifndef EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
-#define EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
+#define LLDB_DEPRECATED_WARNING_RESTORE _Pragma("GCC diagnostic pop")
+#else
+#define LLDB_DEPRECATED_WARNING_DISABLE
+#define LLDB_DEPRECATED_WARNING_RESTORE
#endif
namespace lldb_private {
@@ -387,9 +384,9 @@ class Editline {
void SetGetCharacterFunction(EditlineGetCharCallbackType callbackFn);
#if LLDB_EDITLINE_USE_WCHAR
- EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
+ LLDB_DEPRECATED_WARNING_DISABLE
std::wstring_convert<std::codecvt_utf8<wchar_t>> m_utf8conv;
- EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
+ LLDB_DEPRECATED_WARNING_RESTORE
#endif
::EditLine *m_editline = nullptr;
EditlineHistorySP m_history_sp;
diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp
index b5b8d46c0721cf..3d104f61515f2a 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -1574,7 +1574,7 @@ bool Editline::CompleteCharacter(char ch, EditLineGetCharType &out) {
out = (unsigned char)ch;
return true;
#else
- EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
+ LLDB_DEPRECATED_WARNING_DISABLE
std::codecvt_utf8<wchar_t> cvt;
EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
llvm::SmallString<4> input;
More information about the lldb-commits
mailing list