@@ -186,28 +186,6 @@ ObjcCategoryChecker::ObjcCategoryChecker()
186
186
roClassLayout(target->wordSize), listHeaderLayout(target->wordSize),
187
187
methodLayout(target->wordSize) {}
188
188
189
- // \p r must point to an offset within a CStringInputSection or a
190
- // ConcatInputSection
191
- static StringRef getReferentString (const Reloc &r) {
192
- if (auto *isec = r.referent .dyn_cast <InputSection *>())
193
- return cast<CStringInputSection>(isec)->getStringRefAtOffset (r.addend );
194
-
195
- auto *sym = cast<Defined>(r.referent .get <Symbol *>());
196
- auto *symIsec = sym->isec ();
197
- auto symOffset = sym->value + r.addend ;
198
-
199
- if (auto *s = dyn_cast_or_null<CStringInputSection>(symIsec))
200
- return s->getStringRefAtOffset (symOffset);
201
-
202
- if (isa<ConcatInputSection>(symIsec)) {
203
- auto strData = symIsec->data .slice (symOffset);
204
- const char *pszData = reinterpret_cast <const char *>(strData.data ());
205
- return StringRef (pszData, strnlen (pszData, strData.size ()));
206
- }
207
-
208
- llvm_unreachable (" unknown reference section in getReferentString" );
209
- }
210
-
211
189
void ObjcCategoryChecker::parseMethods (const ConcatInputSection *methodsIsec,
212
190
const Symbol *methodContainerSym,
213
191
const ConcatInputSection *containerIsec,
@@ -219,7 +197,7 @@ void ObjcCategoryChecker::parseMethods(const ConcatInputSection *methodsIsec,
219
197
methodLayout.nameOffset )
220
198
continue ;
221
199
222
- CachedHashStringRef methodName (getReferentString (r ));
200
+ CachedHashStringRef methodName (r. getReferentString ());
223
201
// +load methods are special: all implementations are called by the runtime
224
202
// even if they are part of the same class. Thus there is no need to check
225
203
// for duplicates.
@@ -251,14 +229,14 @@ void ObjcCategoryChecker::parseMethods(const ConcatInputSection *methodsIsec,
251
229
->getReferentInputSection ();
252
230
nameReloc = roIsec->getRelocAt (roClassLayout.nameOffset );
253
231
}
254
- StringRef containerName = getReferentString (*nameReloc );
232
+ StringRef containerName = nameReloc-> getReferentString ();
255
233
StringRef methPrefix = mKind == MK_Instance ? " -" : " +" ;
256
234
257
235
// We should only ever encounter collisions when parsing category methods
258
236
// (since the Class struct is parsed before any of its categories).
259
237
assert (mcKind == MCK_Category);
260
238
StringRef newCatName =
261
- getReferentString (* containerIsec->getRelocAt (catLayout.nameOffset ));
239
+ containerIsec->getRelocAt (catLayout.nameOffset )-> getReferentString ( );
262
240
263
241
auto formatObjAndSrcFileName = [](const InputSection *section) {
264
242
lld::macho::InputFile *inputFile = section->getFile ();
@@ -809,7 +787,7 @@ void ObjcCategoryMerger::parseCatInfoToExtInfo(const InfoInputCategory &catInfo,
809
787
assert (extInfo.objFileForMergeData &&
810
788
" Expected to already have valid objextInfo.objFileForMergeData" );
811
789
812
- StringRef catName = getReferentString (*catNameReloc );
790
+ StringRef catName = catNameReloc-> getReferentString ();
813
791
extInfo.mergedContainerName += catName.str ();
814
792
815
793
// Parse base class
0 commit comments