summaryrefslogtreecommitdiffstats
path: root/llvm/include/llvm/Support/CommandLine.h
diff options
context:
space:
mode:
authorDon Hinton <hintonda@gmail.com>2019-04-30 00:09:49 +0000
committerDon Hinton <hintonda@gmail.com>2019-04-30 00:09:49 +0000
commitcabf1e22992655e0296f033f63191935954a85fa (patch)
treefb78b32ca1057cfe4d90d7c15c94d11e121dc80a /llvm/include/llvm/Support/CommandLine.h
parentb12867230cd84a3cf9d451a8b25f55789cc59bb3 (diff)
downloadbcm5719-llvm-cabf1e22992655e0296f033f63191935954a85fa.tar.gz
bcm5719-llvm-cabf1e22992655e0296f033f63191935954a85fa.zip
[CommandLine} Wire-up cl::list::setDefault() so it will work correctly with cl::ResetAllOptionOccurrences() in unittests. Part 2 of 5
Summary: With this change, cl::ResetAllOptionOccurrences() clears cl::list just like cl::opt, allowing users to call cl::ParseCommandLineOptions() multiple times without interference from previous calls. Reviewers: rnk Reviewed By: rnk Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61234 llvm-svn: 359522
Diffstat (limited to 'llvm/include/llvm/Support/CommandLine.h')
-rw-r--r--llvm/include/llvm/Support/CommandLine.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h
index a62e2eba0a9..1fc26420fe6 100644
--- a/llvm/include/llvm/Support/CommandLine.h
+++ b/llvm/include/llvm/Support/CommandLine.h
@@ -1425,6 +1425,8 @@ template <class DataType, class StorageClass> class list_storage {
public:
list_storage() = default;
+ void clear() {}
+
bool setLocation(Option &O, StorageClass &L) {
if (Location)
return O.error("cl::location(x) specified more than once!");
@@ -1476,6 +1478,10 @@ public:
reference operator[](size_type pos) { return Storage[pos]; }
const_reference operator[](size_type pos) const { return Storage[pos]; }
+ void clear() {
+ Storage.clear();
+ }
+
iterator erase(const_iterator pos) { return Storage.erase(pos); }
iterator erase(const_iterator first, const_iterator last) {
return Storage.erase(first, last);
@@ -1553,7 +1559,10 @@ class list : public Option, public list_storage<DataType, StorageClass> {
void printOptionValue(size_t /*GlobalWidth*/, bool /*Force*/) const override {
}
- void setDefault() override {}
+ void setDefault() override {
+ Positions.clear();
+ list_storage<DataType, StorageClass>::clear();
+ }
void done() {
addArgument();
OpenPOWER on IntegriCloud