aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Frontend/CompilerInvocationTest.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-12-23 14:13:23 -0500
committerNico Weber <thakis@chromium.org>2020-12-23 14:20:21 -0500
commit1876a2914fe0bedf50f7be6a305f5bf35493e496 (patch)
tree1c06adbc461064e1a177826184b3255cc2f4ebfb /clang/unittests/Frontend/CompilerInvocationTest.cpp
parentbbd758a7913b1c374ca26e5a734a01200754fe0e (diff)
downloadllvm-1876a2914fe0bedf50f7be6a305f5bf35493e496.zip
llvm-1876a2914fe0bedf50f7be6a305f5bf35493e496.tar.gz
llvm-1876a2914fe0bedf50f7be6a305f5bf35493e496.tar.bz2
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.
Diffstat (limited to 'clang/unittests/Frontend/CompilerInvocationTest.cpp')
-rw-r--r--clang/unittests/Frontend/CompilerInvocationTest.cpp84
1 files changed, 2 insertions, 82 deletions
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<std::string>({"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<std::string>({"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