@@ -402,33 +402,30 @@ void LinkerScript::assignSymbol(SymbolAssignment *cmd, bool inSec) {
402402 cmd->sym ->type = v.type ;
403403}
404404
405- static inline StringRef getFilename (const InputFile *file) {
406- return file ? file->getNameForScript () : StringRef ();
407- }
408-
409- bool InputSectionDescription::matchesFile (const InputFile *file) const {
405+ bool InputSectionDescription::matchesFile (const InputFile &file) const {
410406 if (filePat.isTrivialMatchAll ())
411407 return true ;
412408
413- if (!matchesFileCache || matchesFileCache->first != file)
414- matchesFileCache.emplace (file, filePat.match (getFilename ( file)));
409+ if (!matchesFileCache || matchesFileCache->first != & file)
410+ matchesFileCache.emplace (& file, filePat.match (file. getNameForScript ( )));
415411
416412 return matchesFileCache->second ;
417413}
418414
419- bool SectionPattern::excludesFile (const InputFile * file) const {
415+ bool SectionPattern::excludesFile (const InputFile & file) const {
420416 if (excludedFilePat.empty ())
421417 return false ;
422418
423- if (!excludesFileCache || excludesFileCache->first != file)
424- excludesFileCache.emplace (file, excludedFilePat.match (getFilename (file)));
419+ if (!excludesFileCache || excludesFileCache->first != &file)
420+ excludesFileCache.emplace (&file,
421+ excludedFilePat.match (file.getNameForScript ()));
425422
426423 return excludesFileCache->second ;
427424}
428425
429426bool LinkerScript::shouldKeep (InputSectionBase *s) {
430427 for (InputSectionDescription *id : keptSections)
431- if (id->matchesFile (s->file ))
428+ if (id->matchesFile (* s->file ))
432429 for (SectionPattern &p : id->sectionPatterns )
433430 if (p.sectionPat .match (s->name ) &&
434431 (s->flags & id->withFlags ) == id->withFlags &&
@@ -557,7 +554,7 @@ LinkerScript::computeInputSections(const InputSectionDescription *cmd,
557554 if (!pat.sectionPat .match (sec->name ))
558555 continue ;
559556
560- if (!cmd->matchesFile (sec->file ) || pat.excludesFile (sec->file ) ||
557+ if (!cmd->matchesFile (* sec->file ) || pat.excludesFile (* sec->file ) ||
561558 sec->parent == &outCmd || !flagsMatch (sec))
562559 continue ;
563560
0 commit comments