X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FSupport%2FCommandLine.cpp;h=40570cab7cc881a34f13e61026f1c573f6a08b35;hb=33943f870fcd9c8b49bab21ca66e8b5d8bbacf81;hp=b2bb7466c11237754af4633cc374864174d0cbe6;hpb=d5132f907367b43d43108bd4367dbbcb650f98ce;p=oota-llvm.git diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index b2bb7466c11..40570cab7cc 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -17,6 +17,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/CommandLine.h" +#include "llvm-c/Support.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallString.h" @@ -43,7 +44,8 @@ using namespace cl; //===----------------------------------------------------------------------===// // Template instantiations and anchors. // -namespace llvm { namespace cl { +namespace llvm { +namespace cl { TEMPLATE_INSTANTIATION(class basic_parser); TEMPLATE_INSTANTIATION(class basic_parser); TEMPLATE_INSTANTIATION(class basic_parser); @@ -59,7 +61,8 @@ TEMPLATE_INSTANTIATION(class opt); TEMPLATE_INSTANTIATION(class opt); TEMPLATE_INSTANTIATION(class opt); TEMPLATE_INSTANTIATION(class opt); -} } // end namespace llvm::cl +} +} // end namespace llvm::cl // Pin the vtables to this file. void GenericOptionValue::anchor() {} @@ -86,19 +89,16 @@ static char ProgramName[80] = ""; static const char *ProgramOverview = nullptr; // This collects additional help to be printed. -static ManagedStatic > MoreHelp; +static ManagedStatic> MoreHelp; -extrahelp::extrahelp(const char *Help) - : morehelp(Help) { +extrahelp::extrahelp(const char *Help) : morehelp(Help) { MoreHelp->push_back(Help); } static bool OptionListChanged = false; // MarkOptionsChanged - Internal helper function. -void cl::MarkOptionsChanged() { - OptionListChanged = true; -} +void cl::MarkOptionsChanged() { OptionListChanged = true; } /// RegisteredOptionList - This is the list of the command line options that /// have statically constructed themselves. @@ -113,14 +113,20 @@ void Option::addArgument() { } void Option::removeArgument() { - assert(NextRegistered && "argument never registered"); - assert(RegisteredOptionList == this && "argument is not the last registered"); - RegisteredOptionList = NextRegistered; + if (RegisteredOptionList == this) { + RegisteredOptionList = NextRegistered; + MarkOptionsChanged(); + return; + } + Option *O = RegisteredOptionList; + for (; O->NextRegistered != this; O = O->NextRegistered) + ; + O->NextRegistered = NextRegistered; MarkOptionsChanged(); } // This collects the different option categories that have been registered. -typedef SmallPtrSet OptionCatSet; +typedef SmallPtrSet OptionCatSet; static ManagedStatic RegisteredOptionCategories; // Initialise the general option category. @@ -131,7 +137,8 @@ void OptionCategory::registerCategory() { RegisteredOptionCategories->end(), [this](const OptionCategory *Category) { return getName() == Category->getName(); - }) == 0 && "Duplicate option categories"); + }) == 0 && + "Duplicate option categories"); RegisteredOptionCategories->insert(this); } @@ -142,11 +149,12 @@ void OptionCategory::registerCategory() { /// GetOptionInfo - Scan the list of registered options, turning them into data /// structures that are easier to handle. -static void GetOptionInfo(SmallVectorImpl &PositionalOpts, - SmallVectorImpl &SinkOpts, - StringMap &OptionsMap) { - SmallVector OptionNames; - Option *CAOpt = nullptr; // The ConsumeAfter option if it exists. +static void GetOptionInfo(SmallVectorImpl