Author: Vlad Serebrennikov Date: 2025-04-28T09:24:25+03:00 New Revision: ab680c55c724ba894269fb687464961a2066c17f
URL: https://github.com/llvm/llvm-project/commit/ab680c55c724ba894269fb687464961a2066c17f DIFF: https://github.com/llvm/llvm-project/commit/ab680c55c724ba894269fb687464961a2066c17f.diff LOG: Revert "[clang][NFC] Convert `Sema::PragmaMsStackAction` to scoped enum" This reverts commit bd2a3f8d90368288a73dd2ef1926f714acd9eff3. 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 899f50cbad599..0b57d50e2b22a 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -475,16 +475,6 @@ 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 { @@ -1446,6 +1436,16 @@ 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 == PragmaMsStackAction::Reset) { + if (Action == PSK_Reset) { CurrentValue = DefaultValue; CurrentPragmaLocation = PragmaLocation; return; } - if (Action & PragmaMsStackAction::Push) + if (Action & PSK_Push) Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation, PragmaLocation); - else if (Action & PragmaMsStackAction::Pop) { + else if (Action & PSK_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 & PragmaMsStackAction::Set) { + if (Action & PSK_Set) { CurrentValue = Value; CurrentPragmaLocation = PragmaLocation; } @@ -1617,8 +1617,7 @@ class Sema final : public SemaBase { // // Push / pop a named sentinel slot. void SentinelAction(PragmaMsStackAction Action, StringRef Label) { - assert((Action == PragmaMsStackAction::Push || - Action == PragmaMsStackAction::Pop) && + assert((Action == PSK_Push || Action == PSK_Pop) && "Can only push / pop #pragma stack sentinels!"); Act(CurrentPragmaLocation, Action, Label, CurrentValue); } @@ -1630,7 +1629,7 @@ class Sema final : public SemaBase { bool hasValue() const { return CurrentValue != DefaultValue; } SmallVector<Slot, 2> Stack; - ValueType DefaultValue; // Value used for PragmaMsStackAction::Reset action. + ValueType DefaultValue; // Value used for PSK_Reset action. ValueType CurrentValue; SourceLocation CurrentPragmaLocation; }; diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp index 1e3a64b4d0223..1d419106bf92b 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()); - PragmaMsStackAction Action = - static_cast<PragmaMsStackAction>((Value >> 16) & 0xFFFF); + Sema::PragmaMsStackAction Action = + static_cast<Sema::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()); - PragmaMsStackAction Action = - static_cast<PragmaMsStackAction>((Value >> 16) & 0xFFFF); + Sema::PragmaMsStackAction Action = + static_cast<Sema::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); // ( - PragmaMsStackAction Action = PragmaMsStackAction::Reset; + Sema::PragmaMsStackAction Action = Sema::PSK_Reset; StringRef SlotLabel; if (Tok.isAnyIdentifier()) { StringRef PushPop = Tok.getIdentifierInfo()->getName(); if (PushPop == "push") - Action = PragmaMsStackAction::Push; + Action = Sema::PSK_Push; else if (PushPop == "pop") - Action = PragmaMsStackAction::Pop; + Action = Sema::PSK_Pop; else { PP.Diag(PragmaLocation, diag::warn_pragma_expected_section_push_pop_or_name) << PragmaName; return false; } - if (Action != PragmaMsStackAction::Reset) { + if (Action != Sema::PSK_Reset) { PP.Lex(Tok); // push | pop if (Tok.is(tok::comma)) { PP.Lex(Tok); // , @@ -1191,12 +1191,10 @@ bool Parser::HandlePragmaMSSegment(StringRef PragmaName, StringLiteral *SegmentName = nullptr; if (Tok.isNot(tok::r_paren)) { if (Tok.isNot(tok::string_literal)) { - 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; + 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; PP.Diag(PragmaLocation, DiagID) << PragmaName; return false; } @@ -1211,7 +1209,7 @@ bool Parser::HandlePragmaMSSegment(StringRef PragmaName, } // Setting section "" has no effect if (SegmentName->getLength()) - Action = (PragmaMsStackAction)(Action | PragmaMsStackAction::Set); + Action = (Sema::PragmaMsStackAction)(Action | Sema::PSK_Set); } if (Tok.isNot(tok::r_paren)) { PP.Diag(PragmaLocation, diag::warn_pragma_expected_rparen) << PragmaName; @@ -1300,23 +1298,23 @@ bool Parser::HandlePragmaMSStrictGuardStackCheck( PragmaName)) return false; - PragmaMsStackAction Action = PragmaMsStackAction::Set; + Sema::PragmaMsStackAction Action = Sema::PSK_Set; if (Tok.is(tok::identifier)) { StringRef PushPop = Tok.getIdentifierInfo()->getName(); if (PushPop == "push") { PP.Lex(Tok); - Action = PragmaMsStackAction::Push; + Action = Sema::PSK_Push; if (ExpectAndConsume(tok::comma, diag::warn_pragma_expected_punc, PragmaName)) return false; } else if (PushPop == "pop") { PP.Lex(Tok); - Action = PragmaMsStackAction::Pop; + Action = Sema::PSK_Pop; } } bool Value = false; - if (Action & PragmaMsStackAction::Push || Action & PragmaMsStackAction::Set) { + if (Action & Sema::PSK_Push || Action & Sema::PSK_Set) { const IdentifierInfo *II = Tok.getIdentifierInfo(); if (II && II->isStr("off")) { PP.Lex(Tok); @@ -2140,7 +2138,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, return; } - PragmaMsStackAction Action = PragmaMsStackAction::Reset; + Sema::PragmaMsStackAction Action = Sema::PSK_Reset; StringRef SlotLabel; Token Alignment; Alignment.startToken(); @@ -2154,12 +2152,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) - ? PragmaMsStackAction::PushSet - : PragmaMsStackAction::Set; + ? Sema::PSK_Push_Set + : Sema::PSK_Set; } else if (Tok.is(tok::identifier)) { // Map pragma pack options to pack (integer). auto MapPack = [&](const char *Literal) { - Action = PragmaMsStackAction::PushSet; + Action = Sema::PSK_Push_Set; Alignment = Tok; Alignment.setKind(tok::numeric_constant); Alignment.setLiteralData(Literal); @@ -2168,7 +2166,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, const IdentifierInfo *II = Tok.getIdentifierInfo(); if (II->isStr("show")) { - Action = PragmaMsStackAction::Show; + Action = Sema::PSK_Show; PP.Lex(Tok); } else if (II->isStr("packed") && PP.getLangOpts().ZOSExt) { // #pragma pack(packed) is the same as #pragma pack(1) @@ -2184,13 +2182,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 = PragmaMsStackAction::Pop; + Action = Sema::PSK_Pop; PP.Lex(Tok); } else { if (II->isStr("push")) { - Action = PragmaMsStackAction::Push; + Action = Sema::PSK_Push; } else if (II->isStr("pop")) { - Action = PragmaMsStackAction::Pop; + Action = Sema::PSK_Pop; } else { PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_action) << "pack"; return; @@ -2201,7 +2199,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, PP.Lex(Tok); if (Tok.is(tok::numeric_constant)) { - Action = (PragmaMsStackAction)(Action | PragmaMsStackAction::Set); + Action = (Sema::PragmaMsStackAction)(Action | Sema::PSK_Set); Alignment = Tok; PP.Lex(Tok); @@ -2217,7 +2215,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, return; } - Action = (PragmaMsStackAction)(Action | PragmaMsStackAction::Set); + Action = (Sema::PragmaMsStackAction)(Action | Sema::PSK_Set); Alignment = Tok; PP.Lex(Tok); @@ -2234,7 +2232,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 = PragmaMsStackAction::Pop; + Action = Sema::PSK_Pop; } if (Tok.isNot(tok::r_paren)) { @@ -2897,7 +2895,7 @@ void PragmaMSVtorDisp::HandlePragma(Preprocessor &PP, } PP.Lex(Tok); - PragmaMsStackAction Action = PragmaMsStackAction::Set; + Sema::PragmaMsStackAction Action = Sema::PSK_Set; const IdentifierInfo *II = Tok.getIdentifierInfo(); if (II) { if (II->isStr("push")) { @@ -2908,24 +2906,24 @@ void PragmaMSVtorDisp::HandlePragma(Preprocessor &PP, return; } PP.Lex(Tok); - Action = PragmaMsStackAction::PushSet; + Action = Sema::PSK_Push_Set; // not push, could be on/off } else if (II->isStr("pop")) { // #pragma vtordisp(pop) PP.Lex(Tok); - Action = PragmaMsStackAction::Pop; + Action = Sema::PSK_Pop; } // not push or pop, could be on/off } else { if (Tok.is(tok::r_paren)) { // #pragma vtordisp() - Action = PragmaMsStackAction::Reset; + Action = Sema::PSK_Reset; } } uint64_t Value = 0; - if (Action & PragmaMsStackAction::Push || Action & PragmaMsStackAction::Set) { + if (Action & Sema::PSK_Push || Action & Sema::PSK_Set) { const IdentifierInfo *II = Tok.getIdentifierInfo(); if (II && II->isStr("off")) { PP.Lex(Tok); @@ -3016,7 +3014,7 @@ void PragmaMSPragma::HandlePragma(Preprocessor &PP, void PragmaFloatControlHandler::HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer, Token &Tok) { - PragmaMsStackAction Action = PragmaMsStackAction::Set; + Sema::PragmaMsStackAction Action = Sema::PSK_Set; SourceLocation FloatControlLoc = Tok.getLocation(); Token PragmaName = Tok; if (!PP.getTargetInfo().hasStrictFP() && !PP.getLangOpts().ExpStrictFP) { @@ -3056,8 +3054,7 @@ void PragmaFloatControlHandler::HandlePragma(Preprocessor &PP, return; } PP.Lex(Tok); // Eat the r_paren - Action = (Kind == PFC_Pop) ? PragmaMsStackAction::Pop - : PragmaMsStackAction::Push; + Action = (Kind == PFC_Pop) ? Sema::PSK_Pop : Sema::PSK_Push; } else { if (Tok.is(tok::r_paren)) // Selecting Precise or Except @@ -3081,7 +3078,7 @@ void PragmaFloatControlHandler::HandlePragma(Preprocessor &PP, if (Kind == PFC_Except) Kind = PFC_NoExcept; } else if (PushOnOff == "push") { - Action = PragmaMsStackAction::PushSet; + Action = Sema::PSK_Push_Set; } else { PP.Diag(Tok.getLocation(), diag::err_pragma_float_control_malformed); return; @@ -3095,7 +3092,7 @@ void PragmaFloatControlHandler::HandlePragma(Preprocessor &PP, } StringRef ExpectedPush = Tok.getIdentifierInfo()->getName(); if (ExpectedPush == "push") { - Action = PragmaMsStackAction::PushSet; + Action = Sema::PSK_Push_Set; } 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 e0ebbd6e092a5..bade3a0502a2c 100644 --- a/clang/lib/Sema/SemaAttr.cpp +++ b/clang/lib/Sema/SemaAttr.cpp @@ -31,25 +31,23 @@ Sema::PragmaStackSentinelRAII::PragmaStackSentinelRAII(Sema &S, bool ShouldAct) : S(S), SlotLabel(SlotLabel), ShouldAct(ShouldAct) { if (ShouldAct) { - 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); + 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); } } Sema::PragmaStackSentinelRAII::~PragmaStackSentinelRAII() { if (ShouldAct) { - 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); + 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); } } @@ -335,7 +333,7 @@ void Sema::inferNullableClassAttribute(CXXRecordDecl *CRD) { void Sema::ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, SourceLocation PragmaLoc) { - PragmaMsStackAction Action = PragmaMsStackAction::Reset; + PragmaMsStackAction Action = Sema::PSK_Reset; AlignPackInfo::Mode ModeVal = AlignPackInfo::Native; switch (Kind) { @@ -343,17 +341,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 = PragmaMsStackAction::PushSet; + Action = Sema::PSK_Push_Set; break; case POAK_Natural: - Action = PragmaMsStackAction::PushSet; + Action = Sema::PSK_Push_Set; 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 = PragmaMsStackAction::PushSet; + Action = Sema::PSK_Push_Set; ModeVal = AlignPackInfo::Packed; break; @@ -363,17 +361,17 @@ void Sema::ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, Diag(PragmaLoc, diag::err_pragma_options_align_mac68k_target_unsupported); return; } - Action = PragmaMsStackAction::PushSet; + Action = Sema::PSK_Push_Set; ModeVal = AlignPackInfo::Mac68k; break; case POAK_Reset: // Reset just pops the top of the stack, or resets the current alignment to // default. - Action = PragmaMsStackAction::Pop; + Action = Sema::PSK_Pop; if (AlignPackStack.Stack.empty()) { if (AlignPackStack.CurrentValue.getAlignMode() != AlignPackInfo::Native || AlignPackStack.CurrentValue.IsPackAttr()) { - Action = PragmaMsStackAction::Reset; + Action = Sema::PSK_Reset; } else { Diag(PragmaLoc, diag::warn_pragma_options_align_reset_failed) << "stack empty"; @@ -474,7 +472,7 @@ void Sema::ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action, AlignmentVal = (unsigned)Val->getZExtValue(); } - if (Action == PragmaMsStackAction::Show) { + if (Action == Sema::PSK_Show) { // Show the current alignment, making sure to show the right value // for the default. // FIXME: This should come from the target. @@ -488,7 +486,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 & PragmaMsStackAction::Pop) { + if (Action & Sema::PSK_Pop) { if (Alignment && !SlotLabel.empty()) Diag(PragmaLoc, diag::warn_pragma_pack_pop_identifier_and_alignment); if (AlignPackStack.Stack.empty()) { @@ -658,7 +656,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, PragmaMsStackAction::Set, StringRef(), NewFPFeatures); + FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures); CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts()); PP.setCurrentFPEvalMethod(Loc, Value); } @@ -667,9 +665,7 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc, PragmaMsStackAction Action, PragmaFloatControlKind Value) { FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides(); - if ((Action == PragmaMsStackAction::PushSet || - Action == PragmaMsStackAction::Push || - Action == PragmaMsStackAction::Pop) && + if ((Action == PSK_Push_Set || Action == PSK_Push || Action == PSK_Pop) && !CurContext->getRedeclContext()->isFileContext()) { // Push and pop can only occur at file or namespace scope, or within a // language linkage declaration. @@ -704,8 +700,7 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc, FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures); break; case PFC_Push: - FpPragmaStack.Act(Loc, PragmaMsStackAction::PushSet, StringRef(), - NewFPFeatures); + FpPragmaStack.Act(Loc, Sema::PSK_Push_Set, StringRef(), NewFPFeatures); break; case PFC_Pop: if (FpPragmaStack.Stack.empty()) { @@ -730,7 +725,7 @@ void Sema::ActOnPragmaMSPointersToMembers( void Sema::ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, SourceLocation PragmaLoc, MSVtorDispMode Mode) { - if (Action & PragmaMsStackAction::Pop && VtorDispStack.Stack.empty()) + if (Action & PSK_Pop && VtorDispStack.Stack.empty()) Diag(PragmaLoc, diag::warn_pragma_pop_failed) << "vtordisp" << "stack empty"; VtorDispStack.Act(PragmaLoc, Action, StringRef(), Mode); @@ -741,15 +736,15 @@ void Sema::PragmaStack<Sema::AlignPackInfo>::Act(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, AlignPackInfo Value) { - if (Action == PragmaMsStackAction::Reset) { + if (Action == PSK_Reset) { CurrentValue = DefaultValue; CurrentPragmaLocation = PragmaLocation; return; } - if (Action & PragmaMsStackAction::Push) + if (Action & PSK_Push) Stack.emplace_back(Slot(StackSlotLabel, CurrentValue, CurrentPragmaLocation, PragmaLocation)); - else if (Action & PragmaMsStackAction::Pop) { + else if (Action & PSK_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) { @@ -792,7 +787,7 @@ void Sema::PragmaStack<Sema::AlignPackInfo>::Act(SourceLocation PragmaLocation, Stack.pop_back(); } } - if (Action & PragmaMsStackAction::Set) { + if (Action & PSK_Set) { CurrentValue = Value; CurrentPragmaLocation = PragmaLocation; } @@ -861,7 +856,7 @@ void Sema::ActOnPragmaMSSeg(SourceLocation PragmaLocation, .Case("bss_seg", &BSSSegStack) .Case("const_seg", &ConstSegStack) .Case("code_seg", &CodeSegStack); - if (Action & PragmaMsStackAction::Pop && Stack->Stack.empty()) + if (Action & PSK_Pop && Stack->Stack.empty()) Diag(PragmaLocation, diag::warn_pragma_pop_failed) << PragmaName << "stack empty"; if (SegmentName) { @@ -880,8 +875,7 @@ void Sema::ActOnPragmaMSSeg(SourceLocation PragmaLocation, void Sema::ActOnPragmaMSStrictGuardStackCheck(SourceLocation PragmaLocation, PragmaMsStackAction Action, bool Value) { - if (Action & PragmaMsStackAction::Pop && - StrictGuardStackCheckStack.Stack.empty()) + if (Action & PSK_Pop && StrictGuardStackCheckStack.Stack.empty()) Diag(PragmaLocation, diag::warn_pragma_pop_failed) << "strict_gs_check" << "stack empty"; @@ -1400,7 +1394,7 @@ void Sema::ActOnPragmaFPContract(SourceLocation Loc, NewFPFeatures.setDisallowFPContract(); break; } - FpPragmaStack.Act(Loc, PragmaMsStackAction::Set, StringRef(), NewFPFeatures); + FpPragmaStack.Act(Loc, Sema::PSK_Set, StringRef(), NewFPFeatures); CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts()); } @@ -1436,14 +1430,14 @@ void Sema::ActOnPragmaFPValueChangingOption(SourceLocation Loc, llvm_unreachable("unhandled value changing pragma fp"); } - FpPragmaStack.Act(Loc, PragmaMsStackAction::Set, StringRef(), NewFPFeatures); + FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures); CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts()); } void Sema::ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode FPR) { FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides(); NewFPFeatures.setConstRoundingModeOverride(FPR); - FpPragmaStack.Act(Loc, PragmaMsStackAction::Set, StringRef(), NewFPFeatures); + FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures); CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts()); } @@ -1451,7 +1445,7 @@ void Sema::setExceptionMode(SourceLocation Loc, LangOptions::FPExceptionModeKind FPE) { FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides(); NewFPFeatures.setSpecifiedExceptionModeOverride(FPE); - FpPragmaStack.Act(Loc, PragmaMsStackAction::Set, StringRef(), NewFPFeatures); + FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures); CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts()); } @@ -1467,7 +1461,7 @@ void Sema::ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled) { } NewFPFeatures.setAllowFEnvAccessOverride(IsEnabled); NewFPFeatures.setRoundingMathOverride(IsEnabled); - FpPragmaStack.Act(Loc, PragmaMsStackAction::Set, StringRef(), NewFPFeatures); + FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures); CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts()); } @@ -1475,7 +1469,7 @@ void Sema::ActOnPragmaCXLimitedRange(SourceLocation Loc, LangOptions::ComplexRangeKind Range) { FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides(); NewFPFeatures.setComplexRangeOverride(Range); - FpPragmaStack.Act(Loc, PragmaMsStackAction::Set, StringRef(), NewFPFeatures); + FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures); CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts()); } diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 5459b3aee958d..f13a173ec933e 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<PragmaMsStackAction>(Record[Idx++]); + Info->Action = static_cast<Sema::PragmaMsStackAction>(Record[Idx++]); auto SlotLabel = ReadString(Record, Idx); Info->SlotLabel = llvm::StringRef(SlotLabel).copy(PP.getPreprocessorAllocator()); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits