Skip to content

Commit 94bb783

Browse files
demangle: ignore lambda printing differences in TestCases
1 parent 35f2a47 commit 94bb783

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

cases_test.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package demangle
66

77
import (
8+
"regexp"
89
"strings"
910
"testing"
1011
)
@@ -30051,8 +30052,6 @@ var casesExpectedFailures = map[string]bool{
3005130052
"_ZZN5OuterI4MarpEcv7MuncherIJT_T0_DpT1_EEI4MerpS0_JicfEEEvEN1ScvS9_Ev": true,
3005230053
"_ZN1Scv7MuncherIJDpPT_EEIJFivEA_iEEEv": true,
3005330054
"_Z2f8IiJ8identityIiES0_IfEEEvRAsPiDpT0_T_DpNS3_4typeEE_i": true,
30054-
"_ZNK13StaticMembersIfE1xMUlvE_clEv": true,
30055-
"_ZNK10inline_varMUlvE_clEv": true,
3005630055
"___Z3foo_block_invoke.25": true,
3005730056
"____Z3foo_block_invoke.25": true,
3005830057
"__Z1fv": true,
@@ -30072,7 +30071,6 @@ var casesExpectedFailures = map[string]bool{
3007230071
"_ZZ11inline_funcvENKUlTyTyT_T1_T0_E_clIiiiEEDaS_S0_S1_": true,
3007330072
"_ZN1XIZ1fIiEvOT_EUlOT_DpT0_E_EclIJEEEvDpT_": true,
3007430073
"_ZN1XIZ1fIiEvOT_EUlS2_DpT0_E_EclIJEEEvDpT_": true,
30075-
"_ZZZZN6abcdef9abcdefghi29abcdefabcdefabcdefabcefabcdef27xxxxxxxxxxxxxxxxxxxxxxxxxxxEN4absl8DurationERKNSt3__u12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEPNS1_19yyyyyyyyyyyyyyyyyyyEENK3$_5clEvENKUlvE_clEvE6zzzzzz": true,
3007630074
}
3007730075

3007830076
// caseExceptions is a list of exceptions from the LLVM list that we
@@ -30144,11 +30142,23 @@ func TestCases(t *testing.T) {
3014430142
}
3014530143
}
3014630144

30145+
// lambdaMatch is used to turn a GCC style demangled lambda into an
30146+
// LLVM style demangled lambda. The GCC style includes an index where
30147+
// the LLVM style does not.
30148+
var lambdaMatch = regexp.MustCompile("#[0-9]+}")
30149+
3014730150
// closeEnoughCase reports whether the two demangled strings are close
3014830151
// enough for our purposes. This code follows the GCC demangler, but
3014930152
// the cases are from the LLVM demangler. There are irrelevant
3015030153
// differences in spaces and parentheses that we accept.
3015130154
func closeEnoughCase(a, b string) bool {
30155+
if strings.Contains(a, "lambda") && strings.Contains(b, "lambda") {
30156+
a = strings.ReplaceAll(a, "{lambda(", "'lambda'(")
30157+
b = strings.ReplaceAll(b, "{lambda(", "'lambda'(")
30158+
a = lambdaMatch.ReplaceAllString(a, "")
30159+
b = lambdaMatch.ReplaceAllString(b, "")
30160+
}
30161+
3015230162
drop := func(r rune) rune {
3015330163
switch r {
3015430164
case ' ', '(', ')':

0 commit comments

Comments
 (0)