Merge changes to clang's Driver code into LLVM's Option library

This is in preparation for switching the clang driver over to using LLVM's
Option library.  Richard Smith introduced most of these changes to the clang
driver in r167638.

Reviewers: espindola on IRC

Differential Revision: http://llvm-reviews.chandlerc.com/D970

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183925 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Kleckner
2013-06-13 18:12:12 +00:00
parent a65ee83ea9
commit 1ee21dc1e1
4 changed files with 45 additions and 11 deletions

View File

@@ -160,10 +160,6 @@ const Option OptTable::getOption(OptSpecifier Opt) const {
return Option(&getInfo(id), this);
}
bool OptTable::isOptionHelpHidden(OptSpecifier id) const {
return getInfo(id).Flags & HelpHidden;
}
static bool isInput(const llvm::StringSet<> &Prefixes, StringRef Arg) {
if (Arg == "-")
return true;
@@ -346,8 +342,16 @@ static const char *getOptionHelpGroup(const OptTable &Opts, OptSpecifier Id) {
return getOptionHelpGroup(Opts, GroupID);
}
void OptTable::PrintHelp(raw_ostream &OS, const char *Name,
const char *Title, bool ShowHidden) const {
void OptTable::PrintHelp(raw_ostream &OS, const char *Name, const char *Title,
bool ShowHidden) const {
PrintHelp(OS, Name, Title, /*Include*/ 0, /*Exclude*/
(ShowHidden ? 0 : HelpHidden));
}
void OptTable::PrintHelp(raw_ostream &OS, const char *Name, const char *Title,
unsigned FlagsToInclude,
unsigned FlagsToExclude) const {
OS << "OVERVIEW: " << Title << "\n";
OS << '\n';
OS << "USAGE: " << Name << " [options] <inputs>\n";
@@ -366,7 +370,10 @@ void OptTable::PrintHelp(raw_ostream &OS, const char *Name,
if (getOptionKind(Id) == Option::GroupClass)
continue;
if (!ShowHidden && isOptionHelpHidden(Id))
unsigned Flags = getInfo(Id).Flags;
if (FlagsToInclude && !(Flags & FlagsToInclude))
continue;
if (Flags & FlagsToExclude)
continue;
if (const char *Text = getOptionHelpText(Id)) {