-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
feat(demangle): Update Swift demangler to Swift 5.10 #854
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,135 @@ | ||
commit 43fca7dd2617ac93f338b5257a2e57c43dcb8154 | ||
Author: Sebastian Zivota <[email protected]> | ||
Date: Thu Dec 2 16:15:35 2021 +0100 | ||
commit eaae91fd522031a2aaafed367414f942f1c83d22 | ||
Author: fantexi023 <[email protected]> | ||
Date: Thu Jul 18 17:04:45 2024 +0800 | ||
|
||
Apply patch | ||
pass cargo build | ||
|
||
diff --git a/symbolic-demangle/vendor/swift/include/swift/Demangling/Demangle.h b/symbolic-demangle/vendor/swift/include/swift/Demangling/Demangle.h | ||
index db32dbd..f48e1c2 100644 | ||
--- a/symbolic-demangle/vendor/swift/include/swift/Demangling/Demangle.h | ||
+++ b/symbolic-demangle/vendor/swift/include/swift/Demangling/Demangle.h | ||
@@ -59,6 +59,7 @@ struct DemangleOptions { | ||
bool ShortenArchetype = false; | ||
bool ShowPrivateDiscriminators = true; | ||
bool ShowFunctionArgumentTypes = true; | ||
+ bool ShowFunctionReturnType = true; | ||
bool DisplayDebuggerGeneratedModule = true; | ||
bool DisplayStdlibModule = true; | ||
bool DisplayObjCModule = true; | ||
@@ -90,6 +91,7 @@ struct DemangleOptions { | ||
Opt.ShortenArchetype = true; | ||
Opt.ShowPrivateDiscriminators = false; | ||
Opt.ShowFunctionArgumentTypes = false; | ||
+ Opt.ShowFunctionReturnType = false; | ||
return Opt; | ||
}; | ||
diff --git a/symbolic-demangle/build.rs b/symbolic-demangle/build.rs | ||
index 4ce782eb..15246da7 100644 | ||
--- a/symbolic-demangle/build.rs | ||
+++ b/symbolic-demangle/build.rs | ||
@@ -15,7 +15,7 @@ fn main() { | ||
"vendor/swift/lib/Demangling/Punycode.cpp", | ||
"vendor/swift/lib/Demangling/Remangler.cpp", | ||
]) | ||
- .flag_if_supported("-std=c++14") | ||
+ .flag_if_supported("-std=c++17") | ||
.flag("-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1") | ||
.warnings(false) | ||
.include("vendor/swift/include") | ||
diff --git a/symbolic-demangle/src/swiftdemangle.cpp b/symbolic-demangle/src/swiftdemangle.cpp | ||
index 843a2a59..85c1fecc 100644 | ||
--- a/symbolic-demangle/src/swiftdemangle.cpp | ||
+++ b/symbolic-demangle/src/swiftdemangle.cpp | ||
@@ -12,10 +12,11 @@ extern "C" int symbolic_demangle_swift(const char *symbol, | ||
|
||
if (features < SYMBOLIC_SWIFT_FEATURE_ALL) { | ||
opts = swift::Demangle::DemangleOptions::SimplifiedUIDemangleOptions(); | ||
- bool return_type = features & SYMBOLIC_SWIFT_FEATURE_RETURN_TYPE; | ||
+ // bool return_type = features & SYMBOLIC_SWIFT_FEATURE_RETURN_TYPE; | ||
bool argument_types = features & SYMBOLIC_SWIFT_FEATURE_PARAMETERS; | ||
|
||
- opts.ShowFunctionReturnType = return_type; | ||
+ // No ShowFunctionReturnType property in DemangleOptions any more | ||
+ // opts.ShowFunctionReturnType = return_type; | ||
opts.ShowFunctionArgumentTypes = argument_types; | ||
} | ||
|
||
diff --git a/symbolic-demangle/vendor/swift/include/llvm/Support/type_traits.h b/symbolic-demangle/vendor/swift/include/llvm/Support/type_traits.h | ||
index 3fd158de..a6046de8 100644 | ||
--- a/symbolic-demangle/vendor/swift/include/llvm/Support/type_traits.h | ||
+++ b/symbolic-demangle/vendor/swift/include/llvm/Support/type_traits.h | ||
@@ -32,11 +32,11 @@ template <typename T> class is_integral_or_enum { | ||
|
||
public: | ||
static const bool value = | ||
- !std::is_class_v<UnderlyingT> && // Filter conversion operators. | ||
- !std::is_pointer_v<UnderlyingT> && | ||
- !std::is_floating_point_v<UnderlyingT> && | ||
- (std::is_enum_v<UnderlyingT> || | ||
- std::is_convertible_v<UnderlyingT, unsigned long long>); | ||
+ !std::is_class<UnderlyingT>::value && // Filter conversion operators. | ||
+ !std::is_pointer<UnderlyingT>::value && | ||
+ !std::is_floating_point<UnderlyingT>::value && | ||
+ (std::is_enum<UnderlyingT>::value || | ||
+ std::is_convertible<UnderlyingT, unsigned long long>::value); | ||
}; | ||
|
||
/// If T is a pointer, just return it. If it is not, return T&. | ||
@@ -45,7 +45,7 @@ struct add_lvalue_reference_if_not_pointer { using type = T &; }; | ||
|
||
template <typename T> | ||
struct add_lvalue_reference_if_not_pointer< | ||
- T, std::enable_if_t<std::is_pointer_v<T>>> { | ||
+ T, std::enable_if_t<std::is_pointer<T>::value>> { | ||
using type = T; | ||
}; | ||
|
||
@@ -55,7 +55,7 @@ template<typename T, typename Enable = void> | ||
struct add_const_past_pointer { using type = const T; }; | ||
|
||
template <typename T> | ||
-struct add_const_past_pointer<T, std::enable_if_t<std::is_pointer_v<T>>> { | ||
+struct add_const_past_pointer<T, std::enable_if_t<std::is_pointer<T>::value>> { | ||
using type = const std::remove_pointer_t<T> *; | ||
}; | ||
|
||
@@ -64,11 +64,27 @@ struct const_pointer_or_const_ref { | ||
using type = const T &; | ||
}; | ||
diff --git a/symbolic-demangle/vendor/swift/lib/Demangling/NodePrinter.cpp b/symbolic-demangle/vendor/swift/lib/Demangling/NodePrinter.cpp | ||
index 2a9c0dc..34fa785 100644 | ||
--- a/symbolic-demangle/vendor/swift/lib/Demangling/NodePrinter.cpp | ||
+++ b/symbolic-demangle/vendor/swift/lib/Demangling/NodePrinter.cpp | ||
@@ -863,10 +863,11 @@ private: | ||
if (isSendable) | ||
Printer << "@Sendable "; | ||
|
||
- printFunctionParameters(LabelList, node->getChild(startIndex), | ||
- Options.ShowFunctionArgumentTypes); | ||
+ if (Options.ShowFunctionArgumentTypes) { | ||
+ printFunctionParameters(LabelList, node->getChild(startIndex), true); | ||
+ } | ||
|
||
- if (!Options.ShowFunctionArgumentTypes) | ||
+ if (!Options.ShowFunctionReturnType) | ||
return; | ||
|
||
if (isAsync) | ||
template <typename T> | ||
-struct const_pointer_or_const_ref<T, std::enable_if_t<std::is_pointer_v<T>>> { | ||
+struct const_pointer_or_const_ref<T, | ||
+ std::enable_if_t<std::is_pointer<T>::value>> { | ||
using type = typename add_const_past_pointer<T>::type; | ||
}; | ||
|
||
namespace detail { | ||
+/// Internal utility to detect trivial copy construction. | ||
+template<typename T> union copy_construction_triviality_helper { | ||
+ T t; | ||
+ copy_construction_triviality_helper() = default; | ||
+ copy_construction_triviality_helper(const copy_construction_triviality_helper&) = default; | ||
+ ~copy_construction_triviality_helper() = default; | ||
+}; | ||
+/// Internal utility to detect trivial move construction. | ||
+template<typename T> union move_construction_triviality_helper { | ||
+ T t; | ||
+ move_construction_triviality_helper() = default; | ||
+ move_construction_triviality_helper(move_construction_triviality_helper&&) = default; | ||
+ ~move_construction_triviality_helper() = default; | ||
+}; | ||
+ | ||
template<class T> | ||
union trivial_helper { | ||
T t; | ||
@@ -76,6 +92,29 @@ union trivial_helper { | ||
|
||
} // end namespace detail | ||
|
||
+/// An implementation of `std::is_trivially_copy_constructible` since we have | ||
+/// users with STLs that don't yet include it. | ||
+template <typename T> | ||
+struct is_trivially_copy_constructible | ||
+ : std::is_copy_constructible< | ||
+ ::llvm::detail::copy_construction_triviality_helper<T>> {}; | ||
+template <typename T> | ||
+struct is_trivially_copy_constructible<T &> : std::true_type {}; | ||
+template <typename T> | ||
+struct is_trivially_copy_constructible<T &&> : std::false_type {}; | ||
+ | ||
+/// An implementation of `std::is_trivially_move_constructible` since we have | ||
+/// users with STLs that don't yet include it. | ||
+template <typename T> | ||
+struct is_trivially_move_constructible | ||
+ : std::is_move_constructible< | ||
+ ::llvm::detail::move_construction_triviality_helper<T>> {}; | ||
+template <typename T> | ||
+struct is_trivially_move_constructible<T &> : std::true_type {}; | ||
+template <typename T> | ||
+struct is_trivially_move_constructible<T &&> : std::true_type {}; | ||
+ | ||
+ | ||
template <typename T> | ||
struct is_copy_assignable { | ||
template<class F> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
//===- llvm/ADT/ADL.h - Argument dependent lookup utilities -----*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_ADT_ADL_H | ||
#define LLVM_ADT_ADL_H | ||
|
||
#include <type_traits> | ||
#include <iterator> | ||
#include <utility> | ||
|
||
namespace llvm { | ||
|
||
// Only used by compiler if both template types are the same. Useful when | ||
// using SFINAE to test for the existence of member functions. | ||
template <typename T, T> struct SameType; | ||
|
||
namespace adl_detail { | ||
|
||
using std::begin; | ||
|
||
template <typename RangeT> | ||
constexpr auto begin_impl(RangeT &&range) | ||
-> decltype(begin(std::forward<RangeT>(range))) { | ||
return begin(std::forward<RangeT>(range)); | ||
} | ||
|
||
using std::end; | ||
|
||
template <typename RangeT> | ||
constexpr auto end_impl(RangeT &&range) | ||
-> decltype(end(std::forward<RangeT>(range))) { | ||
return end(std::forward<RangeT>(range)); | ||
} | ||
|
||
using std::swap; | ||
|
||
template <typename T> | ||
constexpr void swap_impl(T &&lhs, | ||
T &&rhs) noexcept(noexcept(swap(std::declval<T>(), | ||
std::declval<T>()))) { | ||
swap(std::forward<T>(lhs), std::forward<T>(rhs)); | ||
} | ||
|
||
using std::size; | ||
|
||
template <typename RangeT> | ||
constexpr auto size_impl(RangeT &&range) | ||
-> decltype(size(std::forward<RangeT>(range))) { | ||
return size(std::forward<RangeT>(range)); | ||
} | ||
|
||
} // end namespace adl_detail | ||
|
||
/// Returns the begin iterator to \p range using `std::begin` and | ||
/// function found through Argument-Dependent Lookup (ADL). | ||
template <typename RangeT> | ||
constexpr auto adl_begin(RangeT &&range) | ||
-> decltype(adl_detail::begin_impl(std::forward<RangeT>(range))) { | ||
return adl_detail::begin_impl(std::forward<RangeT>(range)); | ||
} | ||
|
||
/// Returns the end iterator to \p range using `std::end` and | ||
/// functions found through Argument-Dependent Lookup (ADL). | ||
template <typename RangeT> | ||
constexpr auto adl_end(RangeT &&range) | ||
-> decltype(adl_detail::end_impl(std::forward<RangeT>(range))) { | ||
return adl_detail::end_impl(std::forward<RangeT>(range)); | ||
} | ||
|
||
/// Swaps \p lhs with \p rhs using `std::swap` and functions found through | ||
/// Argument-Dependent Lookup (ADL). | ||
template <typename T> | ||
constexpr void adl_swap(T &&lhs, T &&rhs) noexcept( | ||
noexcept(adl_detail::swap_impl(std::declval<T>(), std::declval<T>()))) { | ||
adl_detail::swap_impl(std::forward<T>(lhs), std::forward<T>(rhs)); | ||
} | ||
|
||
/// Returns the size of \p range using `std::size` and functions found through | ||
/// Argument-Dependent Lookup (ADL). | ||
template <typename RangeT> | ||
constexpr auto adl_size(RangeT &&range) | ||
-> decltype(adl_detail::size_impl(std::forward<RangeT>(range))) { | ||
return adl_detail::size_impl(std::forward<RangeT>(range)); | ||
} | ||
|
||
namespace detail { | ||
|
||
template <typename RangeT> | ||
using IterOfRange = decltype(adl_begin(std::declval<RangeT &>())); | ||
|
||
template <typename RangeT> | ||
using ValueOfRange = | ||
std::remove_reference_t<decltype(*adl_begin(std::declval<RangeT &>()))>; | ||
|
||
} // namespace detail | ||
} // namespace llvm | ||
|
||
#endif // LLVM_ADT_ADL_H |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mentioned this in the changed
swiftdemangle.cpp
file. This option is indeed not part of upstream Swift, but we patched that in via this small patch here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your reply.
I also saw that the CI process gave five errors, among which the problem of Rust Test on macos-latest should be that the SWIFT_STDLIB_HAS_TYPE_PRINTING did not take effect, which may be caused by the passing exception of CMakeLists.txt. I cancelled the restriction of SWIFT_STDLIB_HAS_TYPE_PRINTING this macro locally. The other four problems correspond to the same error, but I did not encounter this error on my own Mac.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I do understand your explanation for ShowFunctionReturnType. TXS!