[PATCH] D153273: [analyzer] Rework support for CFGScopeBegin, CFGScopeEnd, CFGLifetime elements

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 12 04:24:40 PDT 2023


steakhal added inline comments.


================
Comment at: clang/lib/Analysis/CFG.cpp:1819-1826
+  for (std::size_t idx = 1, count = LocalScopeEndMarkers.size(); idx < count;
+       ++idx) {
+    LocalScope::const_iterator B = LocalScopeEndMarkers[idx];
+    LocalScope::const_iterator E = LocalScopeEndMarkers[idx - 1];
+    if (!B.inSameLocalScope(E))
+      addScopeExitHandling(B, E, S);
+    addAutomaticObjDestruction(B, E, S);
----------------
How about using a "pairwise"  range here?
I believe, we don't have that just yet, but we can use `zip` instead.


================
Comment at: clang/lib/Analysis/CFG.cpp:1844-1846
+  for (LocalScope::const_iterator I = B; I != E; ++I)
+    if (!hasTrivialDestructor(*I))
+      DeclsNonTrivial.push_back(*I);
----------------
We could use `llvm::make_range(B, E)` here, I believe.


================
Comment at: clang/lib/Analysis/CFG.cpp:1901-1903
+  for (LocalScope::const_iterator I = B; I != E; ++I)
     if (hasTrivialDestructor(*I))
       DeclsTrivial.push_back(*I);
----------------
Ranges here too.


================
Comment at: clang/lib/Analysis/CFG.cpp:1936-1938
+    for (LocalScope::const_iterator I = DstPos; I != BasePos; ++I)
+      if (I.pointsToFirstDeclaredVar())
+        appendScopeBegin(Block, *I, S);
----------------
Probably, we could also use a `llvm::make_range(DstPos, BasePos)` here, but I'm not sure if that's more readable or not.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153273/new/

https://reviews.llvm.org/D153273



More information about the cfe-commits mailing list