Skip to content

Commit 487896e

Browse files
committed
Mangling: relax the re-mangling verification check a little bit.
There are cases where the re-mangling doesn't yield the original mangled name. This is no problem for the compiler as it only affects how mangling substitutions are handled. rdar://problem/31539542
1 parent 2584078 commit 487896e

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

lib/Basic/Mangler.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,20 @@ void Mangler::verify(const std::string &mangledName) {
163163
if (Remangled == mangledName)
164164
return;
165165

166-
if (treeContains(Root,
167-
Demangle::Node::Kind::DependentAssociatedTypeRef)) {
168-
// There are cases where dependent associated types results in different
169-
// remangled names. See ASTMangler::appendAssociatedTypeName.
170-
// This is no problem for the compiler, but we have to exclude this case
171-
// for the check. Instead we try to re-de-mangle the remangled name.
172-
nameStr = Remangled;
173-
NodePointer RootOfRemangled = Dem.demangleSymbol(nameStr);
174-
if (Remangled == mangleNode(RootOfRemangled))
175-
return;
176-
}
166+
// There are cases (e.g. with dependent associated types) which results in
167+
// different remangled names. See ASTMangler::appendAssociatedTypeName.
168+
// This is no problem for the compiler, but we have to be more tolerant for
169+
// those cases. Instead we try to re-de-mangle the remangled name.
170+
nameStr = Remangled;
171+
NodePointer RootOfRemangled = Dem.demangleSymbol(nameStr);
172+
std::string ReDemangled = mangleNode(RootOfRemangled);
173+
if (Remangled == ReDemangled)
174+
return;
175+
177176
llvm::errs() << "Remangling failed:\n"
178-
"original = " << nameStr << "\n"
179-
"remangled = " << Remangled << '\n';
177+
"original = " << nameStr << "\n"
178+
"remangled = " << Remangled << "\n"
179+
"re-demangled = " << ReDemangled << '\n';
180180
abort();
181181
#endif
182182
}

test/Demangle/Inputs/manglings.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,5 @@ _T0s10DictionaryV3t17E6Index2V1loiSbAEyxq__G_AGtFZ ---> static (extension in t17
249249
_T08mangling14varargsVsArrayySaySiG3arrd_SS1ntF ---> mangling.varargsVsArray (arr : Swift.Int..., n : Swift.String) -> ()
250250
_T08mangling14varargsVsArrayySaySiG3arrd_tF ---> mangling.varargsVsArray (arr : Swift.Int...) -> ()
251251
_T0s13_UnicodeViewsVss22RandomAccessCollectionRzs0A8EncodingR_11SubSequence_5IndexQZAFRtzsAcERpzAE_AEQZAIRSs15UnsignedInteger8Iterator_7ElementRPzAE_AlMQZANRS13EncodedScalar_AlMQY_AORSr0_lE13CharacterViewVyxq__G ---> (extension in Swift):Swift._UnicodeViews<A, B><A, B where A: Swift.RandomAccessCollection, B: Swift.UnicodeEncoding, A.Index == A.SubSequence.Index, A.SubSequence: Swift.RandomAccessCollection, A.SubSequence == A.SubSequence.SubSequence, A.Iterator.Element: Swift.UnsignedInteger, A.Iterator.Element == A.SubSequence.Iterator.Element, A.SubSequence.Iterator.Element == B.EncodedScalar.Iterator.Element>.CharacterView
252+
_T010Foundation11MeasurementV12SimulatorKitSo9UnitAngleCRszlE11OrientationO2eeoiSbAcDEAGOyAF_G_AKtFZ ---> static (extension in SimulatorKit):Foundation.Measurement<A where A == __ObjC.UnitAngle>.Orientation.== infix ((extension in SimulatorKit):Foundation.Measurement<__ObjC.UnitAngle>.Orientation, (extension in SimulatorKit):Foundation.Measurement<__ObjC.UnitAngle>.Orientation) -> Swift.Bool
252253

0 commit comments

Comments
 (0)