aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Frontend/CompilerInvocationTest.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2020-12-08 10:37:16 +0100
committerJan Svoboda <jan_svoboda@apple.com>2020-12-09 08:58:45 +0100
commit5afff86d26163bc3ba93fb299ccfc2522d3fdc94 (patch)
treedaa7eca6e44ed2dd773ddfc83b6e9eb723f0031d /clang/unittests/Frontend/CompilerInvocationTest.cpp
parentf825ec86e14b1369a9edf382d65259351eae679e (diff)
downloadllvm-5afff86d26163bc3ba93fb299ccfc2522d3fdc94.zip
llvm-5afff86d26163bc3ba93fb299ccfc2522d3fdc94.tar.gz
llvm-5afff86d26163bc3ba93fb299ccfc2522d3fdc94.tar.bz2
[clang][cli] CompilerInvocationTest: split enum test into two
Depends on D92826. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D92827
Diffstat (limited to 'clang/unittests/Frontend/CompilerInvocationTest.cpp')
-rw-r--r--clang/unittests/Frontend/CompilerInvocationTest.cpp27
1 files changed, 12 insertions, 15 deletions
diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 69a8070..39929b8 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -17,9 +17,7 @@ using namespace llvm;
using namespace clang;
using ::testing::Contains;
-using ::testing::Each;
using ::testing::StrEq;
-using ::testing::StrNe;
namespace {
class CommandLineTest : public ::testing::Test {
@@ -117,27 +115,26 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateRequiredAbsent) {
ASSERT_THAT(GeneratedArgs, Contains(StrEq(DefaultTriple.c_str())));
}
-TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateEnum) {
- const char *RelocationModelCStr = "static";
- const char *Args[] = {"clang", "-xc++", "-mrelocation-model",
- RelocationModelCStr, "-"};
+TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateEnumNonDefault) {
+ const char *Args[] = {"clang", "-xc++", "-mrelocation-model", "static", "-"};
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
- // Non default relocation model
- ASSERT_THAT(GeneratedArgs, Contains(StrEq(RelocationModelCStr)));
- GeneratedArgs.clear();
+ // Non default relocation model.
+ ASSERT_THAT(GeneratedArgs, Contains(StrEq("static")));
+}
+
+TEST_F(CommandLineTest, CanGenerateCC1COmmandLineSeparateEnumDefault) {
+ const char *Args[] = {"clang", "-xc++", "-mrelocation-model", "pic", "-"};
- RelocationModelCStr = "pic";
- Args[3] = RelocationModelCStr;
+ CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
- CompilerInvocation Invocation2;
- CompilerInvocation::CreateFromArgs(Invocation2, Args, *Diags);
+ Invocation.generateCC1CommandLine(GeneratedArgs, *this);
- Invocation2.generateCC1CommandLine(GeneratedArgs, *this);
- ASSERT_THAT(GeneratedArgs, Each(StrNe(RelocationModelCStr)));
+ // Default relocation model.
+ ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("pic"))));
}
TEST_F(CommandLineTest, NotPresentNegativeFlagNotGenerated) {