Skip to content

Commit

Permalink
demangle: ignore lambda printing differences in TestCases
Browse files Browse the repository at this point in the history
  • Loading branch information
ianlancetaylor committed Mar 11, 2021
1 parent 35f2a47 commit 94bb783
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package demangle

import (
"regexp"
"strings"
"testing"
)
Expand Down Expand Up @@ -30051,8 +30052,6 @@ var casesExpectedFailures = map[string]bool{
"_ZZN5OuterI4MarpEcv7MuncherIJT_T0_DpT1_EEI4MerpS0_JicfEEEvEN1ScvS9_Ev": true,
"_ZN1Scv7MuncherIJDpPT_EEIJFivEA_iEEEv": true,
"_Z2f8IiJ8identityIiES0_IfEEEvRAsPiDpT0_T_DpNS3_4typeEE_i": true,
"_ZNK13StaticMembersIfE1xMUlvE_clEv": true,
"_ZNK10inline_varMUlvE_clEv": true,
"___Z3foo_block_invoke.25": true,
"____Z3foo_block_invoke.25": true,
"__Z1fv": true,
Expand All @@ -30072,7 +30071,6 @@ var casesExpectedFailures = map[string]bool{
"_ZZ11inline_funcvENKUlTyTyT_T1_T0_E_clIiiiEEDaS_S0_S1_": true,
"_ZN1XIZ1fIiEvOT_EUlOT_DpT0_E_EclIJEEEvDpT_": true,
"_ZN1XIZ1fIiEvOT_EUlS2_DpT0_E_EclIJEEEvDpT_": true,
"_ZZZZN6abcdef9abcdefghi29abcdefabcdefabcdefabcefabcdef27xxxxxxxxxxxxxxxxxxxxxxxxxxxEN4absl8DurationERKNSt3__u12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEPNS1_19yyyyyyyyyyyyyyyyyyyEENK3$_5clEvENKUlvE_clEvE6zzzzzz": true,
}

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

// lambdaMatch is used to turn a GCC style demangled lambda into an
// LLVM style demangled lambda. The GCC style includes an index where
// the LLVM style does not.
var lambdaMatch = regexp.MustCompile("#[0-9]+}")

// closeEnoughCase reports whether the two demangled strings are close
// enough for our purposes. This code follows the GCC demangler, but
// the cases are from the LLVM demangler. There are irrelevant
// differences in spaces and parentheses that we accept.
func closeEnoughCase(a, b string) bool {
if strings.Contains(a, "lambda") && strings.Contains(b, "lambda") {
a = strings.ReplaceAll(a, "{lambda(", "'lambda'(")
b = strings.ReplaceAll(b, "{lambda(", "'lambda'(")
a = lambdaMatch.ReplaceAllString(a, "")
b = lambdaMatch.ReplaceAllString(b, "")
}

drop := func(r rune) rune {
switch r {
case ' ', '(', ')':
Expand Down

0 comments on commit 94bb783

Please sign in to comment.