File tree Expand file tree Collapse file tree 4 files changed +26
-6
lines changed
Expand file tree Collapse file tree 4 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,14 @@ class Mangler {
7878 }
7979 };
8080
81+ void addSubstWordsInIdent (const WordReplacement &repl) {
82+ SubstWordsInIdent.push_back (repl);
83+ }
84+
85+ void addWord (const SubstitutionWord &word) {
86+ Words.push_back (word);
87+ }
88+
8189 // / Returns the buffer as a StringRef, needed by mangleIdentifier().
8290 StringRef getBufferStr () const {
8391 return StringRef (Storage.data (), Storage.size ());
Original file line number Diff line number Diff line change @@ -279,7 +279,11 @@ template<typename T> class Vector {
279279 Capacity = 0 ;
280280 Elems = 0 ;
281281 }
282-
282+
283+ void clear () {
284+ NumElems = 0 ;
285+ }
286+
283287 iterator begin () { return Elems; }
284288 iterator end () { return Elems + NumElems; }
285289
Original file line number Diff line number Diff line change @@ -160,13 +160,13 @@ void mangleIdentifier(Mangler &M, StringRef ident) {
160160 if (WordIdx >= 0 ) {
161161 // We found a word substitution!
162162 assert (WordIdx < 26 );
163- M.SubstWordsInIdent . push_back ({wordStartPos, WordIdx});
163+ M.addSubstWordsInIdent ({wordStartPos, WordIdx});
164164 } else if (wordLen >= 2 && M.Words .size () < M.MaxNumWords ) {
165165 // It's a new word: remember it.
166166 // Note: at this time the word's start position is relative to the
167167 // begin of the identifier. We must update it afterwards so that it is
168168 // relative to the begin of the whole mangled Buffer.
169- M.Words . push_back ({wordStartPos, wordLen});
169+ M.addWord ({wordStartPos, wordLen});
170170 }
171171 wordStartPos = NotInsideWord;
172172 }
@@ -181,7 +181,7 @@ void mangleIdentifier(Mangler &M, StringRef ident) {
181181
182182 size_t Pos = 0 ;
183183 // Add a dummy-word at the end of the list.
184- M.SubstWordsInIdent . push_back ({ident.size (), -1 });
184+ M.addSubstWordsInIdent ({ident.size (), -1 });
185185
186186 // Mangle a sequence of word substitutions and sub-strings.
187187 for (size_t Idx = 0 , End = M.SubstWordsInIdent .size (); Idx < End; ++Idx) {
Original file line number Diff line number Diff line change @@ -155,8 +155,8 @@ class Remangler {
155155
156156 DemanglerPrinter &Buffer;
157157
158- std::vector <SubstitutionWord> Words;
159- std::vector <WordReplacement> SubstWordsInIdent;
158+ Vector <SubstitutionWord> Words;
159+ Vector <WordReplacement> SubstWordsInIdent;
160160
161161 static const size_t MaxNumWords = 26 ;
162162
@@ -172,6 +172,14 @@ class Remangler {
172172 // A callback for resolving symbolic references.
173173 SymbolicResolver Resolver;
174174
175+ void addSubstWordsInIdent (const WordReplacement &repl) {
176+ SubstWordsInIdent.push_back (repl, Factory);
177+ }
178+
179+ void addWord (const SubstitutionWord &word) {
180+ Words.push_back (word, Factory);
181+ }
182+
175183 StringRef getBufferStr () const { return Buffer.getStringRef (); }
176184
177185 void resetBuffer (size_t toPos) { Buffer.resetSize (toPos); }
You can’t perform that action at this time.
0 commit comments