diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -483,6 +483,12 @@ PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value) }; + struct PragmaPackInfo { + PragmaMsStackAction Action; + StringRef SlotLabel; + Token Alignment; + }; + // #pragma pack and align. class AlignPackInfo { public: diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -2236,7 +2236,7 @@ unsigned &Idx, LocSeq *Seq = nullptr); // Read a string - static std::string ReadString(const RecordData &Record, unsigned &Idx); + static std::string ReadString(const RecordDataImpl &Record, unsigned &Idx); // Skip a string static void SkipString(const RecordData &Record, unsigned &Idx) { diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp --- a/clang/lib/Parse/ParsePragma.cpp +++ b/clang/lib/Parse/ParsePragma.cpp @@ -665,18 +665,10 @@ Actions.ActOnPragmaVisibility(VisType, VisLoc); } -namespace { -struct PragmaPackInfo { - Sema::PragmaMsStackAction Action; - StringRef SlotLabel; - Token Alignment; -}; -} // end anonymous namespace - void Parser::HandlePragmaPack() { assert(Tok.is(tok::annot_pragma_pack)); - PragmaPackInfo *Info = - static_cast(Tok.getAnnotationValue()); + Sema::PragmaPackInfo *Info = + static_cast(Tok.getAnnotationValue()); SourceLocation PragmaLoc = Tok.getLocation(); ExprResult Alignment; if (Info->Alignment.is(tok::numeric_constant)) { @@ -2110,8 +2102,8 @@ return; } - PragmaPackInfo *Info = - PP.getPreprocessorAllocator().Allocate(1); + Sema::PragmaPackInfo *Info = + PP.getPreprocessorAllocator().Allocate(1); Info->Action = Action; Info->SlotLabel = SlotLabel; Info->Alignment = Alignment; diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -1687,6 +1687,15 @@ Tok.setAnnotationValue(static_cast(Info)); break; } + case tok::annot_pragma_pack: { + auto *Info = new (PP.getPreprocessorAllocator()) Sema::PragmaPackInfo; + Info->Action = static_cast(Record[Idx++]); + PragmaAlignPackStrings.push_back(ReadString(Record, Idx)); + Info->SlotLabel = PragmaAlignPackStrings.back(); + Info->Alignment = ReadToken(F, Record, Idx); + Tok.setAnnotationValue(static_cast(Info)); + break; + } // Some annotation tokens do not use the PtrData field. case tok::annot_pragma_openmp: case tok::annot_pragma_openmp_end: @@ -9089,7 +9098,7 @@ } // Read a string -std::string ASTReader::ReadString(const RecordData &Record, unsigned &Idx) { +std::string ASTReader::ReadString(const RecordDataImpl &Record, unsigned &Idx) { unsigned Len = Record[Idx++]; std::string Result(Record.data() + Idx, Record.data() + Idx + Len); Idx += Len; diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -4412,6 +4412,14 @@ AddToken(T, Record); break; } + case tok::annot_pragma_pack: { + auto *Info = + static_cast(Tok.getAnnotationValue()); + Record.push_back(static_cast(Info->Action)); + AddString(Info->SlotLabel, Record); + AddToken(Info->Alignment, Record); + break; + } // Some annotation tokens do not use the PtrData field. case tok::annot_pragma_openmp: case tok::annot_pragma_openmp_end: