diff options
author | Aiden Grossman <agrossman154@yahoo.com> | 2022-07-29 18:38:34 -0700 |
---|---|---|
committer | Mircea Trofin <mtrofin@google.com> | 2022-07-29 18:51:48 -0700 |
commit | afb4efd3bcc68ab95bf3c35183bedbdbf038356a (patch) | |
tree | c3bc713765e311755c098463a1c2156b541f64dc /clang/unittests/Frontend | |
parent | 995e9d84f8f90dd237871d15cf7237866902e5b2 (diff) | |
download | llvm-afb4efd3bcc68ab95bf3c35183bedbdbf038356a.zip llvm-afb4efd3bcc68ab95bf3c35183bedbdbf038356a.tar.gz llvm-afb4efd3bcc68ab95bf3c35183bedbdbf038356a.tar.bz2 |
Fix lack of cc1 flag in llvmcmd sections when assertions are enabled
Currently when assertions are enabled, the cc1 flag is not
inserted into the llvmcmd section of object files with embedded
bitcode. This deviates from the normal behavior where this is
the first flag that is inserted. This error stems from incorrect
use of the function generateCC1CommandLine() which requires
manually adding in the -cc1 flag which is currently not done.
Reviewed By: jansvoboda11
Differential Revision: https://reviews.llvm.org/D130620
Diffstat (limited to 'clang/unittests/Frontend')
-rw-r--r-- | clang/unittests/Frontend/CompilerInvocationTest.cpp | 21 |
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"}; |