================
@@ -1023,7 +1023,7 @@ static void checkExprLifetimeImpl(Sema &SemaRef,
         return false;
       }
 
-      if (IsGslPtrInitWithGslTempOwner && DiagLoc.isValid()) {
+      if (InitEntity && IsGslPtrInitWithGslTempOwner && DiagLoc.isValid()) {
----------------
usx95 wrote:

I think it would be simpler to just handle `AEntity` before:
```cpp
if(AEntity) {
  assert(shouldLifetimeExtendThroughPath(Path) == PathLifetimeKind::NoExtend);
  assert(LK == LK_Extended);
  if (!pathContainsInit(path)) {
    SemaRef.Diag(DiagLoc, diag::warn_dangling_pointer_assignment)
              << AEntity->LHS << DiagRange;
  }
  return;
}
assert(InitEntity);
switch (LK) {
...
<remove assert(InitEntity*) checks>
```

https://github.com/llvm/llvm-project/pull/97408
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to