From 8fe960ed50d3ad39d2a45f960ed8b9a69268035a Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 19 Jun 2013 14:58:16 +0000 Subject: [PATCH] Remove the 'R' modifier. It is not present in GNU or OS X versions and doesn't make a lot of sense for llvm-ar. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184306 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Archive/directory.ll | 2 ++ tools/llvm-ar/llvm-ar.cpp | 49 ++++----------------------------------- 2 files changed, 6 insertions(+), 45 deletions(-) create mode 100644 test/Archive/directory.ll diff --git a/test/Archive/directory.ll b/test/Archive/directory.ll new file mode 100644 index 00000000000..f17ac5d36bd --- /dev/null +++ b/test/Archive/directory.ll @@ -0,0 +1,2 @@ +;RUN: not llvm-ar r %T/test.a . 2>&1 | FileCheck %s +;CHECK: . Is a directory diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index 2a4a3deecdd..792b46bded0 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -96,7 +96,6 @@ bool DontSkipBitcode = false; ///< 'k' modifier bool UseCount = false; ///< 'N' modifier bool OriginalDates = false; ///< 'o' modifier bool FullPath = false; ///< 'P' modifier -bool RecurseDirectories = false; ///< 'R' modifier bool SymTable = true; ///< 's' & 'S' modifiers bool OnlyUpdate = false; ///< 'u' modifier bool Verbose = false; ///< 'v' modifier @@ -218,7 +217,6 @@ ArchiveOperation parseCommandLine() { case 'l': /* accepted but unused */ break; case 'o': OriginalDates = true; break; case 'P': FullPath = true; break; - case 'R': RecurseDirectories = true; break; case 's': SymTable = true; break; case 'S': SymTable = false; break; case 'u': OnlyUpdate = true; break; @@ -268,8 +266,6 @@ ArchiveOperation parseCommandLine() { show_help("The 'a', 'b' and 'i' modifiers can only be specified with " "the 'm' or 'r' operations"); } - if (RecurseDirectories && Operation != ReplaceOrInsert) - show_help("The 'R' modifiers is only applicabe to the 'r' operation"); if (OriginalDates && Operation != Extract) show_help("The 'o' modifier is only applicable to the 'x' operation"); if (TruncateNames && Operation!=QuickAppend && Operation!=ReplaceOrInsert) @@ -284,39 +280,6 @@ ArchiveOperation parseCommandLine() { return Operation; } -// recurseDirectories - Implements the "R" modifier. This function scans through -// the Paths vector (built by buildPaths, below) and replaces any directories it -// finds with all the files in that directory (recursively). It uses the -// sys::Path::getDirectoryContent method to perform the actual directory scans. -bool -recurseDirectories(const sys::Path& path, - std::set& result, std::string* ErrMsg) { - result.clear(); - if (RecurseDirectories) { - std::set content; - if (path.getDirectoryContents(content, ErrMsg)) - return true; - - for (std::set::iterator I = content.begin(), E = content.end(); - I != E; ++I) { - // Make sure it exists and is a directory - sys::PathWithStatus PwS(*I); - const sys::FileStatus *Status = PwS.getFileStatus(false, ErrMsg); - if (!Status) - return true; - if (Status->isDir) { - std::set moreResults; - if (recurseDirectories(*I, moreResults, ErrMsg)) - return true; - result.insert(moreResults.begin(), moreResults.end()); - } else { - result.insert(*I); - } - } - } - return false; -} - // buildPaths - Convert the strings in the Members vector to sys::Path objects // and make sure they are valid and exist exist. This check is only needed for // the operations that add/replace files to the archive ('q' and 'r') @@ -334,14 +297,10 @@ bool buildPaths(bool checkExistence, std::string* ErrMsg) { const sys::FileStatus *si = PwS.getFileStatus(false, &Err); if (!si) fail(Err); - if (si->isDir) { - std::set dirpaths; - if (recurseDirectories(aPath, dirpaths, ErrMsg)) - return true; - Paths.insert(dirpaths.begin(),dirpaths.end()); - } else { - Paths.insert(aPath); - } + if (si->isDir) + fail(aPath.str() + " Is a directory"); + + Paths.insert(aPath); } else { Paths.insert(aPath); }