[llvm-branch-commits] [clang] 33f90f3 - [clang][cli] Report the actual argument parsing result
Jan Svoboda via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jan 7 03:42:09 PST 2021
Author: Jan Svoboda
Date: 2021-01-07T12:37:04+01:00
New Revision: 33f90f38e11c7c23d6e2a23ca526f8b0d8f53771
URL: https://github.com/llvm/llvm-project/commit/33f90f38e11c7c23d6e2a23ca526f8b0d8f53771
DIFF: https://github.com/llvm/llvm-project/commit/33f90f38e11c7c23d6e2a23ca526f8b0d8f53771.diff
LOG: [clang][cli] Report the actual argument parsing result
Reviewed By: Bigcheese
Differential Revision: https://reviews.llvm.org/D93700
Added:
Modified:
clang/lib/Frontend/CompilerInvocation.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp
Removed:
################################################################################
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 49447f16637f..7fb7ec896e64 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -129,10 +129,9 @@ CompilerInvocationBase::~CompilerInvocationBase() = default;
#include "clang/Driver/Options.inc"
#undef SIMPLE_ENUM_VALUE_TABLE
-static llvm::Optional<bool> normalizeSimpleFlag(OptSpecifier Opt,
- unsigned TableIndex,
- const ArgList &Args,
- DiagnosticsEngine &Diags) {
+static llvm::Optional<bool>
+normalizeSimpleFlag(OptSpecifier Opt, unsigned TableIndex, const ArgList &Args,
+ DiagnosticsEngine &Diags, bool &Success) {
if (Args.hasArg(Opt))
return true;
return None;
@@ -140,7 +139,8 @@ static llvm::Optional<bool> normalizeSimpleFlag(OptSpecifier Opt,
static Optional<bool> normalizeSimpleNegativeFlag(OptSpecifier Opt, unsigned,
const ArgList &Args,
- DiagnosticsEngine &) {
+ DiagnosticsEngine &,
+ bool &Success) {
if (Args.hasArg(Opt))
return false;
return None;
@@ -166,7 +166,7 @@ template <typename T,
std::enable_if_t<!is_uint64_t_convertible<T>(), bool> = false>
static auto makeFlagToValueNormalizer(T Value) {
return [Value](OptSpecifier Opt, unsigned, const ArgList &Args,
- DiagnosticsEngine &) -> Optional<T> {
+ DiagnosticsEngine &, bool &Success) -> Optional<T> {
if (Args.hasArg(Opt))
return Value;
return None;
@@ -182,8 +182,8 @@ static auto makeFlagToValueNormalizer(T Value) {
static auto makeBooleanOptionNormalizer(bool Value, bool OtherValue,
OptSpecifier OtherOpt) {
return [Value, OtherValue, OtherOpt](OptSpecifier Opt, unsigned,
- const ArgList &Args,
- DiagnosticsEngine &) -> Optional<bool> {
+ const ArgList &Args, DiagnosticsEngine &,
+ bool &Success) -> Optional<bool> {
if (const Arg *A = Args.getLastArg(Opt, OtherOpt)) {
return A->getOption().matches(Opt) ? Value : OtherValue;
}
@@ -246,10 +246,9 @@ findValueTableByValue(const SimpleEnumValueTable &Table, unsigned Value) {
return None;
}
-static llvm::Optional<unsigned> normalizeSimpleEnum(OptSpecifier Opt,
- unsigned TableIndex,
- const ArgList &Args,
- DiagnosticsEngine &Diags) {
+static llvm::Optional<unsigned>
+normalizeSimpleEnum(OptSpecifier Opt, unsigned TableIndex, const ArgList &Args,
+ DiagnosticsEngine &Diags, bool &Success) {
assert(TableIndex < SimpleEnumValueTablesSize);
const SimpleEnumValueTable &Table = SimpleEnumValueTables[TableIndex];
@@ -261,6 +260,7 @@ static llvm::Optional<unsigned> normalizeSimpleEnum(OptSpecifier Opt,
if (auto MaybeEnumVal = findValueTableByName(Table, ArgValue))
return MaybeEnumVal->Value;
+ Success = false;
Diags.Report(diag::err_drv_invalid_value)
<< Arg->getAsString(Args) << ArgValue;
return None;
@@ -294,7 +294,8 @@ static void denormalizeSimpleEnum(SmallVectorImpl<const char *> &Args,
static Optional<std::string> normalizeString(OptSpecifier Opt, int TableIndex,
const ArgList &Args,
- DiagnosticsEngine &Diags) {
+ DiagnosticsEngine &Diags,
+ bool &Success) {
auto *Arg = Args.getLastArg(Opt);
if (!Arg)
return None;
@@ -302,14 +303,15 @@ static Optional<std::string> normalizeString(OptSpecifier Opt, int TableIndex,
}
template <typename IntTy>
-static Optional<IntTy> normalizeStringIntegral(OptSpecifier Opt, int,
- const ArgList &Args,
- DiagnosticsEngine &Diags) {
+static Optional<IntTy>
+normalizeStringIntegral(OptSpecifier Opt, int, const ArgList &Args,
+ DiagnosticsEngine &Diags, bool &Success) {
auto *Arg = Args.getLastArg(Opt);
if (!Arg)
return None;
IntTy Res;
if (StringRef(Arg->getValue()).getAsInteger(0, Res)) {
+ Success = false;
Diags.Report(diag::err_drv_invalid_int_value)
<< Arg->getAsString(Args) << Arg->getValue();
}
@@ -318,7 +320,7 @@ static Optional<IntTy> normalizeStringIntegral(OptSpecifier Opt, int,
static Optional<std::vector<std::string>>
normalizeStringVector(OptSpecifier Opt, int, const ArgList &Args,
- DiagnosticsEngine &) {
+ DiagnosticsEngine &, bool &Success) {
return Args.getAllArgValues(Opt);
}
@@ -356,7 +358,8 @@ static void denormalizeStringVector(SmallVectorImpl<const char *> &Args,
static Optional<std::string> normalizeTriple(OptSpecifier Opt, int TableIndex,
const ArgList &Args,
- DiagnosticsEngine &Diags) {
+ DiagnosticsEngine &Diags,
+ bool &Success) {
auto *Arg = Args.getLastArg(Opt);
if (!Arg)
return None;
@@ -2970,6 +2973,8 @@ static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args,
bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
DiagnosticsEngine &Diags) {
+ bool Success = true;
+
#define OPTION_WITH_MARSHALLING( \
PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, \
@@ -2980,14 +2985,16 @@ bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
if (IMPLIED_CHECK) \
this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE); \
if (SHOULD_PARSE) \
- if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags)) \
+ if (auto MaybeValue = \
+ NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags, Success)) \
this->KEYPATH = MERGER( \
this->KEYPATH, static_cast<decltype(this->KEYPATH)>(*MaybeValue)); \
}
#include "clang/Driver/Options.inc"
#undef OPTION_WITH_MARSHALLING
- return true;
+
+ return Success;
}
bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 7b8efb9af2e2..577059f186b2 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -100,9 +100,7 @@ TEST(ContainsN, Two) {
TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagNotPresent) {
const char *Args[] = {""};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -113,9 +111,7 @@ TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagNotPresent) {
TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagPresent) {
const char *Args[] = {"-fno-temp-file"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_FALSE(Invocation.getFrontendOpts().UseTemporary);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -126,10 +122,8 @@ TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagPresent) {
TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagUnknownPresent) {
const char *Args[] = {"-ftemp-file"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
// Driver-only flag.
- ASSERT_TRUE(Diags->hasErrorOccurred());
+ ASSERT_FALSE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
}
@@ -140,8 +134,7 @@ TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagUnknownPresent) {
TEST_F(CommandLineTest, BoolOptionDefaultTruePresentNone) {
const char *Args[] = {""};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_TRUE(Invocation.getCodeGenOpts().Autolink);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -152,8 +145,7 @@ TEST_F(CommandLineTest, BoolOptionDefaultTruePresentNone) {
TEST_F(CommandLineTest, BoolOptionDefaultTruePresentNegChange) {
const char *Args[] = {"-fno-autolink"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_FALSE(Invocation.getCodeGenOpts().Autolink);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -164,8 +156,8 @@ TEST_F(CommandLineTest, BoolOptionDefaultTruePresentNegChange) {
TEST_F(CommandLineTest, BoolOptionDefaultTruePresentPosReset) {
const char *Args[] = {"-fautolink"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
- ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
+ // Driver-only flag.
+ ASSERT_FALSE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_TRUE(Invocation.getCodeGenOpts().Autolink);
}
@@ -176,8 +168,7 @@ TEST_F(CommandLineTest, BoolOptionDefaultTruePresentPosReset) {
TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNone) {
const char *Args[] = {""};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_FALSE(Invocation.getCodeGenOpts().NoInlineLineTables);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -188,8 +179,7 @@ TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNone) {
TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNegChange) {
const char *Args[] = {"-gno-inline-line-tables"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_TRUE(Invocation.getCodeGenOpts().NoInlineLineTables);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -200,8 +190,8 @@ TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNegChange) {
TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentPosReset) {
const char *Args[] = {"-ginline-line-tables"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
- ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
+ // Driver-only flag.
+ ASSERT_FALSE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_FALSE(Invocation.getCodeGenOpts().NoInlineLineTables);
}
@@ -212,8 +202,7 @@ TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentPosReset) {
TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNoneX) {
const char *Args[] = {""};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_FALSE(Invocation.getCodeGenOpts().CodeViewGHash);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -224,8 +213,7 @@ TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNoneX) {
TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentPosChange) {
const char *Args[] = {"-gcodeview-ghash"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_TRUE(Invocation.getCodeGenOpts().CodeViewGHash);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -236,8 +224,8 @@ TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentPosChange) {
TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNegReset) {
const char *Args[] = {"-gno-codeview-ghash"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
- ASSERT_TRUE(Diags->hasErrorOccurred()); // Driver-only flag.
+ // Driver-only flag.
+ ASSERT_FALSE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_FALSE(Invocation.getCodeGenOpts().CodeViewGHash);
}
@@ -259,9 +247,7 @@ static constexpr const char *PassManagerChangedByFlag =
TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentNone) {
const char *Args = {""};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_EQ(Invocation.getCodeGenOpts().LegacyPassManager, PassManagerDefault);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -273,8 +259,7 @@ TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentNone) {
TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentChange) {
const char *Args[] = {PassManagerChangedByFlag};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_EQ(Invocation.getCodeGenOpts().LegacyPassManager, !PassManagerDefault);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -285,8 +270,7 @@ TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentChange) {
TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentReset) {
const char *Args[] = {PassManagerResetByFlag};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_EQ(Invocation.getCodeGenOpts().LegacyPassManager, PassManagerDefault);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -304,9 +288,7 @@ TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentReset) {
TEST_F(CommandLineTest, BoolOptionCC1ViaLetPresentNone) {
const char *Args[] = {""};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_FALSE(Invocation.getCodeGenOpts().DebugPassManager);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -318,9 +300,7 @@ TEST_F(CommandLineTest, BoolOptionCC1ViaLetPresentNone) {
TEST_F(CommandLineTest, BoolOptionCC1ViaLetPresentPos) {
const char *Args[] = {"-fdebug-pass-manager"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_TRUE(Invocation.getCodeGenOpts().DebugPassManager);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -332,9 +312,7 @@ TEST_F(CommandLineTest, BoolOptionCC1ViaLetPresentPos) {
TEST_F(CommandLineTest, BoolOptionCC1ViaLetPresentNeg) {
const char *Args[] = {"-fno-debug-pass-manager"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_FALSE(Invocation.getCodeGenOpts().DebugPassManager);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -346,9 +324,7 @@ TEST_F(CommandLineTest, BoolOptionCC1ViaLetPresentNeg) {
TEST_F(CommandLineTest, CanGenerateCC1CommandLineFlag) {
const char *Args[] = {"-fmodules-strict-context-hash"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -359,9 +335,7 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparate) {
const char *TripleCStr = "i686-apple-darwin9";
const char *Args[] = {"-triple", TripleCStr};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -373,9 +347,7 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateRequiredPresent) {
llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple());
const char *Args[] = {"-triple", DefaultTriple.c_str()};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -388,9 +360,7 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateRequiredAbsent) {
llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple());
const char *Args[] = {""};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -401,9 +371,7 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateRequiredAbsent) {
TEST_F(CommandLineTest, SeparateEnumNonDefault) {
const char *Args[] = {"-mrelocation-model", "static"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_EQ(Invocation.getCodeGenOpts().RelocationModel, Reloc::Model::Static);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -417,9 +385,7 @@ TEST_F(CommandLineTest, SeparateEnumNonDefault) {
TEST_F(CommandLineTest, SeparateEnumDefault) {
const char *Args[] = {"-mrelocation-model", "pic"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_EQ(Invocation.getCodeGenOpts().RelocationModel, Reloc::Model::PIC_);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -433,9 +399,7 @@ TEST_F(CommandLineTest, SeparateEnumDefault) {
TEST_F(CommandLineTest, JoinedEnumNonDefault) {
const char *Args[] = {"-fobjc-dispatch-method=non-legacy"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_EQ(Invocation.getCodeGenOpts().getObjCDispatchMethod(),
CodeGenOptions::NonLegacy);
@@ -450,9 +414,7 @@ TEST_F(CommandLineTest, JoinedEnumNonDefault) {
TEST_F(CommandLineTest, JoinedEnumDefault) {
const char *Args[] = {"-fobjc-dispatch-method=legacy"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_EQ(Invocation.getCodeGenOpts().getObjCDispatchMethod(),
CodeGenOptions::Legacy);
@@ -467,9 +429,7 @@ TEST_F(CommandLineTest, JoinedEnumDefault) {
TEST_F(CommandLineTest, StringVectorEmpty) {
const char *Args[] = {""};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_TRUE(Invocation.getFrontendOpts().ModuleMapFiles.empty());
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -480,9 +440,7 @@ TEST_F(CommandLineTest, StringVectorEmpty) {
TEST_F(CommandLineTest, StringVectorSingle) {
const char *Args[] = {"-fmodule-map-file=a"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_EQ(Invocation.getFrontendOpts().ModuleMapFiles,
std::vector<std::string>({"a"}));
@@ -495,9 +453,7 @@ TEST_F(CommandLineTest, StringVectorSingle) {
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(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_TRUE(Invocation.getFrontendOpts().ModuleMapFiles ==
std::vector<std::string>({"a", "b"}));
@@ -513,9 +469,7 @@ TEST_F(CommandLineTest, StringVectorMultiple) {
TEST_F(CommandLineTest, StringVectorCommaJoinedNone) {
const char *Args[] = {""};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_TRUE(Invocation.getLangOpts()->CommentOpts.BlockCommandNames.empty());
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -527,9 +481,7 @@ TEST_F(CommandLineTest, StringVectorCommaJoinedNone) {
TEST_F(CommandLineTest, StringVectorCommaJoinedSingle) {
const char *Args[] = {"-fcomment-block-commands=x,y"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_EQ(Invocation.getLangOpts()->CommentOpts.BlockCommandNames,
std::vector<std::string>({"x", "y"}));
@@ -543,9 +495,7 @@ 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_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_EQ(Invocation.getLangOpts()->CommentOpts.BlockCommandNames,
std::vector<std::string>({"x", "y", "a", "b"}));
@@ -640,9 +590,7 @@ TEST_F(CommandLineTest, WideIntegerHighValue) {
TEST_F(CommandLineTest, ImpliedBoolOptionsNoFlagPresent) {
const char *Args[] = {""};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_FALSE(Invocation.getLangOpts()->CLUnsafeMath);
ASSERT_FALSE(Invocation.getCodeGenOpts().LessPreciseFPMAD);
ASSERT_FALSE(Invocation.getLangOpts()->UnsafeFPMath);
@@ -661,9 +609,7 @@ TEST_F(CommandLineTest, ImpliedBoolOptionsNoFlagPresent) {
TEST_F(CommandLineTest, ImpliedBoolOptionsRootFlagPresent) {
const char *Args[] = {"-cl-unsafe-math-optimizations"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
// Explicitly provided root flag.
ASSERT_TRUE(Invocation.getLangOpts()->CLUnsafeMath);
// Directly implied by explicitly provided root flag.
@@ -686,9 +632,7 @@ TEST_F(CommandLineTest, ImpliedBoolOptionsAllFlagsPresent) {
const char *Args[] = {"-cl-unsafe-math-optimizations", "-cl-mad-enable",
"-menable-unsafe-fp-math", "-freciprocal-math"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_TRUE(Invocation.getLangOpts()->CLUnsafeMath);
ASSERT_TRUE(Invocation.getCodeGenOpts().LessPreciseFPMAD);
ASSERT_TRUE(Invocation.getLangOpts()->UnsafeFPMath);
@@ -708,8 +652,7 @@ TEST_F(CommandLineTest, ImpliedBoolOptionsImpliedFlagsPresent) {
const char *Args[] = {"-cl-mad-enable", "-menable-unsafe-fp-math",
"-freciprocal-math"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_FALSE(Invocation.getLangOpts()->CLUnsafeMath);
ASSERT_TRUE(Invocation.getCodeGenOpts().LessPreciseFPMAD);
ASSERT_TRUE(Invocation.getLangOpts()->UnsafeFPMath);
@@ -729,9 +672,7 @@ TEST_F(CommandLineTest, ImpliedBoolOptionsImpliedFlagsPresent) {
TEST_F(CommandLineTest, PresentAndNotImpliedGenerated) {
const char *Args[] = {"-cl-mad-enable", "-menable-unsafe-fp-math"};
- CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
-
- ASSERT_FALSE(Diags->hasErrorOccurred());
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
More information about the llvm-branch-commits
mailing list