Skip to content

Commit 29cb383

Browse files
committed
Affecting -> NotCompatible; file-scope enum -> class scope enum class
1 parent 8b3e5ba commit 29cb383

File tree

6 files changed

+274
-261
lines changed

6 files changed

+274
-261
lines changed

clang/include/clang/Basic/LangOptions.def

Lines changed: 231 additions & 231 deletions
Large diffs are not rendered by default.

clang/include/clang/Basic/LangOptions.h

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,6 @@ enum class PointerAuthenticationMode : unsigned {
6666
SignAndAuth
6767
};
6868

69-
enum EffectKind {
70-
// Does affect the construction of the AST in a way that does prevent module
71-
// interoperability.
72-
Affecting,
73-
// Does affect the construction of the AST in a way that doesn't prevent
74-
// interoperability (that is, the value can be different between an explicit
75-
// module and the user of that module).
76-
Compatible,
77-
// Does not affect the construction of the AST in any way (that is, the
78-
// value can be different between an implicit module and the user of that
79-
// module).
80-
Benign,
81-
};
82-
8369
/// Bitfields of LangOptions, split out from LangOptions in order to ensure that
8470
/// this large collection of bitfields is a trivial class type.
8571
class LangOptionsBase {
@@ -91,6 +77,22 @@ class LangOptionsBase {
9177
using RoundingMode = llvm::RoundingMode;
9278
using CFBranchLabelSchemeKind = clang::CFBranchLabelSchemeKind;
9379

80+
/// For ASTs produced with different value, signifies their level of
81+
/// compatibility.
82+
enum class CompatibilityKind {
83+
/// Does affect the construction of the AST in a way that does prevent
84+
/// module interoperability.
85+
NotCompatible,
86+
/// Does affect the construction of the AST in a way that doesn't prevent
87+
/// interoperability (that is, the value can be different between an
88+
/// explicit module and the user of that module).
89+
Compatible,
90+
/// Does not affect the construction of the AST in any way (that is, the
91+
/// value can be different between an implicit module and the user of that
92+
/// module).
93+
Benign,
94+
};
95+
9496
enum GCMode { NonGC, GCOnly, HybridGC };
9597
enum StackProtectorMode { SSPOff, SSPOn, SSPStrong, SSPReq };
9698

clang/lib/Basic/LangOptions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ LangOptions::LangOptions() : LangStd(LangStandard::lang_unspecified) {
2424

2525
void LangOptions::resetNonModularOptions() {
2626
#define LANGOPT(Name, Bits, Default, Compatibility, Description) \
27-
if constexpr (Compatibility == Benign) \
27+
if constexpr (CompatibilityKind::Compatibility == CompatibilityKind::Benign) \
2828
Name = Default;
2929
#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
30-
if constexpr (Compatibility == Benign) \
30+
if constexpr (CompatibilityKind::Compatibility == CompatibilityKind::Benign) \
3131
Name = static_cast<unsigned>(Default);
3232
#include "clang/Basic/LangOptions.def"
3333

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5222,11 +5222,13 @@ std::string CompilerInvocation::getModuleHash() const {
52225222
HBuilder.add(serialization::VERSION_MAJOR, serialization::VERSION_MINOR);
52235223

52245224
// Extend the signature with the language options
5225+
// FIXME: Replace with C++20 `using enum LangOptions::CompatibilityKind`.
5226+
using CK = LangOptions::CompatibilityKind;
52255227
#define LANGOPT(Name, Bits, Default, Compatibility, Description) \
5226-
if constexpr (Compatibility != Benign) \
5228+
if constexpr (CK::Compatibility != CK::Benign) \
52275229
HBuilder.add(LangOpts->Name);
52285230
#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
5229-
if constexpr (Compatibility != Benign) \
5231+
if constexpr (CK::Compatibility != CK::Benign) \
52305232
HBuilder.add(static_cast<unsigned>(LangOpts->get##Name()));
52315233
#include "clang/Basic/LangOptions.def"
52325234

clang/lib/Frontend/FrontendActions.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,16 +643,19 @@ namespace {
643643
bool ReadLanguageOptions(const LangOptions &LangOpts,
644644
StringRef ModuleFilename, bool Complain,
645645
bool AllowCompatibleDifferences) override {
646+
// FIXME: Replace with C++20 `using enum LangOptions::CompatibilityKind`.
647+
using CK = LangOptions::CompatibilityKind;
648+
646649
Out.indent(2) << "Language options:\n";
647650
#define LANGOPT(Name, Bits, Default, Compatibility, Description) \
648-
if constexpr (Compatibility != Benign) \
651+
if constexpr (CK::Compatibility != CK::Benign) \
649652
DUMP_BOOLEAN(LangOpts.Name, Description);
650653
#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
651-
if constexpr (Compatibility != Benign) \
654+
if constexpr (CK::Compatibility != CK::Benign) \
652655
Out.indent(4) << Description << ": " \
653656
<< static_cast<unsigned>(LangOpts.get##Name()) << "\n";
654657
#define VALUE_LANGOPT(Name, Bits, Default, Compatibility, Description) \
655-
if constexpr (Compatibility != Benign) \
658+
if constexpr (CK::Compatibility != CK::Benign) \
656659
Out.indent(4) << Description << ": " << LangOpts.Name << "\n";
657660
#include "clang/Basic/LangOptions.def"
658661

clang/lib/Serialization/ASTReader.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,14 @@ static bool checkLanguageOptions(const LangOptions &LangOpts,
278278
StringRef ModuleFilename,
279279
DiagnosticsEngine *Diags,
280280
bool AllowCompatibleDifferences = true) {
281+
// FIXME: Replace with C++20 `using enum LangOptions::CompatibilityKind`.
282+
using CK = LangOptions::CompatibilityKind;
283+
281284
#define LANGOPT(Name, Bits, Default, Compatibility, Description) \
282-
if constexpr (Compatibility != Benign) { \
283-
if ((Compatibility == Affecting) || \
284-
(Compatibility == Compatible && !AllowCompatibleDifferences)) { \
285+
if constexpr (CK::Compatibility != CK::Benign) { \
286+
if ((CK::Compatibility == CK::NotCompatible) || \
287+
(CK::Compatibility == CK::Compatible && \
288+
!AllowCompatibleDifferences)) { \
285289
if (ExistingLangOpts.Name != LangOpts.Name) { \
286290
if (Diags) { \
287291
if (Bits == 1) \
@@ -298,9 +302,10 @@ static bool checkLanguageOptions(const LangOptions &LangOpts,
298302
}
299303

300304
#define VALUE_LANGOPT(Name, Bits, Default, Compatibility, Description) \
301-
if constexpr (Compatibility != Benign) { \
302-
if ((Compatibility == Affecting) || \
303-
(Compatibility == Compatible && !AllowCompatibleDifferences)) { \
305+
if constexpr (CK::Compatibility != CK::Benign) { \
306+
if ((CK::Compatibility == CK::NotCompatible) || \
307+
(CK::Compatibility == CK::Compatible && \
308+
!AllowCompatibleDifferences)) { \
304309
if (ExistingLangOpts.Name != LangOpts.Name) { \
305310
if (Diags) \
306311
Diags->Report(diag::err_ast_file_langopt_value_mismatch) \
@@ -311,9 +316,10 @@ static bool checkLanguageOptions(const LangOptions &LangOpts,
311316
}
312317

313318
#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
314-
if constexpr (Compatibility != Benign) { \
315-
if ((Compatibility == Affecting) || \
316-
(Compatibility == Compatible && !AllowCompatibleDifferences)) { \
319+
if constexpr (CK::Compatibility != CK::Benign) { \
320+
if ((CK::Compatibility == CK::NotCompatible) || \
321+
(CK::Compatibility == CK::Compatible && \
322+
!AllowCompatibleDifferences)) { \
317323
if (ExistingLangOpts.get##Name() != LangOpts.get##Name()) { \
318324
if (Diags) \
319325
Diags->Report(diag::err_ast_file_langopt_value_mismatch) \

0 commit comments

Comments
 (0)