-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang] fix serialization for SubstNonTypeTemplateParmPackExpr #135428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang] fix serialization for SubstNonTypeTemplateParmPackExpr #135428
Conversation
This fixes a PCM non-determinism regression reported here: #134560 (comment) There was a bit in `SubstNonTypeTemplateParmPackExpr` which we missed to serialize, and that bit eventually propagates to `SubstNonTypeTemplateParmExpr`. As a drive by, improve serialization for PackIndex on SubstNonTypeTemplateParmExpr by using the newly introduced UnsignedOrNone helpers. There are no release notes since this regression was never released.
@llvm/pr-subscribers-clang Author: Matheus Izvekov (mizvekov) ChangesThis fixes a PCM non-determinism regression reported here: #134560 (comment) There was a bit in As a drive by, improve serialization for PackIndex on SubstNonTypeTemplateParmExpr by using the newly introduced UnsignedOrNone helpers. There are no release notes since this regression was never released. Full diff: https://github.com/llvm/llvm-project/pull/135428.diff 2 Files Affected:
diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp
index 715aaf6452264..f41cfcc53a35d 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -2226,10 +2226,7 @@ void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
E->AssociatedDeclAndRef.setPointer(readDeclAs<Decl>());
E->AssociatedDeclAndRef.setInt(CurrentUnpackingBits->getNextBit());
E->Index = CurrentUnpackingBits->getNextBits(/*Width=*/12);
- if (CurrentUnpackingBits->getNextBit())
- E->PackIndex = Record.readInt();
- else
- E->PackIndex = 0;
+ E->PackIndex = Record.readUnsignedOrNone().toInternalRepresentation();
E->Final = CurrentUnpackingBits->getNextBit();
E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
E->Replacement = Record.readSubExpr();
@@ -2239,6 +2236,7 @@ void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
SubstNonTypeTemplateParmPackExpr *E) {
VisitExpr(E);
E->AssociatedDecl = readDeclAs<Decl>();
+ E->Final = CurrentUnpackingBits->getNextBit();
E->Index = Record.readInt();
TemplateArgument ArgPack = Record.readTemplateArgument();
if (ArgPack.getKind() != TemplateArgument::Pack)
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index 939b37c547349..b9eabd5ddb64c 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -2228,9 +2228,7 @@ void ASTStmtWriter::VisitSubstNonTypeTemplateParmExpr(
Record.AddDeclRef(E->getAssociatedDecl());
CurrentPackingBits.addBit(E->isReferenceParameter());
CurrentPackingBits.addBits(E->getIndex(), /*Width=*/12);
- CurrentPackingBits.addBit((bool)E->getPackIndex());
- if (auto PackIndex = E->getPackIndex())
- Record.push_back(*PackIndex + 1);
+ Record.writeUnsignedOrNone(E->getPackIndex());
CurrentPackingBits.addBit(E->getFinal());
Record.AddSourceLocation(E->getNameLoc());
@@ -2242,6 +2240,7 @@ void ASTStmtWriter::VisitSubstNonTypeTemplateParmPackExpr(
SubstNonTypeTemplateParmPackExpr *E) {
VisitExpr(E);
Record.AddDeclRef(E->getAssociatedDecl());
+ CurrentPackingBits.addBit(E->getFinal());
Record.push_back(E->getIndex());
Record.AddTemplateArgument(E->getArgumentPack());
Record.AddSourceLocation(E->getParameterPackLocation());
|
@llvm/pr-subscribers-clang-modules Author: Matheus Izvekov (mizvekov) ChangesThis fixes a PCM non-determinism regression reported here: #134560 (comment) There was a bit in As a drive by, improve serialization for PackIndex on SubstNonTypeTemplateParmExpr by using the newly introduced UnsignedOrNone helpers. There are no release notes since this regression was never released. Full diff: https://github.com/llvm/llvm-project/pull/135428.diff 2 Files Affected:
diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp
index 715aaf6452264..f41cfcc53a35d 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -2226,10 +2226,7 @@ void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
E->AssociatedDeclAndRef.setPointer(readDeclAs<Decl>());
E->AssociatedDeclAndRef.setInt(CurrentUnpackingBits->getNextBit());
E->Index = CurrentUnpackingBits->getNextBits(/*Width=*/12);
- if (CurrentUnpackingBits->getNextBit())
- E->PackIndex = Record.readInt();
- else
- E->PackIndex = 0;
+ E->PackIndex = Record.readUnsignedOrNone().toInternalRepresentation();
E->Final = CurrentUnpackingBits->getNextBit();
E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
E->Replacement = Record.readSubExpr();
@@ -2239,6 +2236,7 @@ void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
SubstNonTypeTemplateParmPackExpr *E) {
VisitExpr(E);
E->AssociatedDecl = readDeclAs<Decl>();
+ E->Final = CurrentUnpackingBits->getNextBit();
E->Index = Record.readInt();
TemplateArgument ArgPack = Record.readTemplateArgument();
if (ArgPack.getKind() != TemplateArgument::Pack)
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index 939b37c547349..b9eabd5ddb64c 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -2228,9 +2228,7 @@ void ASTStmtWriter::VisitSubstNonTypeTemplateParmExpr(
Record.AddDeclRef(E->getAssociatedDecl());
CurrentPackingBits.addBit(E->isReferenceParameter());
CurrentPackingBits.addBits(E->getIndex(), /*Width=*/12);
- CurrentPackingBits.addBit((bool)E->getPackIndex());
- if (auto PackIndex = E->getPackIndex())
- Record.push_back(*PackIndex + 1);
+ Record.writeUnsignedOrNone(E->getPackIndex());
CurrentPackingBits.addBit(E->getFinal());
Record.AddSourceLocation(E->getNameLoc());
@@ -2242,6 +2240,7 @@ void ASTStmtWriter::VisitSubstNonTypeTemplateParmPackExpr(
SubstNonTypeTemplateParmPackExpr *E) {
VisitExpr(E);
Record.AddDeclRef(E->getAssociatedDecl());
+ CurrentPackingBits.addBit(E->getFinal());
Record.push_back(E->getIndex());
Record.AddTemplateArgument(E->getArgumentPack());
Record.AddSourceLocation(E->getParameterPackLocation());
|
* origin/main: (287 commits) [Sema] On Windows, silence erroneous warning when building with MSVC [lldb][lldbp-dap] On Windoows, silence warnings when building with MSVC [lldb] Fix erroneous return value [compiler-rt] On Windows, silence warning when building with Clang ToT [clang][unittests] On Windows, silence warning when building with MSVC [lldb] On Windows, silence warning when building with Clang ToT [CIR] Make LLVM & OGCG variables match the same pattern (llvm#135427) [mlir][SMT] upstream `SMT` dialect (llvm#131480) [clang] fix serialization for SubstNonTypeTemplateParmPackExpr (llvm#135428) [flang][openacc] Allow if_present multiple times on host_data and update (llvm#135422) [flang][openacc] Allow finalize clause on exit data more than once (llvm#135415) [flang] IEEE_SCALB and SCALE - kind=2, kind=3 (llvm#135374) [-Wunsafe-buffer-usage] Add findUnsafePointers (llvm#135421) [compiler-rt][sanitizer] add Haiku support (llvm#134772) [cpp23] Remove usage of std::aligned_union<> in llvm (llvm#135146) [mlir][tosa] Add error_if checks for Mul Op (llvm#135075) [VPlan] Merge cases using getResultType in inferScalarType (NFC). [flang][runtime] Fix recently broken big-endian formatted integer input (llvm#135417) [AMDGPU][Verifier] Mark calls to entry functions as invalid in the IR verifier (llvm#134910) [llvm][Hexagon] Promote operand v2i1 to v2i32 (llvm#135409) ...
…135428) This fixes a PCM non-determinism regression reported here: llvm#134560 (comment) There was a bit in `SubstNonTypeTemplateParmPackExpr` which we missed to serialize, and that bit eventually propagates to `SubstNonTypeTemplateParmExpr`. As a drive by, improve serialization for PackIndex on SubstNonTypeTemplateParmExpr by using the newly introduced UnsignedOrNone helpers. There are no release notes since this regression was never released.
This fixes a PCM non-determinism regression reported here: #134560 (comment)
There was a bit in
SubstNonTypeTemplateParmPackExpr
which we missed to serialize, and that bit eventually propagates toSubstNonTypeTemplateParmExpr
.As a drive by, improve serialization for PackIndex on SubstNonTypeTemplateParmExpr by using the newly introduced UnsignedOrNone helpers.
There are no release notes since this regression was never released.