From 1876a2914fe0bedf50f7be6a305f5bf35493e496 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 23 Dec 2020 14:13:23 -0500 Subject: Revert more changes that landed on top of 741978d727 This should've been in 7ad666798f12456d9 but wasn't. Squashes these twoc commits: Revert "[clang][cli] Let denormalizer decide how to render the option based on the option class" This reverts commit 70410a264949101ced3ce3458f37dd4cc2f5af85. Revert "[clang][cli] Implement `getAllArgValues` marshalling" This reverts commit 63a24816f561a5d8e28ca7054892bd8602618be4. --- .../unittests/Frontend/CompilerInvocationTest.cpp | 84 +--------------------- 1 file changed, 2 insertions(+), 82 deletions(-) (limited to 'clang/unittests/Frontend/CompilerInvocationTest.cpp') diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp index 5738f707..51b7ba8 100644 --- a/clang/unittests/Frontend/CompilerInvocationTest.cpp +++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp @@ -18,7 +18,6 @@ using namespace llvm; using namespace clang; using ::testing::Contains; -using ::testing::HasSubstr; using ::testing::StrEq; namespace { @@ -343,109 +342,30 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateRequiredAbsent) { ASSERT_THAT(GeneratedArgs, Contains(StrEq(DefaultTriple.c_str()))); } -TEST_F(CommandLineTest, SeparateEnumNonDefault) { +TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateEnumNonDefault) { const char *Args[] = {"-mrelocation-model", "static"}; CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); ASSERT_FALSE(Diags->hasErrorOccurred()); - ASSERT_EQ(Invocation.getCodeGenOpts().RelocationModel, Reloc::Model::Static); Invocation.generateCC1CommandLine(GeneratedArgs, *this); // Non default relocation model. - ASSERT_THAT(GeneratedArgs, Contains(StrEq("-mrelocation-model"))); ASSERT_THAT(GeneratedArgs, Contains(StrEq("static"))); - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-mrelocation-model=static")))); } -TEST_F(CommandLineTest, SeparateEnumDefault) { +TEST_F(CommandLineTest, CanGenerateCC1COmmandLineSeparateEnumDefault) { const char *Args[] = {"-mrelocation-model", "pic"}; CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); ASSERT_FALSE(Diags->hasErrorOccurred()); - ASSERT_EQ(Invocation.getCodeGenOpts().RelocationModel, Reloc::Model::PIC_); Invocation.generateCC1CommandLine(GeneratedArgs, *this); // Default relocation model. - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-mrelocation-model")))); ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("pic")))); - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-mrelocation-model=pic")))); -} - -TEST_F(CommandLineTest, JoinedEnumNonDefault) { - const char *Args[] = {"-fobjc-dispatch-method=non-legacy"}; - - CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); - - ASSERT_FALSE(Diags->hasErrorOccurred()); - ASSERT_EQ(Invocation.getCodeGenOpts().getObjCDispatchMethod(), - CodeGenOptions::NonLegacy); - - Invocation.generateCC1CommandLine(GeneratedArgs, *this); - - ASSERT_THAT(GeneratedArgs, - Contains(StrEq("-fobjc-dispatch-method=non-legacy"))); - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fobjc-dispatch-method=")))); - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("non-legacy")))); -} - -TEST_F(CommandLineTest, JoinedEnumDefault) { - const char *Args[] = {"-fobjc-dispatch-method=legacy"}; - - CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); - - ASSERT_FALSE(Diags->hasErrorOccurred()); - ASSERT_EQ(Invocation.getCodeGenOpts().getObjCDispatchMethod(), - CodeGenOptions::Legacy); - - Invocation.generateCC1CommandLine(GeneratedArgs, *this); - - ASSERT_THAT(GeneratedArgs, - Not(Contains(StrEq("-fobjc-dispatch-method=legacy")))); - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fobjc-dispatch-method=")))); - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("legacy")))); -} - -TEST_F(CommandLineTest, StringVectorEmpty) { - const char *Args[] = {""}; - - CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); - - ASSERT_FALSE(Diags->hasErrorOccurred()); - ASSERT_TRUE(Invocation.getFrontendOpts().ModuleMapFiles.empty()); - - Invocation.generateCC1CommandLine(GeneratedArgs, *this); - ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-fmodule-map-file=")))); -} - -TEST_F(CommandLineTest, StringVectorSingle) { - const char *Args[] = {"-fmodule-map-file=a"}; - - CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); - - ASSERT_FALSE(Diags->hasErrorOccurred()); - ASSERT_EQ(Invocation.getFrontendOpts().ModuleMapFiles, - std::vector({"a"})); - - Invocation.generateCC1CommandLine(GeneratedArgs, *this); - ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=a")), 1); -} - -TEST_F(CommandLineTest, StringVectorMultiple) { - const char *Args[] = {"-fmodule-map-file=a", "-fmodule-map-file=b"}; - - CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); - - ASSERT_FALSE(Diags->hasErrorOccurred()); - ASSERT_TRUE(Invocation.getFrontendOpts().ModuleMapFiles == - std::vector({"a", "b"})); - - Invocation.generateCC1CommandLine(GeneratedArgs, *this); - ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=a")), 1); - ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=b")), 1); } // Tree of boolean options that can be (directly or transitively) implied by -- cgit v1.1