aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ASTWriterDecl.cpp
diff options
context:
space:
mode:
authorHenrik G. Olsson <hnrklssn@gmail.com>2025-06-23 20:20:15 -0700
committerGitHub <noreply@github.com>2025-06-23 20:20:15 -0700
commit37eb465710b45e0e56e6e7f662fd6b252bf0d309 (patch)
treed9ddfcc7efbc32ed8a6ab234f07cf25323e51eb4 /clang/lib/Serialization/ASTWriterDecl.cpp
parent0fcced7d791f5be3f5f9fa6e561854716b11d4e8 (diff)
downloadllvm-37eb465710b45e0e56e6e7f662fd6b252bf0d309.zip
llvm-37eb465710b45e0e56e6e7f662fd6b252bf0d309.tar.gz
llvm-37eb465710b45e0e56e6e7f662fd6b252bf0d309.tar.bz2
Reland "[Modules] Record whether VarDecl initializers contain side effects" (#145447)
This reverts commit 329ae86 and adds an early exit for EvaluateInPlace when the expression's type is null.
Diffstat (limited to 'clang/lib/Serialization/ASTWriterDecl.cpp')
-rw-r--r--clang/lib/Serialization/ASTWriterDecl.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp
index 2d93832..2e390db 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1306,6 +1306,7 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
VarDeclBits.addBit(D->isConstexpr());
VarDeclBits.addBit(D->isInitCapture());
VarDeclBits.addBit(D->isPreviousDeclInSameBlockScope());
+ VarDeclBits.addBit(D->hasInitWithSideEffects());
VarDeclBits.addBit(D->isEscapingByref());
HasDeducedType = D->getType()->getContainedDeducedType();
@@ -1355,10 +1356,11 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
!D->hasExtInfo() && D->getFirstDecl() == D->getMostRecentDecl() &&
D->getKind() == Decl::Var && !D->isInline() && !D->isConstexpr() &&
!D->isInitCapture() && !D->isPreviousDeclInSameBlockScope() &&
- !D->isEscapingByref() && !HasDeducedType &&
- D->getStorageDuration() != SD_Static && !D->getDescribedVarTemplate() &&
- !D->getMemberSpecializationInfo() && !D->isObjCForDecl() &&
- !isa<ImplicitParamDecl>(D) && !D->isEscapingByref())
+ !D->hasInitWithSideEffects() && !D->isEscapingByref() &&
+ !HasDeducedType && D->getStorageDuration() != SD_Static &&
+ !D->getDescribedVarTemplate() && !D->getMemberSpecializationInfo() &&
+ !D->isObjCForDecl() && !isa<ImplicitParamDecl>(D) &&
+ !D->isEscapingByref())
AbbrevToUse = Writer.getDeclVarAbbrev();
Code = serialization::DECL_VAR;
@@ -2731,12 +2733,12 @@ void ASTWriter::WriteDeclAbbrevs() {
// VarDecl
Abv->Add(BitCodeAbbrevOp(
BitCodeAbbrevOp::Fixed,
- 21)); // Packed Var Decl bits: Linkage, ModulesCodegen,
+ 22)); // Packed Var Decl bits: Linkage, ModulesCodegen,
// SClass, TSCSpec, InitStyle,
// isARCPseudoStrong, IsThisDeclarationADemotedDefinition,
// isExceptionVariable, isNRVOVariable, isCXXForRangeDecl,
// isInline, isInlineSpecified, isConstexpr,
- // isInitCapture, isPrevDeclInSameScope,
+ // isInitCapture, isPrevDeclInSameScope, hasInitWithSideEffects,
// EscapingByref, HasDeducedType, ImplicitParamKind, isObjCForDecl
Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
// Type Source Info