Reapply multiple "[clang][cli]" patches

This reverts 7ad666798f and 1876a2914f that reverted:

741978d727 [clang][cli] Port CodeGen option flags to new option parsing system
383778e217 [clang][cli] Port LangOpts option flags to new option parsing system
aec2991d08 [clang][cli] Port LangOpts simple string based options to new option parsing system
95d3cc67ca [clang][cli] Port CodeGenOpts simple string flags to new option parsing system
27b7d64688 [clang][cli] Streamline MarshallingInfoFlag description
70410a2649 [clang][cli] Let denormalizer decide how to render the option based on the option class
63a24816f5 [clang][cli] Implement `getAllArgValues` marshalling

Commit 741978d727 accidentally changed the `Group` attribute of `g[no_]column_info` options from `g_flags_Group` to `g_Group`, which changed the debug info options passed to cc1 by the driver.

Similar change was also present in 383778e217, which accidentally added `Group<f_Group>` to `f[no_]const_strings` and `f[no_]signed_wchar`.

This patch corrects all three accidental changes by replacing `Bool{G,F}Option` with `BoolCC1Option`.
This commit is contained in:
Jan Svoboda 2021-01-05 17:00:46 +01:00
parent 643e3c9076
commit ce8c59e6af
8 changed files with 1030 additions and 1339 deletions

View File

@ -30,6 +30,8 @@ namespace clang {
/// Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure
/// that this large collection of bitfields is a trivial class type.
class CodeGenOptionsBase {
friend class CompilerInvocation;
public:
#define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
#define ENUM_CODEGENOPT(Name, Type, Bits, Default)

View File

@ -86,8 +86,6 @@ def err_drv_invalid_thread_model_for_target : Error<
"invalid thread model '%0' in '%1' for this target">;
def err_drv_invalid_linker_name : Error<
"invalid linker name in argument '%0'">;
def err_drv_invalid_pgo_instrumentor : Error<
"invalid PGO instrumentor in argument '%0'">;
def err_drv_invalid_rtlib_name : Error<
"invalid runtime library name in argument '%0'">;
def err_drv_unsupported_rtlib_for_platform : Error<

View File

@ -108,8 +108,6 @@ def err_fe_action_not_available : Error<
"action %0 not compiled in">;
def err_fe_invalid_alignment : Error<
"invalid value '%1' in '%0'; alignment must be a power of 2">;
def err_fe_invalid_wchar_type
: Error<"invalid wchar_t type '%0'; must be one of 'char', 'short', 'int'">;
def err_fe_invalid_exception_model
: Error<"invalid exception model '%select{none|dwarf|sjlj|arm|seh|wasm|aix}0' for target '%1'">;
def warn_fe_concepts_ts_flag : Warning<

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
//
// PROF-INSTR-NONE-NOT: __llvm_prf
//
// PROF-INSTR-GARBAGE: invalid PGO instrumentor in argument '-fprofile-instrument=garbage'
// PROF-INSTR-GARBAGE: invalid value 'garbage' in '-fprofile-instrument=garbage'
int main(void) {
return 0;

View File

@ -18,6 +18,7 @@ using namespace llvm;
using namespace clang;
using ::testing::Contains;
using ::testing::HasSubstr;
using ::testing::StrEq;
namespace {
@ -342,30 +343,109 @@ TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateRequiredAbsent) {
ASSERT_THAT(GeneratedArgs, Contains(StrEq(DefaultTriple.c_str())));
}
TEST_F(CommandLineTest, CanGenerateCC1CommandLineSeparateEnumNonDefault) {
TEST_F(CommandLineTest, SeparateEnumNonDefault) {
const char *Args[] = {"-mrelocation-model", "static"};
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_EQ(Invocation.getCodeGenOpts().RelocationModel, Reloc::Model::Static);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
// Non default relocation model.
ASSERT_THAT(GeneratedArgs, Contains(StrEq("-mrelocation-model")));
ASSERT_THAT(GeneratedArgs, Contains(StrEq("static")));
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-mrelocation-model=static"))));
}
TEST_F(CommandLineTest, CanGenerateCC1COmmandLineSeparateEnumDefault) {
TEST_F(CommandLineTest, SeparateEnumDefault) {
const char *Args[] = {"-mrelocation-model", "pic"};
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_EQ(Invocation.getCodeGenOpts().RelocationModel, Reloc::Model::PIC_);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
// Default relocation model.
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-mrelocation-model"))));
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("pic"))));
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-mrelocation-model=pic"))));
}
TEST_F(CommandLineTest, JoinedEnumNonDefault) {
const char *Args[] = {"-fobjc-dispatch-method=non-legacy"};
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_EQ(Invocation.getCodeGenOpts().getObjCDispatchMethod(),
CodeGenOptions::NonLegacy);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
ASSERT_THAT(GeneratedArgs,
Contains(StrEq("-fobjc-dispatch-method=non-legacy")));
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fobjc-dispatch-method="))));
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("non-legacy"))));
}
TEST_F(CommandLineTest, JoinedEnumDefault) {
const char *Args[] = {"-fobjc-dispatch-method=legacy"};
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_EQ(Invocation.getCodeGenOpts().getObjCDispatchMethod(),
CodeGenOptions::Legacy);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
ASSERT_THAT(GeneratedArgs,
Not(Contains(StrEq("-fobjc-dispatch-method=legacy"))));
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fobjc-dispatch-method="))));
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("legacy"))));
}
TEST_F(CommandLineTest, StringVectorEmpty) {
const char *Args[] = {""};
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_TRUE(Invocation.getFrontendOpts().ModuleMapFiles.empty());
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-fmodule-map-file="))));
}
TEST_F(CommandLineTest, StringVectorSingle) {
const char *Args[] = {"-fmodule-map-file=a"};
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_EQ(Invocation.getFrontendOpts().ModuleMapFiles,
std::vector<std::string>({"a"}));
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=a")), 1);
}
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(Invocation.getFrontendOpts().ModuleMapFiles ==
std::vector<std::string>({"a", "b"}));
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=a")), 1);
ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=b")), 1);
}
// Wide integer option.

