1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Pete Cooper suggested the new API should use ArrayRef instead of SmallVectorImpl. Also adding a test case.

llvm-svn: 227148
This commit is contained in:
Chris Bieneman 2015-01-26 22:50:47 +00:00
parent 2b71db1121
commit 4f9237ff63
3 changed files with 27 additions and 3 deletions

View File

@ -20,6 +20,7 @@
#ifndef LLVM_SUPPORT_COMMANDLINE_H
#define LLVM_SUPPORT_COMMANDLINE_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/Twine.h"
@ -1938,7 +1939,7 @@ void HideUnrelatedOptions(cl::OptionCategory &Category);
/// Some tools (like clang-format) like to be able to hide all options that are
/// not specific to the tool. This function allows a tool to specify a single
/// option category to display in the -help output.
void HideUnrelatedOptions(SmallVectorImpl<cl::OptionCategory *> &Categories);
void HideUnrelatedOptions(ArrayRef<cl::OptionCategory *> Categories);
} // End namespace cl

View File

@ -1861,8 +1861,7 @@ void cl::HideUnrelatedOptions(cl::OptionCategory &Category) {
}
}
void cl::HideUnrelatedOptions(
SmallVectorImpl<cl::OptionCategory *> &Categories) {
void cl::HideUnrelatedOptions(ArrayRef<cl::OptionCategory *> Categories) {
auto CategoriesBegin = Categories.begin();
auto CategoriesEnd = Categories.end();
StringMap<cl::Option *> Options;

View File

@ -247,4 +247,28 @@ TEST(CommandLineTest, HideUnrelatedOptions) {
<< "Hid default option that should be visable.";
}
cl::OptionCategory TestCategory2("Test Options set 2", "Description");
TEST(CommandLineTest, HideUnrelatedOptionsMulti) {
cl::opt<int> TestOption1("test-option-1");
cl::opt<int> TestOption2("test-option-2", cl::cat(TestCategory));
cl::opt<int> TestOption3("test-option-3", cl::cat(TestCategory2));
cl::OptionCategory *VisibleCategories[] = {&TestCategory, &TestCategory2};
cl::HideUnrelatedOptions(makeArrayRef(VisibleCategories));
ASSERT_EQ(cl::ReallyHidden, TestOption1.getOptionHiddenFlag())
<< "Failed to hide extra option.";
ASSERT_EQ(cl::NotHidden, TestOption2.getOptionHiddenFlag())
<< "Hid extra option that should be visable.";
ASSERT_EQ(cl::NotHidden, TestOption3.getOptionHiddenFlag())
<< "Hid extra option that should be visable.";
StringMap<cl::Option *> Map;
cl::getRegisteredOptions(Map);
ASSERT_EQ(cl::NotHidden, Map["help"]->getOptionHiddenFlag())
<< "Hid default option that should be visable.";
}
} // anonymous namespace