aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Frontend/CompilerInvocationTest.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2020-12-21 14:28:09 +0100
committerJan Svoboda <jan_svoboda@apple.com>2020-12-22 14:11:16 +0100
commit63a24816f561a5d8e28ca7054892bd8602618be4 (patch)
treed27c478f31eb58eb164ddf92048bf1a9727c6ebe /clang/unittests/Frontend/CompilerInvocationTest.cpp
parent44e74c75e614af453f4824cb9bf1f0056d7cf426 (diff)
downloadllvm-63a24816f561a5d8e28ca7054892bd8602618be4.zip
llvm-63a24816f561a5d8e28ca7054892bd8602618be4.tar.gz
llvm-63a24816f561a5d8e28ca7054892bd8602618be4.tar.bz2
[clang][cli] Implement `getAllArgValues` marshalling
This infrastructure can be used ~30 more command line options. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D93631
Diffstat (limited to 'clang/unittests/Frontend/CompilerInvocationTest.cpp')
-rw-r--r--clang/unittests/Frontend/CompilerInvocationTest.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 71e8d09..5738f707 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -18,6 +18,7 @@ using namespace llvm;
using namespace clang;
using ::testing::Contains;
+using ::testing::HasSubstr;
using ::testing::StrEq;
namespace {
@@ -408,6 +409,45 @@ TEST_F(CommandLineTest, JoinedEnumDefault) {
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
// their parent:
//