[llvm] r242347 - For new archive member we only need to store the full path.
Rafael Espindola
rafael.espindola at gmail.com
Wed Jul 15 15:46:54 PDT 2015
Author: rafael
Date: Wed Jul 15 17:46:53 2015
New Revision: 242347
URL: http://llvm.org/viewvc/llvm-project?rev=242347&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/Object/ArchiveWriter.h
llvm/trunk/lib/LibDriver/LibDriver.cpp
llvm/trunk/lib/Object/ArchiveWriter.cpp
llvm/trunk/tools/llvm-ar/llvm-ar.cpp
Modified: llvm/trunk/include/llvm/Object/ArchiveWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ArchiveWriter.h?rev=242347&r1=242346&r2=242347&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ArchiveWriter.h (original)
+++ llvm/trunk/include/llvm/Object/ArchiveWriter.h Wed Jul 15 17:46:53 2015
@@ -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;
Modified: llvm/trunk/lib/LibDriver/LibDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LibDriver/LibDriver.cpp?rev=242347&r1=242346&r2=242347&view=diff
==============================================================================
--- llvm/trunk/lib/LibDriver/LibDriver.cpp (original)
+++ llvm/trunk/lib/LibDriver/LibDriver.cpp Wed Jul 15 17:46:53 2015
@@ -135,8 +135,7 @@ int llvm::libDriverMain(llvm::ArrayRef<c
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 =
Modified: llvm/trunk/lib/Object/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ArchiveWriter.cpp?rev=242347&r1=242346&r2=242347&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Object/ArchiveWriter.cpp Wed Jul 15 17:46:53 2015
@@ -38,8 +38,8 @@ NewArchiveIterator::NewArchiveIterator(o
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 NewArchi
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);
Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=242347&r1=242346&r2=242347&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Wed Jul 15 17:46:53 2015
@@ -437,8 +437,8 @@ static void performReadOperation(Archive
}
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(ArchiveOperatio
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(ArchiveOperatio
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(ArchiveOperatio
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;
More information about the llvm-commits
mailing list