From c068e9c8c123e7f8c8f3feb57245a012ccd09ccf Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 31 Jul 2020 10:46:27 -0700 Subject: [Support][CommandLine] Delete unused llvm::cl::ParseEnvrironmentOptions The function was added in 2003. It is not used and can be emulated with ParseCommandLineOptions. --- llvm/unittests/Support/CommandLineTest.cpp | 32 ------------------------------ 1 file changed, 32 deletions(-) (limited to 'llvm/unittests/Support/CommandLineTest.cpp') diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp index e8c2cef..be8217b 100644 --- a/llvm/unittests/Support/CommandLineTest.cpp +++ b/llvm/unittests/Support/CommandLineTest.cpp @@ -45,8 +45,6 @@ class TempEnvVar { EXPECT_EQ(nullptr, old_value) << old_value; #if HAVE_SETENV setenv(name, value, true); -#else -# define SKIP_ENVIRONMENT_TESTS #endif } @@ -137,36 +135,6 @@ TEST(CommandLineTest, ModifyExisitingOption) { ASSERT_EQ(cl::Hidden, TestOption.getOptionHiddenFlag()) << "Failed to modify option's hidden flag."; } -#ifndef SKIP_ENVIRONMENT_TESTS - -const char test_env_var[] = "LLVM_TEST_COMMAND_LINE_FLAGS"; - -cl::opt EnvironmentTestOption("env-test-opt"); -TEST(CommandLineTest, ParseEnvironment) { - TempEnvVar TEV(test_env_var, "-env-test-opt=hello"); - EXPECT_EQ("", EnvironmentTestOption); - cl::ParseEnvironmentOptions("CommandLineTest", test_env_var); - EXPECT_EQ("hello", EnvironmentTestOption); -} - -// This test used to make valgrind complain -// ("Conditional jump or move depends on uninitialised value(s)") -// -// Warning: Do not run any tests after this one that try to gain access to -// registered command line options because this will likely result in a -// SEGFAULT. This can occur because the cl::opt in the test below is declared -// on the stack which will be destroyed after the test completes but the -// command line system will still hold a pointer to a deallocated cl::Option. -TEST(CommandLineTest, ParseEnvironmentToLocalVar) { - // Put cl::opt on stack to check for proper initialization of fields. - StackOption 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 TEST(CommandLineTest, UseOptionCategory) { StackOption TestOption2("test-option", cl::cat(TestCategory)); -- cgit v1.1