diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2020-12-08 10:52:31 +0100 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2020-12-09 08:58:45 +0100 |
commit | 03692bae1fc9b6232de7caea3b57ad2f3dc2a9d0 (patch) | |
tree | ffa0432c5e1d9b04f2f6bb7585eb9b86f0ec85ff /clang/unittests/Frontend/CompilerInvocationTest.cpp | |
parent | 4894e423e7b4b121bd4fb23cdba9870ff0f2a6b6 (diff) | |
download | llvm-03692bae1fc9b6232de7caea3b57ad2f3dc2a9d0.zip llvm-03692bae1fc9b6232de7caea3b57ad2f3dc2a9d0.tar.gz llvm-03692bae1fc9b6232de7caea3b57ad2f3dc2a9d0.tar.bz2 |
[clang][cli] CompilerInvocationTest: check arg parsing does not produce diagnostics
Depends on D92828.
Reviewed By: dexonsmith
Differential Revision: https://reviews.llvm.org/D92829
Diffstat (limited to 'clang/unittests/Frontend/CompilerInvocationTest.cpp')
-rw-r--r-- | clang/unittests/Frontend/CompilerInvocationTest.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp index 0eb76a1..7712dd0 100644 --- a/clang/unittests/Frontend/CompilerInvocationTest.cpp +++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp @@ -8,6 +8,7 @@ #include "clang/Frontend/CompilerInvocation.h" #include "clang/Frontend/CompilerInstance.h" +#include "clang/Frontend/TextDiagnosticBuffer.h" #include "llvm/Support/Host.h" #include "gmock/gmock.h" @@ -32,7 +33,9 @@ public: } CommandLineTest() - : Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions())) {} + : Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions(), + new TextDiagnosticBuffer())) { + } }; TEST_F(CommandLineTest, OptIsInitializedWithCustomDefaultValue) { @@ -40,6 +43,8 @@ TEST_F(CommandLineTest, OptIsInitializedWithCustomDefaultValue) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + ASSERT_FALSE(Diags->hasErrorOccurred()); + ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary); } @@ -48,6 +53,8 @@ TEST_F(CommandLineTest, OptOfNegativeFlagIsPopulatedWithFalse) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + ASSERT_FALSE(Diags->hasErrorOccurred()); + ASSERT_FALSE(Invocation.getFrontendOpts().UseTemporary); } @@ -56,6 +63,8 @@ TEST_F(CommandLineTest, OptsOfImpliedPositiveFlagArePopulatedWithTrue) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + ASSERT_FALSE(Diags->hasErrorOccurred()); + // Explicitly provided flag. ASSERT_TRUE(Invocation.getLangOpts()->CLUnsafeMath); @@ -72,6 +81,8 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineFlag) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + ASSERT_FALSE(Diags->hasErrorOccurred()); + Invocation.generateCC1CommandLine(GeneratedArgs, *this); ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fmodules-strict-context-hash"))); @@ -83,6 +94,8 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparate) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + ASSERT_FALSE(Diags->hasErrorOccurred()); + Invocation.generateCC1CommandLine(GeneratedArgs, *this); ASSERT_THAT(GeneratedArgs, Contains(StrEq(TripleCStr))); @@ -95,6 +108,8 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateRequiredPresent) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + ASSERT_FALSE(Diags->hasErrorOccurred()); + Invocation.generateCC1CommandLine(GeneratedArgs, *this); // Triple should always be emitted even if it is the default @@ -108,6 +123,8 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateRequiredAbsent) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + ASSERT_FALSE(Diags->hasErrorOccurred()); + Invocation.generateCC1CommandLine(GeneratedArgs, *this); // Triple should always be emitted even if it is the default @@ -119,6 +136,8 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateEnumNonDefault) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + ASSERT_FALSE(Diags->hasErrorOccurred()); + Invocation.generateCC1CommandLine(GeneratedArgs, *this); // Non default relocation model. @@ -130,6 +149,8 @@ TEST_F(CommandLineTest, CanGenerateCC1COmmandLineSeparateEnumDefault) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + ASSERT_FALSE(Diags->hasErrorOccurred()); + Invocation.generateCC1CommandLine(GeneratedArgs, *this); // Default relocation model. @@ -141,6 +162,8 @@ TEST_F(CommandLineTest, NotPresentNegativeFlagNotGenerated) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + ASSERT_FALSE(Diags->hasErrorOccurred()); + Invocation.generateCC1CommandLine(GeneratedArgs, *this); ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-temp-file")))); @@ -151,6 +174,8 @@ TEST_F(CommandLineTest, PresentNegativeFlagGenerated) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + ASSERT_FALSE(Diags->hasErrorOccurred()); + Invocation.generateCC1CommandLine(GeneratedArgs, *this); ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fno-temp-file"))); @@ -161,6 +186,8 @@ TEST_F(CommandLineTest, NotPresentAndNotImpliedNotGenerated) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + ASSERT_FALSE(Diags->hasErrorOccurred()); + Invocation.generateCC1CommandLine(GeneratedArgs, *this); // Missing options are not generated. @@ -175,6 +202,8 @@ TEST_F(CommandLineTest, NotPresentAndImpliedNotGenerated) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + ASSERT_FALSE(Diags->hasErrorOccurred()); + Invocation.generateCC1CommandLine(GeneratedArgs, *this); // Missing options that were implied are not generated. @@ -189,6 +218,8 @@ TEST_F(CommandLineTest, PresentAndImpliedNotGenerated) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + ASSERT_FALSE(Diags->hasErrorOccurred()); + Invocation.generateCC1CommandLine(GeneratedArgs, *this); // Present options that were also implied are not generated. @@ -202,6 +233,8 @@ TEST_F(CommandLineTest, PresentAndNotImpliedGenerated) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); + ASSERT_FALSE(Diags->hasErrorOccurred()); + Invocation.generateCC1CommandLine(GeneratedArgs, *this); // Present options that were not implied are generated. |