[PATCH] D143410: [Serialization] Add support for (de)serializing #pragma pack

Dustin L. Howett via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 6 10:09:28 PST 2023


DHowett-MSFT created this revision.
Herald added a project: All.
DHowett-MSFT updated this revision to Diff 495195.
DHowett-MSFT added a comment.
DHowett-MSFT published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Add a test


DHowett-MSFT added a comment.

This is a fix for https://github.com/llvm/llvm-project/issues/60543.

I originally approached this fix by moving `PragmaPackOptions` up to `Lex/Token.h` to live near `PragmaLoopHintInfo`; however, that required moving much more of the `PragmaMsStack` machinery than I was comfortable with.

There is precedent for some pragma infos living in `Sema` as well as `ASTReader`/`ASTWriter` poking into `Sema` to do their jobs.

I've included a test that both validates that the frontend no longer crashes _and_ that the resultant structures are packed as expected.


Without this, GCH serialization of late template expansions will
encounter an assertion failure.

Changes were required to ASTReader::ReadString to add support for
reading a string from a RecordDataImpl (which is the type consumed by
ReadToken) rather than a RecordData.

`#pragma pack` slot names are read into the preexisting string storage
PragmaAlignPackStrings.

This requires incidental changes [Parse,Sema] to move PragmaPackInfo to Sema

There is precedent for ASTReader/ASTWriter to poke into Sema.

Fixes https://github.com/llvm/llvm-project/issues/60543


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143410

Files:
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/PCH/delayed-template-with-pragma-pack.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143410.495195.patch
Type: text/x-patch
Size: 5188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230206/20ef6908/attachment-0001.bin>


More information about the cfe-commits mailing list