[PATCH] D20878: [Coverage] Do not push a new region after a CXXTryStmt

Vedant Kumar via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 1 14:18:11 PDT 2016


vsk created this revision.
vsk added reviewers: bogner, MaggieYi, phillip.power.
vsk added a subscriber: cfe-commits.

There are three possible scenarios when entering a CXXTryStmt:

  1. No exceptions thrown.
  2. An exception is thrown but caught by one of the handlers.
  3. An exception is thrown but not caught by one of the handlers.

The region we push after a CXXTryStmt isn't useful in scenarios (1) or (2). In
these cases, if control flows to the try block it must flow to the region
following the CXXTryStmt.

This may not be the case in situation (3). However, we don't handle this
scenario anywhere else (e.g after function calls). Having a dedicated region
here could only be helpful if its counter expression differed from the try
block, and even then it's questionable.

http://reviews.llvm.org/D20878

Files:
  lib/CodeGen/CoverageMappingGen.cpp
  test/CoverageMapping/trycatch.cpp

Index: test/CoverageMapping/trycatch.cpp
===================================================================
--- test/CoverageMapping/trycatch.cpp
+++ test/CoverageMapping/trycatch.cpp
@@ -33,5 +33,5 @@
   catch(const Warning &w) {           // CHECK-NEXT: File 0, [[@LINE]]:27 -> [[@LINE+2]]:4 = #4
     j = 0;
   }
-  return 0;                           // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:11 = #1
+  return 0;
 }
Index: lib/CodeGen/CoverageMappingGen.cpp
===================================================================
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -850,9 +850,6 @@
     Visit(S->getTryBlock());
     for (unsigned I = 0, E = S->getNumHandlers(); I < E; ++I)
       Visit(S->getHandler(I));
-
-    Counter ExitCount = getRegionCounter(S);
-    pushRegion(ExitCount);
   }
 
   void VisitCXXCatchStmt(const CXXCatchStmt *S) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20878.59275.patch
Type: text/x-patch
Size: 895 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160601/ee9922cf/attachment.bin>


More information about the cfe-commits mailing list