aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ASTWriterDecl.cpp
diff options
context:
space:
mode:
authorMarco Vitale <53484928+mrcvtl@users.noreply.github.com>2025-07-10 03:57:07 +0200
committerGitHub <noreply@github.com>2025-07-10 09:57:07 +0800
commitc86c815fc57c098ba14576fe2bb189da1dfc820d (patch)
tree33d4bcead45d6e30ac971c046dd0334a5ec6ca2d /clang/lib/Serialization/ASTWriterDecl.cpp
parentf1c4df5b7bb79efb3e9be7fa5f8176506499d0a6 (diff)
downloadllvm-c86c815fc57c098ba14576fe2bb189da1dfc820d.zip
llvm-c86c815fc57c098ba14576fe2bb189da1dfc820d.tar.gz
llvm-c86c815fc57c098ba14576fe2bb189da1dfc820d.tar.bz2
[Sema] Fix lifetime extension for temporaries in range-based for loops in C++23 (#145164)
C++23 mandates that temporaries used in range-based for loops are lifetime-extended to cover the full loop. This patch adds a check for loop variables and compiler- generated `__range` bindings to apply the correct extension. Includes test cases based on examples from CWG900/P2644R1. Fixes https://github.com/llvm/llvm-project/issues/109793
Diffstat (limited to 'clang/lib/Serialization/ASTWriterDecl.cpp')
-rw-r--r--clang/lib/Serialization/ASTWriterDecl.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp
index b8a68af..e414910 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1317,6 +1317,7 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
VarDeclBits.addBits(0, /*Width=*/3);
VarDeclBits.addBit(D->isObjCForDecl());
+ VarDeclBits.addBit(D->isCXXForRangeImplicitVar());
}
Record.push_back(VarDeclBits);
@@ -2738,6 +2739,7 @@ void ASTWriter::WriteDeclAbbrevs() {
// isInline, isInlineSpecified, isConstexpr,
// isInitCapture, isPrevDeclInSameScope, hasInitWithSideEffects,
// EscapingByref, HasDeducedType, ImplicitParamKind, isObjCForDecl
+ // IsCXXForRangeImplicitVar
Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
// Type Source Info
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));