]> granicus.if.org Git - llvm/commitdiff
[llvm-ar] Simplify and make two global variables static. NFC
authorFangrui Song <maskray@google.com>
Thu, 17 Oct 2019 06:15:34 +0000 (06:15 +0000)
committerFangrui Song <maskray@google.com>
Thu, 17 Oct 2019 06:15:34 +0000 (06:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375082 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-ar/llvm-ar.cpp

index 70e21dfe636c4a566ee9dd21bd8e418df88967e6..6233c60e9bdc60687000a7afdbf97f8e5c8cc3ad 100644 (file)
@@ -214,6 +214,9 @@ static int CountParam = 0;
 // command line.
 static std::string ArchiveName;
 
+static std::vector<std::unique_ptr<MemoryBuffer>> ArchiveBuffers;
+static std::vector<std::unique_ptr<object::Archive>> Archives;
+
 // This variable holds the list of member files to proecess, as given
 // on the command line.
 static std::vector<StringRef> Members;
@@ -251,15 +254,6 @@ static void getArchive() {
   PositionalArgs.erase(PositionalArgs.begin());
 }
 
-// Copy over remaining items in PositionalArgs to our Members vector
-static void getMembers() {
-  for (auto &Arg : PositionalArgs)
-    Members.push_back(Arg);
-}
-
-std::vector<std::unique_ptr<MemoryBuffer>> ArchiveBuffers;
-std::vector<std::unique_ptr<object::Archive>> Archives;
-
 static object::Archive &readLibrary(const Twine &Library) {
   auto BufOrErr = MemoryBuffer::getFile(Library, -1, false);
   failIfError(BufOrErr.getError(), "could not open library " + Library);
@@ -399,7 +393,7 @@ static ArchiveOperation parseCommandLine() {
   getArchive();
 
   // Everything on the command line at this point is a member.
-  getMembers();
+  Members.assign(PositionalArgs.begin(), PositionalArgs.end());
 
   if (NumOperations == 0 && MaybeJustCreateSymTab) {
     NumOperations = 1;