[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)
Boaz Brickner via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 17 01:06:04 PDT 2024
================
@@ -1091,21 +1104,22 @@ static bool isAssignmentOperatorLifetimeBound(CXXMethodDecl *CMD) {
}
static bool shouldRunGSLAssignmentAnalysis(const Sema &SemaRef,
- const AssignedEntity &Entity) {
+ const CapturingEntity &Entity) {
bool EnableGSLAssignmentWarnings = !SemaRef.getDiagnostics().isIgnored(
diag::warn_dangling_lifetime_pointer_assignment, SourceLocation());
return (EnableGSLAssignmentWarnings &&
- (isRecordWithAttr<PointerAttr>(Entity.LHS->getType()) ||
+ (isRecordWithAttr<PointerAttr>(Entity.Expression->getType()) ||
isAssignmentOperatorLifetimeBound(Entity.AssignmentOperator)));
}
static void checkExprLifetimeImpl(Sema &SemaRef,
----------------
bricknerb wrote:
IIUC, this function handles different use cases and for different use cases it needs different args to be set.
Since it's becoming more complex with this change, would it make sense to split it to different functions and only reuse the shared logic between the different use cases?
I think this could simplify the asserts and make the calling this method much clearer and safer.
https://github.com/llvm/llvm-project/pull/111499
More information about the cfe-commits
mailing list