https://github.com/mrcvtl updated
https://github.com/llvm/llvm-project/pull/145164
>From 37c57131c397d4aeaef7fe5b860d1983f1e4bdc2 Mon Sep 17 00:00:00 2001
From: Marco Vitale
Date: Sat, 21 Jun 2025 14:01:53 +0200
Subject: [PATCH] [Sema] Fix lifetime extension for temporaries in range-based
for
https://github.com/mrcvtl deleted
https://github.com/llvm/llvm-project/pull/145164
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/mrcvtl deleted
https://github.com/llvm/llvm-project/pull/145164
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -1585,6 +1590,20 @@ class VarDecl : public DeclaratorDecl, public
Redeclarable {
NonParmVarDeclBits.IsCXXCondDecl = true;
}
+ /// Determine whether this variable is the compiler-generated '__range'
+ /// variable used to hold the range expression in a C++11 and lat
@@ -2740,6 +2741,7 @@ void ASTWriter::WriteDeclAbbrevs() {
// isInline, isInlineSpecified, isConstexpr,
// isInitCapture, isPrevDeclInSameScope, hasInitWithSideEffects,
// EscapingByref, HasDeducedType, ImplicitParamKind, isObjCForDecl
+
mrcvtl wrote:
> > but why can’t we use InLifetimeExtendingContext flag here?
> > Is there a subtle difference I’m missing?
>
> This flag will tiger subroutines to collect `MaterializedTemporaryExpr` and
> rebuild default init/arg。 All we need to know here is that `ExtendingDecl` is
> a C++ `__
https://github.com/mrcvtl updated
https://github.com/llvm/llvm-project/pull/145164
>From b5146278ce5059b6bf0312f18f509022de5fd661 Mon Sep 17 00:00:00 2001
From: Marco Vitale
Date: Sat, 21 Jun 2025 14:01:53 +0200
Subject: [PATCH 1/2] [Sema] Fix lifetime extension for temporaries in
range-based
mrcvtl wrote:
> IMO, we have 2 options:
>
> 1. Add a flag variable into `ExpressionEvaluationContextRecord`. Represent
> that we are initializing the for-range __range variable.
>Eg.
>
> ```diff
> diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
> index 939754
mrcvtl wrote:
I’ve taken some time to better understand the code and think through the
solution.
I tried using `isInLifetimeExtendingContext()`, but it still returns false, and
I believe I now understand why. In your PR, the flag is set here:
https://github.com/llvm/llvm-project/blob/b581f9d05
https://github.com/mrcvtl ready_for_review
https://github.com/llvm/llvm-project/pull/145164
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
mrcvtl wrote:
A couple of quick notes:
- This is my first LLVM PR, so if there are any issues with code style or
conventions, please let me know!
- I'm not entirely satisfied with the `VD->getName().starts_with("__range")`
check, but it was the most reliable approach I found. Walking up the AS
https://github.com/mrcvtl edited
https://github.com/llvm/llvm-project/pull/145164
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
mrcvtl wrote:
> Could you associate this PR with the issue to fix, if any?
Done!
https://github.com/llvm/llvm-project/pull/145164
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/mrcvtl created
https://github.com/llvm/llvm-project/pull/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 corre
14 matches
Mail list logo