From d39c594d39df7f283c2fb8a704a3f31c501180d9 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Fri, 17 Sep 2010 15:48:55 +0000 Subject: Vendor import of llvm r114020 (from the release_28 branch): http://llvm.org/svn/llvm-project/llvm/branches/release_28@114020 Approved by: rpaulo (mentor) --- include/llvm/Support/CommandLine.h | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'include/llvm/Support/CommandLine.h') diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 61c3256d38454..9ae3d6af32ee8 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -31,7 +31,7 @@ #include namespace llvm { - + /// cl Namespace - This namespace contains all of the command line option /// processing machinery. It is intentionally a short name to make qualified /// usage concise. @@ -443,16 +443,23 @@ protected: template class parser : public generic_parser_base { protected: - SmallVector >, 8> Values; + class OptionInfo { + public: + OptionInfo(const char *name, DataType v, const char *helpStr) : + Name(name), V(v), HelpStr(helpStr) {} + const char *Name; + DataType V; + const char *HelpStr; + }; + SmallVector Values; public: typedef DataType parser_data_type; // Implement virtual functions needed by generic_parser_base unsigned getNumOptions() const { return unsigned(Values.size()); } - const char *getOption(unsigned N) const { return Values[N].first; } + const char *getOption(unsigned N) const { return Values[N].Name; } const char *getDescription(unsigned N) const { - return Values[N].second.second; + return Values[N].HelpStr; } // parse - Return true on error. @@ -465,8 +472,8 @@ public: for (unsigned i = 0, e = static_cast(Values.size()); i != e; ++i) - if (Values[i].first == ArgVal) { - V = Values[i].second.first; + if (Values[i].Name == ArgVal) { + V = Values[i].V; return false; } @@ -478,8 +485,8 @@ public: template void addLiteralOption(const char *Name, const DT &V, const char *HelpStr) { assert(findOption(Name) == Values.size() && "Option already exists!"); - Values.push_back(std::make_pair(Name, - std::make_pair(static_cast(V),HelpStr))); + OptionInfo X(Name, static_cast(V), HelpStr); + Values.push_back(X); MarkOptionsChanged(); } @@ -781,7 +788,7 @@ public: DataType &getValue() { check(); return *Location; } const DataType &getValue() const { check(); return *Location; } - + operator DataType() const { return this->getValue(); } }; -- cgit v1.2.3