mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 12:19:53 +00:00
For new archive member we only need to store the full path.
We were storing both the path and the file name, which was redundant and easy to get confused up with. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242347 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c2fa6d64b4
commit
ba7661d294
@ -26,11 +26,9 @@ class NewArchiveIterator {
|
||||
|
||||
object::Archive::child_iterator OldI;
|
||||
|
||||
StringRef NewFilename;
|
||||
|
||||
public:
|
||||
NewArchiveIterator(object::Archive::child_iterator I, StringRef Name);
|
||||
NewArchiveIterator(StringRef I, StringRef Name);
|
||||
NewArchiveIterator(StringRef FileName);
|
||||
bool isNewMember() const;
|
||||
StringRef getName() const;
|
||||
|
||||
|
@ -135,8 +135,7 @@ int llvm::libDriverMain(llvm::ArrayRef<const char*> ArgsArr) {
|
||||
llvm::errs() << Arg->getValue() << ": no such file or directory\n";
|
||||
return 1;
|
||||
}
|
||||
Members.emplace_back(Saver.save(*Path),
|
||||
llvm::sys::path::filename(Arg->getValue()));
|
||||
Members.emplace_back(Saver.save(*Path));
|
||||
}
|
||||
|
||||
std::pair<StringRef, std::error_code> Result =
|
||||
|
@ -38,8 +38,8 @@ NewArchiveIterator::NewArchiveIterator(object::Archive::child_iterator I,
|
||||
StringRef Name)
|
||||
: IsNewMember(false), Name(Name), OldI(I) {}
|
||||
|
||||
NewArchiveIterator::NewArchiveIterator(StringRef NewFilename, StringRef Name)
|
||||
: IsNewMember(true), Name(Name), NewFilename(NewFilename) {}
|
||||
NewArchiveIterator::NewArchiveIterator(StringRef FileName)
|
||||
: IsNewMember(true), Name(FileName) {}
|
||||
|
||||
StringRef NewArchiveIterator::getName() const { return Name; }
|
||||
|
||||
@ -52,14 +52,14 @@ object::Archive::child_iterator NewArchiveIterator::getOld() const {
|
||||
|
||||
StringRef NewArchiveIterator::getNew() const {
|
||||
assert(IsNewMember);
|
||||
return NewFilename;
|
||||
return Name;
|
||||
}
|
||||
|
||||
llvm::ErrorOr<int>
|
||||
NewArchiveIterator::getFD(sys::fs::file_status &NewStatus) const {
|
||||
assert(IsNewMember);
|
||||
int NewFD;
|
||||
if (auto EC = sys::fs::openFileForRead(NewFilename, NewFD))
|
||||
if (auto EC = sys::fs::openFileForRead(Name, NewFD))
|
||||
return EC;
|
||||
assert(NewFD != -1);
|
||||
|
||||
|
@ -437,8 +437,8 @@ static void performReadOperation(ArchiveOperation Operation,
|
||||
}
|
||||
|
||||
void addMember(std::vector<NewArchiveIterator> &Members, StringRef FileName,
|
||||
StringRef Name, int Pos = -1) {
|
||||
NewArchiveIterator NI(FileName, Name);
|
||||
int Pos = -1) {
|
||||
NewArchiveIterator NI(FileName);
|
||||
if (Pos == -1)
|
||||
Members.push_back(NI);
|
||||
else
|
||||
@ -544,7 +544,7 @@ computeNewArchiveMembers(ArchiveOperation Operation,
|
||||
addMember(Ret, Child, Name);
|
||||
break;
|
||||
case IA_AddNewMeber:
|
||||
addMember(Ret, *MemberI, Name);
|
||||
addMember(Ret, *MemberI);
|
||||
break;
|
||||
case IA_Delete:
|
||||
break;
|
||||
@ -552,7 +552,7 @@ computeNewArchiveMembers(ArchiveOperation Operation,
|
||||
addMember(Moved, Child, Name);
|
||||
break;
|
||||
case IA_MoveNewMember:
|
||||
addMember(Moved, *MemberI, Name);
|
||||
addMember(Moved, *MemberI);
|
||||
break;
|
||||
}
|
||||
if (MemberI != Members.end())
|
||||
@ -572,12 +572,10 @@ computeNewArchiveMembers(ArchiveOperation Operation,
|
||||
assert(unsigned(InsertPos) <= Ret.size());
|
||||
Ret.insert(Ret.begin() + InsertPos, Moved.begin(), Moved.end());
|
||||
|
||||
Ret.insert(Ret.begin() + InsertPos, Members.size(),
|
||||
NewArchiveIterator("", ""));
|
||||
Ret.insert(Ret.begin() + InsertPos, Members.size(), NewArchiveIterator(""));
|
||||
int Pos = InsertPos;
|
||||
for (auto &Member : Members) {
|
||||
StringRef Name = sys::path::filename(Member);
|
||||
addMember(Ret, Member, Name, Pos);
|
||||
addMember(Ret, Member, Pos);
|
||||
++Pos;
|
||||
}
|
||||
|
||||
@ -736,7 +734,7 @@ static void runMRIScript() {
|
||||
break;
|
||||
}
|
||||
case MRICommand::AddMod:
|
||||
addMember(NewMembers, Rest, sys::path::filename(Rest));
|
||||
addMember(NewMembers, Rest);
|
||||
break;
|
||||
case MRICommand::Create:
|
||||
Create = true;
|
||||
|
Loading…
Reference in New Issue
Block a user