View File

@ -167,12 +167,24 @@ class MarshallingInfoStringInt<code keypath, code defaultvalue="0", code type="u
code Denormalizer = "denormalizeString";
}
class MarshallingInfoStringVector<code keypath>
: MarshallingInfo<keypath, "std::vector<std::string>({})"> {
code Normalizer = "normalizeStringVector";
code Denormalizer = "denormalizeStringVector";
}
class MarshallingInfoFlag<code keypath, code defaultvalue = "false">
: MarshallingInfo<keypath, defaultvalue> {
code Normalizer = "normalizeSimpleFlag";
code Denormalizer = "denormalizeSimpleFlag";
}
class MarshallingInfoNegativeFlag<code keypath, code defaultvalue = "true">
: MarshallingInfo<keypath, defaultvalue> {
code Normalizer = "normalizeSimpleNegativeFlag";
code Denormalizer = "denormalizeSimpleFlag";
}
class MarshallingInfoBitfieldFlag<code keypath, code value>
: MarshallingInfoFlag<keypath, "0u"> {
code Normalizer = "makeFlagToValueNormalizer("#value#")";
@ -190,9 +202,6 @@ class MarshallingInfoBooleanFlag<code keypath, code defaultvalue, code value, co
// Mixins for additional marshalling attributes.
class IsNegative {
code Normalizer = "normalizeSimpleNegativeFlag";
}
class AlwaysEmit { bit ShouldAlwaysEmit = true; }
class Normalizer<code normalizer> { code Normalizer = normalizer; }
class Denormalizer<code denormalizer> { code Denormalizer = denormalizer; }
@ -202,9 +211,6 @@ class AutoNormalizeEnum {
code Normalizer = "normalizeSimpleEnum";
code Denormalizer = "denormalizeSimpleEnum";
}
class AutoNormalizeEnumJoined : AutoNormalizeEnum {
code Denormalizer = "denormalizeSimpleEnumJoined";
}
class ValueMerger<code merger> { code ValueMerger = merger; }
class ValueExtractor<code extractor> { code ValueExtractor = extractor; }