[llvm-commits] [llvm] r161751 - /llvm/trunk/unittests/Support/CommandLineTest.cpp

Alexander Kornienko alexfh at google.com
Mon Aug 13 03:43:36 PDT 2012


Author: alexfh
Date: Mon Aug 13 05:43:36 2012
New Revision: 161751

URL: http://llvm.org/viewvc/llvm-project?rev=161751&view=rev
Log:
Added test for non-static use of cl::opt (fixed in r160170)

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=161751&r1=161750&r2=161751&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/CommandLineTest.cpp (original)
+++ llvm/trunk/unittests/Support/CommandLineTest.cpp Mon Aug 13 05:43:36 2012
@@ -55,6 +55,17 @@
   EXPECT_EQ("hello", EnvironmentTestOption);
 }
 
+// This test used to make valgrind complain
+// ("Conditional jump or move depends on uninitialised value(s)")
+TEST(CommandLineTest, ParseEnvironmentToLocalVar) {
+  // Put cl::opt on stack to check for proper initialization of fields.
+  cl::opt<std::string> EnvironmentTestOptionLocal("env-test-opt-local");
+  TempEnvVar TEV(test_env_var, "-env-test-opt-local=hello-local");
+  EXPECT_EQ("", EnvironmentTestOptionLocal);
+  cl::ParseEnvironmentOptions("CommandLineTest", test_env_var);
+  EXPECT_EQ("hello-local", EnvironmentTestOptionLocal);
+}
+
 #endif  // SKIP_ENVIRONMENT_TESTS
 
 }  // anonymous namespace





More information about the llvm-commits mailing list