Skip to content

Commit 1b8d0fa

Browse files
authored
Merge pull request swiftlang#27992 from compnerd/subscript-off-by-one
Basic: avoid an assertion on Windows
2 parents d6a5570 + 41e28a8 commit 1b8d0fa

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)