[clang] [Clang] Add fake use emission to Clang with -fextend-lifetimes (PR #110102)

Jeremy Morse via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 29 10:04:05 PST 2024


================
@@ -112,11 +112,11 @@ void EHScopeStack::deallocate(size_t Size) {
   StartOfData += llvm::alignTo(Size, ScopeStackAlignment);
 }
 
-bool EHScopeStack::containsOnlyLifetimeMarkers(
+bool EHScopeStack::containsOnlyNoopCleanups(
     EHScopeStack::stable_iterator Old) const {
   for (EHScopeStack::iterator it = begin(); stabilize(it) != Old; it++) {
     EHCleanupScope *cleanup = dyn_cast<EHCleanupScope>(&*it);
-    if (!cleanup || !cleanup->isLifetimeMarker())
+    if (!cleanup || !(cleanup->isLifetimeMarker() || cleanup->isFakeUse()))
----------------
jmorse wrote:

I feel like the number of inversions here makes it harder to read; how about the suggestion,
```suggestion
    if (!cleanup)
      return false
    if (!cleanup->isLifetimeMarker() && !cleanup->isFakeUse()))
      return false;
```
I.e. it's slightly clearer that it's a dont-dereference-null check and a is-it-not-a-noop check.

https://github.com/llvm/llvm-project/pull/110102


More information about the cfe-commits mailing list