@@ -337,11 +337,9 @@ void Parser::HandlePragmaVisibility() {
337
337
338
338
namespace {
339
339
struct PragmaPackInfo {
340
- Sema::PragmaPackKind Kind ;
341
- IdentifierInfo *Name ;
340
+ Sema::PragmaMsStackAction Action ;
341
+ StringRef SlotLabel ;
342
342
Token Alignment;
343
- SourceLocation LParenLoc;
344
- SourceLocation RParenLoc;
345
343
};
346
344
} // end anonymous namespace
347
345
@@ -356,8 +354,8 @@ void Parser::HandlePragmaPack() {
356
354
if (Alignment.isInvalid ())
357
355
return ;
358
356
}
359
- Actions.ActOnPragmaPack (Info->Kind , Info->Name , Alignment. get (), PragmaLoc ,
360
- Info-> LParenLoc , Info-> RParenLoc );
357
+ Actions.ActOnPragmaPack (PragmaLoc, Info->Action , Info->SlotLabel ,
358
+ Alignment. get () );
361
359
}
362
360
363
361
void Parser::HandlePragmaMSStruct () {
@@ -962,11 +960,10 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP,
962
960
return ;
963
961
}
964
962
965
- Sema::PragmaPackKind Kind = Sema::PPK_Default ;
966
- IdentifierInfo *Name = nullptr ;
963
+ Sema::PragmaMsStackAction Action = Sema::PSK_Reset ;
964
+ StringRef SlotLabel ;
967
965
Token Alignment;
968
966
Alignment.startToken ();
969
- SourceLocation LParenLoc = Tok.getLocation ();
970
967
PP.Lex (Tok);
971
968
if (Tok.is (tok::numeric_constant)) {
972
969
Alignment = Tok;
@@ -976,18 +973,18 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP,
976
973
// In MSVC/gcc, #pragma pack(4) sets the alignment without affecting
977
974
// the push/pop stack.
978
975
// In Apple gcc, #pragma pack(4) is equivalent to #pragma pack(push, 4)
979
- if (PP. getLangOpts (). ApplePragmaPack )
980
- Kind = Sema::PPK_Push ;
976
+ Action =
977
+ PP. getLangOpts (). ApplePragmaPack ? Sema::PSK_Push_Set : Sema::PSK_Set ;
981
978
} else if (Tok.is (tok::identifier)) {
982
979
const IdentifierInfo *II = Tok.getIdentifierInfo ();
983
980
if (II->isStr (" show" )) {
984
- Kind = Sema::PPK_Show ;
981
+ Action = Sema::PSK_Show ;
985
982
PP.Lex (Tok);
986
983
} else {
987
984
if (II->isStr (" push" )) {
988
- Kind = Sema::PPK_Push ;
985
+ Action = Sema::PSK_Push ;
989
986
} else if (II->isStr (" pop" )) {
990
- Kind = Sema::PPK_Pop ;
987
+ Action = Sema::PSK_Pop ;
991
988
} else {
992
989
PP.Diag (Tok.getLocation (), diag::warn_pragma_invalid_action) << " pack" ;
993
990
return ;
@@ -998,11 +995,12 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP,
998
995
PP.Lex (Tok);
999
996
1000
997
if (Tok.is (tok::numeric_constant)) {
998
+ Action = (Sema::PragmaMsStackAction)(Action | Sema::PSK_Set);
1001
999
Alignment = Tok;
1002
1000
1003
1001
PP.Lex (Tok);
1004
1002
} else if (Tok.is (tok::identifier)) {
1005
- Name = Tok.getIdentifierInfo ();
1003
+ SlotLabel = Tok.getIdentifierInfo ()-> getName ();
1006
1004
PP.Lex (Tok);
1007
1005
1008
1006
if (Tok.is (tok::comma)) {
@@ -1013,6 +1011,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP,
1013
1011
return ;
1014
1012
}
1015
1013
1014
+ Action = (Sema::PragmaMsStackAction)(Action | Sema::PSK_Set);
1016
1015
Alignment = Tok;
1017
1016
1018
1017
PP.Lex (Tok);
@@ -1027,7 +1026,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP,
1027
1026
// In MSVC/gcc, #pragma pack() resets the alignment without affecting
1028
1027
// the push/pop stack.
1029
1028
// In Apple gcc #pragma pack() is equivalent to #pragma pack(pop).
1030
- Kind = Sema::PPK_Pop ;
1029
+ Action = Sema::PSK_Pop ;
1031
1030
}
1032
1031
1033
1032
if (Tok.isNot (tok::r_paren)) {
@@ -1044,11 +1043,9 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP,
1044
1043
1045
1044
PragmaPackInfo *Info =
1046
1045
PP.getPreprocessorAllocator ().Allocate <PragmaPackInfo>(1 );
1047
- Info->Kind = Kind ;
1048
- Info->Name = Name ;
1046
+ Info->Action = Action ;
1047
+ Info->SlotLabel = SlotLabel ;
1049
1048
Info->Alignment = Alignment;
1050
- Info->LParenLoc = LParenLoc;
1051
- Info->RParenLoc = RParenLoc;
1052
1049
1053
1050
MutableArrayRef<Token> Toks (PP.getPreprocessorAllocator ().Allocate <Token>(1 ),
1054
1051
1 );
0 commit comments