aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Frontend/CompilerInvocationTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/Frontend/CompilerInvocationTest.cpp')
-rw-r--r--clang/unittests/Frontend/CompilerInvocationTest.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index fe67852..d4c6981 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -23,6 +23,7 @@ using namespace clang;
using ::testing::Contains;
using ::testing::HasSubstr;
using ::testing::StrEq;
+using ::testing::StartsWith;
namespace {
class CommandLineTest : public ::testing::Test {
@@ -145,6 +146,26 @@ TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagPresent) {
ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fno-temp-file")));
}
+TEST_F(CommandLineTest, CC1FlagPresentWhenDoingRoundTrip) {
+ const char *Args[] = {"-cc1", "-round-trip-args"};
+
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+
+ ASSERT_THAT(std::string(Invocation.getCodeGenOpts().CmdArgs.begin(),
+ Invocation.getCodeGenOpts().CmdArgs.end()),
+ StartsWith("-cc1"));
+}
+
+TEST_F(CommandLineTest, CC1FlagPresentWhenNotDoingRoundTrip) {
+ const char *Args[] = {"-cc1", "-no-round-trip-args"};
+
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+
+ ASSERT_THAT(std::string(Invocation.getCodeGenOpts().CmdArgs.begin(),
+ Invocation.getCodeGenOpts().CmdArgs.end()),
+ StartsWith("-cc1"));
+}
+
TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagUnknownPresent) {
const char *Args[] = {"-ftemp-file"};