[clang] 21444e3 - [clang][NFC] Convert `Sema::PragmaMsStackAction` to scoped enum
Vlad Serebrennikov via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 27 23:21:23 PDT 2025
Author: Vlad Serebrennikov
Date: 2025-04-28T09:21:17+03:00
New Revision: 21444e37ab3fa1a62e6113c85954e3f98ee48698
URL: https://github.com/llvm/llvm-project/commit/21444e37ab3fa1a62e6113c85954e3f98ee48698
DIFF: https://github.com/llvm/llvm-project/commit/21444e37ab3fa1a62e6113c85954e3f98ee48698.diff
LOG: [clang][NFC] Convert `Sema::PragmaMsStackAction` to scoped enum
Added:
Modified:
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParsePragma.cpp
clang/lib/Sema/SemaAttr.cpp
clang/lib/Serialization/ASTReader.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 0b57d50e2b22a..899f50cbad599 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -475,6 +475,16 @@ enum class PragmaClangSectionKind {
enum class PragmaClangSectionAction { Set = 0, Clear = 1 };
+enum PragmaMsStackAction {
+ Reset = 0x0, // #pragma ()
+ Set = 0x1, // #pragma (value)
+ Push = 0x2, // #pragma (push[, id])
+ Pop = 0x4, // #pragma (pop[, id])
+ Show = 0x8, // #pragma (show) -- only for "pack"!
+ PushSet = Push | Set, // #pragma (push[, id], value)
+ PopSet = Pop | Set, // #pragma (pop[, id], value)
+};
+
/// Sema - This implements semantic analysis and AST building for C.
/// \nosubgrouping
class Sema final : public SemaBase {
@@ -1436,16 +1446,6 @@ class Sema final : public SemaBase {
PragmaClangSection PragmaClangRelroSection;
PragmaClangSection PragmaClangTextSection;
- enum PragmaMsStackAction {
- PSK_Reset = 0x0, // #pragma ()
- PSK_Set = 0x1, // #pragma (value)
- PSK_Push = 0x2, // #pragma (push[, id])
- PSK_Pop = 0x4, // #pragma (pop[, id])
- PSK_Show = 0x8, // #pragma (show) -- only for "pack"!
- PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value)
- PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value)
- };
-
struct PragmaPackInfo {
PragmaMsStackAction Action;
StringRef SlotLabel;
@@ -1569,15 +1569,15 @@ class Sema final : public SemaBase {
void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action,
llvm::StringRef StackSlotLabel, ValueType Value) {
- if (Action == PSK_Reset) {
+ if (Action == PragmaMsStackAction::Reset) {
CurrentValue = DefaultValue;
CurrentPragmaLocation = PragmaLocation;
return;
}
- if (Action & PSK_Push)
+ if (Action & PragmaMsStackAction::Push)
Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
PragmaLocation);
- else if (Action & PSK_Pop) {
+ else if (Action & PragmaMsStackAction::Pop) {
if (!StackSlotLabel.empty()) {
// If we've got a label, try to find it and jump there.
auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
@@ -1596,7 +1596,7 @@ class Sema final : public SemaBase {
Stack.pop_back();
}
}
- if (Action & PSK_Set) {
+ if (Action & PragmaMsStackAction::Set) {
CurrentValue = Value;
CurrentPragmaLocation = PragmaLocation;
}
@@ -1617,7 +1617,8 @@ class Sema final : public SemaBase {
//
// Push / pop a named sentinel slot.
void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
- assert((Action == PSK_Push || Action == PSK_Pop) &&
+ assert((Action == PragmaMsStackAction::Push ||
+ Action == PragmaMsStackAction::Pop) &&
"Can only push / pop #pragma stack sentinels!");
Act(CurrentPragmaLocation, Action, Label, CurrentValue);
}
@@ -1629,7 +1630,7 @@ class Sema final : public SemaBase {
bool hasValue() const { return CurrentValue != DefaultValue; }
SmallVector<Slot, 2> Stack;
- ValueType DefaultValue; // Value used for PSK_Reset action.
+ ValueType DefaultValue; // Value used for PragmaMsStackAction::Reset action.
ValueType CurrentValue;
SourceLocation CurrentPragmaLocation;
};
diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index 1d419106bf92b..1e3a64b4d0223 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -869,8 +869,8 @@ void Parser::HandlePragmaFloatControl() {
// and the FloatControl is the lower 16 bits. Use shift and bit-and
// to decode the parts.
uintptr_t Value = reinterpret_cast<uintptr_t>(Tok.getAnnotationValue());
- Sema::PragmaMsStackAction Action =
- static_cast<Sema::PragmaMsStackAction>((Value >> 16) & 0xFFFF);
+ PragmaMsStackAction Action =
+ static_cast<PragmaMsStackAction>((Value >> 16) & 0xFFFF);
PragmaFloatControlKind Kind = PragmaFloatControlKind(Value & 0xFFFF);
SourceLocation PragmaLoc = ConsumeAnnotationToken();
Actions.ActOnPragmaFloatControl(PragmaLoc, Action, Kind);
@@ -1019,8 +1019,8 @@ void Parser::HandlePragmaMSPointersToMembers() {
void Parser::HandlePragmaMSVtorDisp() {
assert(Tok.is(tok::annot_pragma_ms_vtordisp));
uintptr_t Value = reinterpret_cast<uintptr_t>(Tok.getAnnotationValue());
- Sema::PragmaMsStackAction Action =
- static_cast<Sema::PragmaMsStackAction>((Value >> 16) & 0xFFFF);
+ PragmaMsStackAction Action =
+ static_cast<PragmaMsStackAction>((Value >> 16) & 0xFFFF);
MSVtorDispMode Mode = MSVtorDispMode(Value & 0xFFFF);
SourceLocation PragmaLoc = ConsumeAnnotationToken();
Actions.ActOnPragmaMSVtorDisp(Action, PragmaLoc, Mode);
@@ -1151,21 +1151,21 @@ bool Parser::HandlePragmaMSSegment(StringRef PragmaName,
return false;
}
PP.Lex(Tok); // (
- Sema::PragmaMsStackAction Action = Sema::PSK_Reset;
+ PragmaMsStackAction Action = PragmaMsStackAction::Reset;
StringRef SlotLabel;
if (Tok.isAnyIdentifier()) {
StringRef PushPop = Tok.getIdentifierInfo()->getName();
if (PushPop == "push")
- Action = Sema::PSK_Push;
+ Action = PragmaMsStackAction::Push;
else if (PushPop == "pop")
- Action = Sema::PSK_Pop;
+ Action = PragmaMsStackAction::Pop;
else {
PP.Diag(PragmaLocation,
diag::warn_pragma_expected_section_push_pop_or_name)
<< PragmaName;
return false;
}
- if (Action != Sema::PSK_Reset) {
+ if (Action != PragmaMsStackAction::Reset) {
PP.Lex(Tok); // push | pop
if (Tok.is(tok::comma)) {
PP.Lex(Tok); // ,
@@ -1191,10 +1191,12 @@ bool Parser::HandlePragmaMSSegment(StringRef PragmaName,
StringLiteral *SegmentName = nullptr;
if (Tok.isNot(tok::r_paren)) {
if (Tok.isNot(tok::string_literal)) {
- unsigned DiagID = Action != Sema::PSK_Reset ? !SlotLabel.empty() ?
- diag::warn_pragma_expected_section_name :
- diag::warn_pragma_expected_section_label_or_name :
- diag::warn_pragma_expected_section_push_pop_or_name;
+ unsigned DiagID =
+ Action != PragmaMsStackAction::Reset
+ ? !SlotLabel.empty()
+ ? diag::warn_pragma_expected_section_name
+ : diag::warn_pragma_expected_section_label_or_name
+ : diag::warn_pragma_expected_section_push_pop_or_name;
PP.Diag(PragmaLocation, DiagID) << PragmaName;
return false;
}
@@ -1209,7 +1211,7 @@ bool Parser::HandlePragmaMSSegment(StringRef PragmaName,
}
// Setting section "" has no effect
if (SegmentName->getLength())
- Action = (Sema::PragmaMsStackAction)(Action | Sema::PSK_Set);
+ Action = (PragmaMsStackAction)(Action | PragmaMsStackAction::Set);
}
if (Tok.isNot(tok::r_paren)) {
PP.Diag(PragmaLocation, diag::warn_pragma_expected_rparen) << PragmaName;
@@ -1298,23 +1300,23 @@ bool Parser::HandlePragmaMSStrictGuardStackCheck(
PragmaName))
return false;
- Sema::PragmaMsStackAction Action = Sema::PSK_Set;
+ PragmaMsStackAction Action = PragmaMsStackAction::Set;
if (Tok.is(tok::identifier)) {
StringRef PushPop = Tok.getIdentifierInfo()->getName();
if (PushPop == "push") {
PP.Lex(Tok);
- Action = Sema::PSK_Push;
+ Action = PragmaMsStackAction::Push;
if (ExpectAndConsume(tok::comma, diag::warn_pragma_expected_punc,
PragmaName))
return false;
} else if (PushPop == "pop") {
PP.Lex(Tok);
- Action = Sema::PSK_Pop;
+ Action = PragmaMsStackAction::Pop;
}
}
bool Value = false;
- if (Action & Sema::PSK_Push || Action & Sema::PSK_Set) {
+ if (Action & PragmaMsStackAction::Push || Action & PragmaMsStackAction::Set) {
const IdentifierInfo *II = Tok.getIdentifierInfo();
if (II && II->isStr("off")) {
PP.Lex(Tok);
@@ -2138,7 +2140,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP,
return;
}
- Sema::PragmaMsStackAction Action = Sema::PSK_Reset;
+ PragmaMsStackAction Action = PragmaMsStackAction::Reset;
StringRef SlotLabel;
Token Alignment;
Alignment.startToken();
@@ -2152,12 +2154,12 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP,
// the push/pop stack.
// In Apple gcc/XL, #pragma pack(4) is equivalent to #pragma pack(push, 4)
Action = (PP.getLangOpts().ApplePragmaPack || PP.getLangOpts().XLPragmaPack)
- ? Sema::PSK_Push_Set
- : Sema::PSK_Set;
+ ? PragmaMsStackAction::PushSet
+ : PragmaMsStackAction::Set;
} else if (Tok.is(tok::identifier)) {
// Map pragma pack options to pack (integer).
auto MapPack = [&](const char *Literal) {
- Action = Sema::PSK_Push_Set;
+ Action = PragmaMsStackAction::PushSet;
Alignment = Tok;
Alignment.setKind(tok::numeric_constant);
Alignment.setLiteralData(Literal);
@@ -2166,7 +2168,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP,
const IdentifierInfo *II = Tok.getIdentifierInfo();
if (II->isStr("show")) {
- Action = Sema::PSK_Show;
+ Action = PragmaMsStackAction::Show;
PP.Lex(Tok);
} else if (II->isStr("packed") && PP.getLangOpts().ZOSExt) {
// #pragma pack(packed) is the same as #pragma pack(1)
@@ -2182,13 +2184,13 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP,
PP.Lex(Tok);
} else if (II->isStr("reset") && PP.getLangOpts().ZOSExt) {
// #pragma pack(reset) is the same as #pragma pack(pop) on XL
- Action = Sema::PSK_Pop;
+ Action = PragmaMsStackAction::Pop;
PP.Lex(Tok);
} else {
if (II->isStr("push")) {
- Action = Sema::PSK_Push;
+ Action = PragmaMsStackAction::Push;
} else if (II->isStr("pop")) {
- Action = Sema::PSK_Pop;
+ Action = PragmaMsStackAction::Pop;
} else {
PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_action) << "pack";
return;
@@ -2199,7 +2201,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP,
PP.Lex(Tok);
if (Tok.is(tok::numeric_constant)) {
- Action = (Sema::PragmaMsStackAction)(Action | Sema::PSK_Set);
+ Action = (PragmaMsStackAction)(Action | PragmaMsStackAction::Set);
Alignment = Tok;
PP.Lex(Tok);
@@ -2215,7 +2217,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP,
return;
}
- Action = (Sema::PragmaMsStackAction)(Action | Sema::PSK_Set);
+ Action = (PragmaMsStackAction)(Action | PragmaMsStackAction::Set);
Alignment = Tok;
PP.Lex(Tok);
@@ -2232,7 +2234,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP,
// the push/pop stack.
// In Apple gcc and IBM XL, #pragma pack() is equivalent to #pragma
// pack(pop).
- Action = Sema::PSK_Pop;
+ Action = PragmaMsStackAction::Pop;
}
if (Tok.isNot(tok::r_paren)) {
@@ -2895,7 +2897,7 @@ void PragmaMSVtorDisp::HandlePragma(Preprocessor &PP,
}
PP.Lex(Tok);
- Sema::PragmaMsStackAction Action = Sema::PSK_Set;
+ PragmaMsStackAction Action = PragmaMsStackAction::Set;
const IdentifierInfo *II = Tok.getIdentifierInfo();
if (II) {
if (II->isStr("push")) {
@@ -2906,24 +2908,24 @@ void PragmaMSVtorDisp::HandlePragma(Preprocessor &PP,
return;
}
PP.Lex(Tok);
- Action = Sema::PSK_Push_Set;
+ Action = PragmaMsStackAction::PushSet;
// not push, could be on/off
} else if (II->isStr("pop")) {
// #pragma vtordisp(pop)
PP.Lex(Tok);
- Action = Sema::PSK_Pop;
+ Action = PragmaMsStackAction::Pop;
}
// not push or pop, could be on/off
} else {
if (Tok.is(tok::r_paren)) {
// #pragma vtordisp()
- Action = Sema::PSK_Reset;
+ Action = PragmaMsStackAction::Reset;
}
}
uint64_t Value = 0;
- if (Action & Sema::PSK_Push || Action & Sema::PSK_Set) {
+ if (Action & PragmaMsStackAction::Push || Action & PragmaMsStackAction::Set) {
const IdentifierInfo *II = Tok.getIdentifierInfo();
if (II && II->isStr("off")) {
PP.Lex(Tok);
@@ -3014,7 +3016,7 @@ void PragmaMSPragma::HandlePragma(Preprocessor &PP,
void PragmaFloatControlHandler::HandlePragma(Preprocessor &PP,
PragmaIntroducer Introducer,
Token &Tok) {
- Sema::PragmaMsStackAction Action = Sema::PSK_Set;
+ PragmaMsStackAction Action = PragmaMsStackAction::Set;
SourceLocation FloatControlLoc = Tok.getLocation();
Token PragmaName = Tok;
if (!PP.getTargetInfo().hasStrictFP() && !PP.getLangOpts().ExpStrictFP) {
@@ -3054,7 +3056,8 @@ void PragmaFloatControlHandler::HandlePragma(Preprocessor &PP,
return;
}
PP.Lex(Tok); // Eat the r_paren
- Action = (Kind == PFC_Pop) ? Sema::PSK_Pop : Sema::PSK_Push;
+ Action = (Kind == PFC_Pop) ? PragmaMsStackAction::Pop
+ : PragmaMsStackAction::Push;
} else {
if (Tok.is(tok::r_paren))
// Selecting Precise or Except
@@ -3078,7 +3081,7 @@ void PragmaFloatControlHandler::HandlePragma(Preprocessor &PP,
if (Kind == PFC_Except)
Kind = PFC_NoExcept;
} else if (PushOnOff == "push") {
- Action = Sema::PSK_Push_Set;
+ Action = PragmaMsStackAction::PushSet;
} else {
PP.Diag(Tok.getLocation(), diag::err_pragma_float_control_malformed);
return;
@@ -3092,7 +3095,7 @@ void PragmaFloatControlHandler::HandlePragma(Preprocessor &PP,
}
StringRef ExpectedPush = Tok.getIdentifierInfo()->getName();
if (ExpectedPush == "push") {
- Action = Sema::PSK_Push_Set;
+ Action = PragmaMsStackAction::PushSet;
} else {
PP.Diag(Tok.getLocation(), diag::err_pragma_float_control_malformed);
return;
diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index bade3a0502a2c..e0ebbd6e092a5 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -31,23 +31,25 @@ Sema::PragmaStackSentinelRAII::PragmaStackSentinelRAII(Sema &S,
bool ShouldAct)
: S(S), SlotLabel(SlotLabel), ShouldAct(ShouldAct) {
if (ShouldAct) {
- S.VtorDispStack.SentinelAction(PSK_Push, SlotLabel);
- S.DataSegStack.SentinelAction(PSK_Push, SlotLabel);
- S.BSSSegStack.SentinelAction(PSK_Push, SlotLabel);
- S.ConstSegStack.SentinelAction(PSK_Push, SlotLabel);
- S.CodeSegStack.SentinelAction(PSK_Push, SlotLabel);
- S.StrictGuardStackCheckStack.SentinelAction(PSK_Push, SlotLabel);
+ S.VtorDispStack.SentinelAction(PragmaMsStackAction::Push, SlotLabel);
+ S.DataSegStack.SentinelAction(PragmaMsStackAction::Push, SlotLabel);
+ S.BSSSegStack.SentinelAction(PragmaMsStackAction::Push, SlotLabel);
+ S.ConstSegStack.SentinelAction(PragmaMsStackAction::Push, SlotLabel);
+ S.CodeSegStack.SentinelAction(PragmaMsStackAction::Push, SlotLabel);
+ S.StrictGuardStackCheckStack.SentinelAction(PragmaMsStackAction::Push,
+ SlotLabel);
}
}
Sema::PragmaStackSentinelRAII::~PragmaStackSentinelRAII() {
if (ShouldAct) {
- S.VtorDispStack.SentinelAction(PSK_Pop, SlotLabel);
- S.DataSegStack.SentinelAction(PSK_Pop, SlotLabel);
- S.BSSSegStack.SentinelAction(PSK_Pop, SlotLabel);
- S.ConstSegStack.SentinelAction(PSK_Pop, SlotLabel);
- S.CodeSegStack.SentinelAction(PSK_Pop, SlotLabel);
- S.StrictGuardStackCheckStack.SentinelAction(PSK_Pop, SlotLabel);
+ S.VtorDispStack.SentinelAction(PragmaMsStackAction::Pop, SlotLabel);
+ S.DataSegStack.SentinelAction(PragmaMsStackAction::Pop, SlotLabel);
+ S.BSSSegStack.SentinelAction(PragmaMsStackAction::Pop, SlotLabel);
+ S.ConstSegStack.SentinelAction(PragmaMsStackAction::Pop, SlotLabel);
+ S.CodeSegStack.SentinelAction(PragmaMsStackAction::Pop, SlotLabel);
+ S.StrictGuardStackCheckStack.SentinelAction(PragmaMsStackAction::Pop,
+ SlotLabel);
}
}
@@ -333,7 +335,7 @@ void Sema::inferNullableClassAttribute(CXXRecordDecl *CRD) {
void Sema::ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
SourceLocation PragmaLoc) {
- PragmaMsStackAction Action = Sema::PSK_Reset;
+ PragmaMsStackAction Action = PragmaMsStackAction::Reset;
AlignPackInfo::Mode ModeVal = AlignPackInfo::Native;
switch (Kind) {
@@ -341,17 +343,17 @@ void Sema::ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
// With XL, native is the same as power, natural means something else.
case POAK_Native:
case POAK_Power:
- Action = Sema::PSK_Push_Set;
+ Action = PragmaMsStackAction::PushSet;
break;
case POAK_Natural:
- Action = Sema::PSK_Push_Set;
+ Action = PragmaMsStackAction::PushSet;
ModeVal = AlignPackInfo::Natural;
break;
// Note that '#pragma options align=packed' is not equivalent to attribute
// packed, it has a
diff erent precedence relative to attribute aligned.
case POAK_Packed:
- Action = Sema::PSK_Push_Set;
+ Action = PragmaMsStackAction::PushSet;
ModeVal = AlignPackInfo::Packed;
break;
@@ -361,17 +363,17 @@ void Sema::ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
Diag(PragmaLoc, diag::err_pragma_options_align_mac68k_target_unsupported);
return;
}
- Action = Sema::PSK_Push_Set;
+ Action = PragmaMsStackAction::PushSet;
ModeVal = AlignPackInfo::Mac68k;
break;
case POAK_Reset:
// Reset just pops the top of the stack, or resets the current alignment to
// default.
- Action = Sema::PSK_Pop;
+ Action = PragmaMsStackAction::Pop;
if (AlignPackStack.Stack.empty()) {
if (AlignPackStack.CurrentValue.getAlignMode() != AlignPackInfo::Native ||
AlignPackStack.CurrentValue.IsPackAttr()) {
- Action = Sema::PSK_Reset;
+ Action = PragmaMsStackAction::Reset;
} else {
Diag(PragmaLoc, diag::warn_pragma_options_align_reset_failed)
<< "stack empty";
@@ -472,7 +474,7 @@ void Sema::ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
AlignmentVal = (unsigned)Val->getZExtValue();
}
- if (Action == Sema::PSK_Show) {
+ if (Action == PragmaMsStackAction::Show) {
// Show the current alignment, making sure to show the right value
// for the default.
// FIXME: This should come from the target.
@@ -486,7 +488,7 @@ void Sema::ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
// MSDN, C/C++ Preprocessor Reference > Pragma Directives > pack:
// "#pragma pack(pop, identifier, n) is undefined"
- if (Action & Sema::PSK_Pop) {
+ if (Action & PragmaMsStackAction::Pop) {
if (Alignment && !SlotLabel.empty())
Diag(PragmaLoc, diag::warn_pragma_pack_pop_identifier_and_alignment);
if (AlignPackStack.Stack.empty()) {
@@ -656,7 +658,7 @@ void Sema::ActOnPragmaFPEvalMethod(SourceLocation Loc,
Diag(Loc, diag::err_setting_eval_method_used_in_unsafe_context) << 0 << 1;
if (getLangOpts().AllowRecip)
Diag(Loc, diag::err_setting_eval_method_used_in_unsafe_context) << 0 << 2;
- FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
+ FpPragmaStack.Act(Loc, PragmaMsStackAction::Set, StringRef(), NewFPFeatures);
CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
PP.setCurrentFPEvalMethod(Loc, Value);
}
@@ -665,7 +667,9 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc,
PragmaMsStackAction Action,
PragmaFloatControlKind Value) {
FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
- if ((Action == PSK_Push_Set || Action == PSK_Push || Action == PSK_Pop) &&
+ if ((Action == PragmaMsStackAction::PushSet ||
+ Action == PragmaMsStackAction::Push ||
+ Action == PragmaMsStackAction::Pop) &&
!CurContext->getRedeclContext()->isFileContext()) {
// Push and pop can only occur at file or namespace scope, or within a
// language linkage declaration.
@@ -700,7 +704,8 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc,
FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
break;
case PFC_Push:
- FpPragmaStack.Act(Loc, Sema::PSK_Push_Set, StringRef(), NewFPFeatures);
+ FpPragmaStack.Act(Loc, PragmaMsStackAction::PushSet, StringRef(),
+ NewFPFeatures);
break;
case PFC_Pop:
if (FpPragmaStack.Stack.empty()) {
@@ -725,7 +730,7 @@ void Sema::ActOnPragmaMSPointersToMembers(
void Sema::ActOnPragmaMSVtorDisp(PragmaMsStackAction Action,
SourceLocation PragmaLoc,
MSVtorDispMode Mode) {
- if (Action & PSK_Pop && VtorDispStack.Stack.empty())
+ if (Action & PragmaMsStackAction::Pop && VtorDispStack.Stack.empty())
Diag(PragmaLoc, diag::warn_pragma_pop_failed) << "vtordisp"
<< "stack empty";
VtorDispStack.Act(PragmaLoc, Action, StringRef(), Mode);
@@ -736,15 +741,15 @@ void Sema::PragmaStack<Sema::AlignPackInfo>::Act(SourceLocation PragmaLocation,
PragmaMsStackAction Action,
llvm::StringRef StackSlotLabel,
AlignPackInfo Value) {
- if (Action == PSK_Reset) {
+ if (Action == PragmaMsStackAction::Reset) {
CurrentValue = DefaultValue;
CurrentPragmaLocation = PragmaLocation;
return;
}
- if (Action & PSK_Push)
+ if (Action & PragmaMsStackAction::Push)
Stack.emplace_back(Slot(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
PragmaLocation));
- else if (Action & PSK_Pop) {
+ else if (Action & PragmaMsStackAction::Pop) {
if (!StackSlotLabel.empty()) {
// If we've got a label, try to find it and jump there.
auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
@@ -787,7 +792,7 @@ void Sema::PragmaStack<Sema::AlignPackInfo>::Act(SourceLocation PragmaLocation,
Stack.pop_back();
}
}
- if (Action & PSK_Set) {
+ if (Action & PragmaMsStackAction::Set) {
CurrentValue = Value;
CurrentPragmaLocation = PragmaLocation;
}
@@ -856,7 +861,7 @@ void Sema::ActOnPragmaMSSeg(SourceLocation PragmaLocation,
.Case("bss_seg", &BSSSegStack)
.Case("const_seg", &ConstSegStack)
.Case("code_seg", &CodeSegStack);
- if (Action & PSK_Pop && Stack->Stack.empty())
+ if (Action & PragmaMsStackAction::Pop && Stack->Stack.empty())
Diag(PragmaLocation, diag::warn_pragma_pop_failed) << PragmaName
<< "stack empty";
if (SegmentName) {
@@ -875,7 +880,8 @@ void Sema::ActOnPragmaMSSeg(SourceLocation PragmaLocation,
void Sema::ActOnPragmaMSStrictGuardStackCheck(SourceLocation PragmaLocation,
PragmaMsStackAction Action,
bool Value) {
- if (Action & PSK_Pop && StrictGuardStackCheckStack.Stack.empty())
+ if (Action & PragmaMsStackAction::Pop &&
+ StrictGuardStackCheckStack.Stack.empty())
Diag(PragmaLocation, diag::warn_pragma_pop_failed) << "strict_gs_check"
<< "stack empty";
@@ -1394,7 +1400,7 @@ void Sema::ActOnPragmaFPContract(SourceLocation Loc,
NewFPFeatures.setDisallowFPContract();
break;
}
- FpPragmaStack.Act(Loc, Sema::PSK_Set, StringRef(), NewFPFeatures);
+ FpPragmaStack.Act(Loc, PragmaMsStackAction::Set, StringRef(), NewFPFeatures);
CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
}
@@ -1430,14 +1436,14 @@ void Sema::ActOnPragmaFPValueChangingOption(SourceLocation Loc,
llvm_unreachable("unhandled value changing pragma fp");
}
- FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
+ FpPragmaStack.Act(Loc, PragmaMsStackAction::Set, StringRef(), NewFPFeatures);
CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
}
void Sema::ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode FPR) {
FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
NewFPFeatures.setConstRoundingModeOverride(FPR);
- FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
+ FpPragmaStack.Act(Loc, PragmaMsStackAction::Set, StringRef(), NewFPFeatures);
CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
}
@@ -1445,7 +1451,7 @@ void Sema::setExceptionMode(SourceLocation Loc,
LangOptions::FPExceptionModeKind FPE) {
FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
NewFPFeatures.setSpecifiedExceptionModeOverride(FPE);
- FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
+ FpPragmaStack.Act(Loc, PragmaMsStackAction::Set, StringRef(), NewFPFeatures);
CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
}
@@ -1461,7 +1467,7 @@ void Sema::ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled) {
}
NewFPFeatures.setAllowFEnvAccessOverride(IsEnabled);
NewFPFeatures.setRoundingMathOverride(IsEnabled);
- FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
+ FpPragmaStack.Act(Loc, PragmaMsStackAction::Set, StringRef(), NewFPFeatures);
CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
}
@@ -1469,7 +1475,7 @@ void Sema::ActOnPragmaCXLimitedRange(SourceLocation Loc,
LangOptions::ComplexRangeKind Range) {
FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
NewFPFeatures.setComplexRangeOverride(Range);
- FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
+ FpPragmaStack.Act(Loc, PragmaMsStackAction::Set, StringRef(), NewFPFeatures);
CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
}
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index f13a173ec933e..5459b3aee958d 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2027,7 +2027,7 @@ Token ASTReader::ReadToken(ModuleFile &M, const RecordDataImpl &Record,
}
case tok::annot_pragma_pack: {
auto *Info = new (PP.getPreprocessorAllocator()) Sema::PragmaPackInfo;
- Info->Action = static_cast<Sema::PragmaMsStackAction>(Record[Idx++]);
+ Info->Action = static_cast<PragmaMsStackAction>(Record[Idx++]);
auto SlotLabel = ReadString(Record, Idx);
Info->SlotLabel =
llvm::StringRef(SlotLabel).copy(PP.getPreprocessorAllocator());
More information about the cfe-commits
mailing list