[llvm] r332354 - Fix broken asan Support tests

Eric Liu via llvm-commits llvm-commits at lists.llvm.org
Tue May 15 06:43:20 PDT 2018


Author: ioeric
Date: Tue May 15 06:43:20 2018
New Revision: 332354

URL: http://llvm.org/viewvc/llvm-project?rev=332354&view=rev
Log:
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.

Modified:
    llvm/trunk/unittests/Support/CommandLineTest.cpp

Modified: llvm/trunk/unittests/Support/CommandLineTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/CommandLineTest.cpp?rev=332354&r1=332353&r2=332354&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/CommandLineTest.cpp (original)
+++ llvm/trunk/unittests/Support/CommandLineTest.cpp Tue May 15 06:43:20 2018
@@ -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, ResponseFileWindow
   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"};




More information about the llvm-commits mailing list