aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/CommandLineTest.cpp
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2018-05-15 13:43:20 +0000
committerEric Liu <ioeric@google.com>2018-05-15 13:43:20 +0000
commit5390e36953c08bd2b975c9b13964114b51248fa1 (patch)
treebb6cf99bd70a38651450b8d56f317828b634607c /llvm/unittests/Support/CommandLineTest.cpp
parent245dd2e0c76648b8f875a2f45003ffd8614eb6d6 (diff)
downloadllvm-5390e36953c08bd2b975c9b13964114b51248fa1.zip
llvm-5390e36953c08bd2b975c9b13964114b51248fa1.tar.gz
llvm-5390e36953c08bd2b975c9b13964114b51248fa1.tar.bz2
Fix broken asan Support tests
The asan failures were caught in google internal asan tests after r332311 o Make StackOption support cl::list o Rememeber to removeArguments for cl::alias in tests. llvm-svn: 332354
Diffstat (limited to 'llvm/unittests/Support/CommandLineTest.cpp')
-rw-r--r--llvm/unittests/Support/CommandLineTest.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index a52420f..8e5e9ad 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -51,9 +51,8 @@ class TempEnvVar {
const char *const name;
};
-template <typename T>
-class StackOption : public cl::opt<T> {
- typedef cl::opt<T> Base;
+template <typename T, typename Base = cl::opt<T>>
+class StackOption : public Base {
public:
// One option...
template<class M0t>
@@ -72,6 +71,12 @@ public:
StackOption(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3)
: Base(M0, M1, M2, M3) {}
+ // Five options...
+ template <class M0t, class M1t, class M2t, class M3t, class M4t>
+ StackOption(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3,
+ const M4t &M4)
+ : Base(M0, M1, M2, M3, M4) {}
+
~StackOption() override { this->removeArgument(); }
template <class DT> StackOption<T> &operator=(const DT &V) {
@@ -636,8 +641,8 @@ TEST(CommandLineTest, ResponseFileWindows) {
if (!Triple(sys::getProcessTriple()).isOSWindows())
return;
- static cl::list<std::string>
- InputFilenames(cl::Positional, cl::desc("<input files>"), cl::ZeroOrMore);
+ StackOption<std::string, cl::list<std::string>> InputFilenames(
+ cl::Positional, cl::desc("<input files>"), cl::ZeroOrMore);
StackOption<bool> TopLevelOpt("top-level", cl::init(false));
// Create response file.
@@ -760,6 +765,7 @@ TEST(CommandLineTest, SetDefautValue) {
EXPECT_TRUE(Opt1 == "true");
EXPECT_TRUE(Opt2);
EXPECT_TRUE(Opt3 == 3);
+ Alias.removeArgument();
}
TEST(CommandLineTest, ReadConfigFile) {
@@ -817,9 +823,9 @@ TEST(CommandLineTest, ReadConfigFile) {
}
TEST(CommandLineTest, PositionalEatArgsError) {
- static cl::list<std::string> PosEatArgs("positional-eat-args", cl::Positional,
- cl::desc("<arguments>..."), cl::ZeroOrMore,
- cl::PositionalEatsArgs);
+ StackOption<std::string, cl::list<std::string>> PosEatArgs(
+ "positional-eat-args", cl::Positional, cl::desc("<arguments>..."),
+ cl::ZeroOrMore, cl::PositionalEatsArgs);
const char *args[] = {"prog", "-positional-eat-args=XXXX"};
const char *args2[] = {"prog", "-positional-eat-args=XXXX", "-foo"};