Skip to content

Commit 41e28a8

Browse files
committed
Basic: avoid an assertion on Windows
The order of evaluation of the subscript operator would increase the count of map, resulting in the decoration to be off by one. This enables building the swift standard library on Windows again.
1 parent 6acf8db commit 41e28a8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

include/swift/Basic/Mangler.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,18 @@ class Mangler {
124124
void appendIdentifier(StringRef ident);
125125

126126
void addSubstitution(const void *ptr) {
127-
if (UseSubstitutions)
128-
Substitutions[ptr] = Substitutions.size() + StringSubstitutions.size();
127+
if (!UseSubstitutions)
128+
return;
129+
130+
auto value = Substitutions.size() + StringSubstitutions.size();
131+
Substitutions[ptr] = value;
129132
}
130133
void addSubstitution(StringRef Str) {
131-
if (UseSubstitutions)
132-
StringSubstitutions[Str] = Substitutions.size() + StringSubstitutions.size();
134+
if (!UseSubstitutions)
135+
return;
136+
137+
auto value = Substitutions.size() + StringSubstitutions.size();
138+
StringSubstitutions[Str] = value;
133139
}
134140

135141
bool tryMangleSubstitution(const void *ptr);

0 commit comments

Comments
 (0)