Skip to content

[lldb] Disable warning about codecvt_utf8 deprecation (NFC) #112446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

JDevlieghere
Copy link
Member

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.

Disable -Wdeprecated-declarations for codecvt_utf8 in Editline. This is
in preparation for llvm#112276 which narrows the scope of
-Wno-deprecated-declarations for building LLDB.
@JDevlieghere JDevlieghere requested a review from labath October 15, 2024 22:21
@llvmbot llvmbot added the lldb label Oct 15, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 15, 2024

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/112446.diff

2 Files Affected:

  • (modified) lldb/include/lldb/Host/Editline.h (+22)
  • (modified) lldb/source/Host/common/Editline.cpp (+2)
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;

@JDevlieghere
Copy link
Member Author

There was an attempt to remove this (https://reviews.llvm.org/D106035) but this hit some issues on Arch and with column counting which is out of scope for what I'm trying to achieve.

@labath
Copy link
Collaborator

labath commented Oct 16, 2024

There was an attempt to remove this (https://reviews.llvm.org/D106035) but this hit some issues on Arch and with column counting which is out of scope for what I'm trying to achieve.

I'm not actually sure the approach in that patch is feasible. Last time I looked at this (which was a long time ago, to be fair), to problem was basically that editline could be built in two modes (wide or not), and we had to do something to match what was being used there.

Copy link
Collaborator

@labath labath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be a non-deprecated way of achieving this, though I'm not entirely sure about its portability (windows is the main question, but I guess we don't use editline there anyway). I don't think you have to do that, but it is an option.

 - Rename macro and include LLDB prefix.
 - Fix copy/paste error.
 - Define empty macro in else block.
@JDevlieghere
Copy link
Member Author

this might be a non-deprecated way of achieving this, though I'm not entirely sure about its portability (windows is the main question, but I guess we don't use editline there anyway). I don't think you have to do that, but it is an option.

Thanks, I see you did something similar in Editline::CompleteCharacter. Let me know if #112582 matches what you had in mind.

@JDevlieghere JDevlieghere merged commit 8c7f80f into llvm:main Oct 17, 2024
7 checks passed
@JDevlieghere JDevlieghere deleted the disable-deprecated-declarations-editline branch October 17, 2024 15:20
JDevlieghere added a commit to swiftlang/llvm-project that referenced this pull request Oct 22, 2024
)

Disable -Wdeprecated-declarations for codecvt_utf8 in Editline. This is
in preparation for llvm#112276 which narrows the scope of
-Wno-deprecated-declarations for building LLDB.

(cherry picked from commit 8c7f80f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants