[PATCH] D97101: [Coverage] Emit zero count gap region between statements if first statements contains return, throw, goto, co_return

Vedant Kumar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 22 18:06:58 PST 2021


vsk added inline comments.


================
Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:559
 
-  /// Location of the last terminated region.
-  Optional<std::pair<SourceLocation, size_t>> LastTerminatedRegion;
+  /// If there is a return, co_return, goto or throw inside.
+  bool HasTerminateStmt = false;
----------------
nit: Whether the visitor is at a ... stmt?


================
Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:593
       MostRecentLocation = *StartLoc;
-      completeDeferred(Count, MostRecentLocation);
     }
 
----------------
Does this mean a deferred gap region following a `break;` statement won't be completed before the next region is pushed?


================
Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:942
     pushRegion(Counter::getZero());
-    auto &ZeroRegion = getRegion();
-    ZeroRegion.setDeferred(true);
-    LastTerminatedRegion = {EndLoc, RegionStack.size()};
+    if (!HasTerminateStmt) {
+      auto &ZeroRegion = getRegion();
----------------
What's supposed to be the difference between the zero region pushed after a `return;` vs. after a `break;`?


================
Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:1057
+    if (SaveTerminateStmt)
+      HasTerminateStmt = true;
     handleFileExit(getEnd(S));
----------------
Can this replace all of the machinery around DeferredRegions? It'd be nice to just have one way to set up gaps between statements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97101



More information about the cfe-commits mailing list