diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2020-12-21 16:35:32 +0100 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2021-01-07 11:52:06 +0100 |
commit | a828fb463ed9f6085849bb3a4f225b3c84e7cf29 (patch) | |
tree | 98e64833f6f745ef199e670d63bf0a75c9ac139f /clang/unittests/Frontend/CompilerInvocationTest.cpp | |
parent | 801c7866e6d4fba81c97d27ca56c9e05ba7b157a (diff) | |
download | llvm-a828fb463ed9f6085849bb3a4f225b3c84e7cf29.zip llvm-a828fb463ed9f6085849bb3a4f225b3c84e7cf29.tar.gz llvm-a828fb463ed9f6085849bb3a4f225b3c84e7cf29.tar.bz2 |
[clang][cli] Port a CommaJoined option to the marshalling infrastructure
Reviewed By: dexonsmith
Differential Revision: https://reviews.llvm.org/D93698
Diffstat (limited to 'clang/unittests/Frontend/CompilerInvocationTest.cpp')
-rw-r--r-- | clang/unittests/Frontend/CompilerInvocationTest.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp index 8fcf34d..7b8efb9 100644 --- a/clang/unittests/Frontend/CompilerInvocationTest.cpp +++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp @@ -508,6 +508,53 @@ TEST_F(CommandLineTest, StringVectorMultiple) { ASSERT_THAT(GeneratedArgs, ContainsN(HasSubstr("-fmodule-map-file"), 2)); } +// CommaJoined option with MarshallingInfoStringVector. + +TEST_F(CommandLineTest, StringVectorCommaJoinedNone) { + const char *Args[] = {""}; + + CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + + ASSERT_FALSE(Diags->hasErrorOccurred()); + ASSERT_TRUE(Invocation.getLangOpts()->CommentOpts.BlockCommandNames.empty()); + + Invocation.generateCC1CommandLine(GeneratedArgs, *this); + + ASSERT_THAT(GeneratedArgs, + Not(Contains(HasSubstr("-fcomment-block-commands")))); +} + +TEST_F(CommandLineTest, StringVectorCommaJoinedSingle) { + const char *Args[] = {"-fcomment-block-commands=x,y"}; + + CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + + ASSERT_FALSE(Diags->hasErrorOccurred()); + ASSERT_EQ(Invocation.getLangOpts()->CommentOpts.BlockCommandNames, + std::vector<std::string>({"x", "y"})); + + Invocation.generateCC1CommandLine(GeneratedArgs, *this); + + ASSERT_THAT(GeneratedArgs, + ContainsN(StrEq("-fcomment-block-commands=x,y"), 1)); +} + +TEST_F(CommandLineTest, StringVectorCommaJoinedMultiple) { + const char *Args[] = {"-fcomment-block-commands=x,y", + "-fcomment-block-commands=a,b"}; + + CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + + ASSERT_FALSE(Diags->hasErrorOccurred()); + ASSERT_EQ(Invocation.getLangOpts()->CommentOpts.BlockCommandNames, + std::vector<std::string>({"x", "y", "a", "b"})); + + Invocation.generateCC1CommandLine(GeneratedArgs, *this); + + ASSERT_THAT(GeneratedArgs, + ContainsN(StrEq("-fcomment-block-commands=x,y,a,b"), 1)); +} + // A flag that should be parsed only if a condition is met. TEST_F(CommandLineTest, ConditionalParsingIfFalseFlagNotPresent) { |