forked from OSchip/llvm-project
[Coverage] Push a new region when handling CXXTryStmts
Push a new region for the try block and propagate execution counts through it. This ensures that catch statements get a region counter distinct from the try block's counter. llvm-svn: 273463
This commit is contained in:
parent
30afae1a75
commit
049908b296
|
@ -867,7 +867,12 @@ struct CounterCoverageMappingBuilder
|
|||
|
||||
void VisitCXXTryStmt(const CXXTryStmt *S) {
|
||||
extendRegion(S);
|
||||
Visit(S->getTryBlock());
|
||||
// Handle macros that generate the "try" but not the rest.
|
||||
extendRegion(S->getTryBlock());
|
||||
|
||||
Counter ParentCount = getRegion().getCounter();
|
||||
propagateCounts(ParentCount, S->getTryBlock());
|
||||
|
||||
for (unsigned I = 0, E = S->getNumHandlers(); I < E; ++I)
|
||||
Visit(S->getHandler(I));
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ void func(int i) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> {{[
|
|||
// CHECK-NEXT: main
|
||||
int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+13]]:2 = #0
|
||||
int j = 1;
|
||||
try {
|
||||
try { // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE+2]]:4 = #0
|
||||
func(j);
|
||||
} catch(const Error &e) { // CHECK-NEXT: File 0, [[@LINE]]:27 -> [[@LINE+2]]:4 = #2
|
||||
j = 1;
|
||||
|
|
|
@ -17,8 +17,27 @@ catch(...) {} // CHECK: [[@LINE]]:12 -> [[@LINE]]:14 = #2
|
|||
void fn3() TRY { return; } // CHECK: [[@LINE]]:15 -> [[@LINE+1]]:14 = #1
|
||||
CATCH(...) {} // CHECK: [[@LINE]]:12 -> [[@LINE]]:14 = #2
|
||||
|
||||
// CHECK: Z3fn4v:
|
||||
#define TRY2 try { // CHECK-DAG: File 1, [[@LINE]]:18 -> [[@LINE]]:19 = #1
|
||||
void fn4() TRY2 // CHECK-DAG: Expansion,File 0, [[@LINE]]:12 -> [[@LINE]]:16 = #1 (Expanded file = 1)
|
||||
for (;;)
|
||||
return;
|
||||
}
|
||||
catch (...) {}
|
||||
|
||||
// CHECK: Z3fn5v:
|
||||
#define TRY3 try { return; } catch (...) // CHECK-DAG: File 2, [[@LINE]]:18 -> [[@LINE]]:29 = #1
|
||||
#define TRY4 try { TRY3 { return; } } catch (...) // CHECK-DAG: Expansion,File 1, [[@LINE]]:20 -> [[@LINE]]:24 = #1 (Expanded file = 2)
|
||||
void fn5() {
|
||||
for (;;) {
|
||||
TRY4 { return; } // CHECK-DAG: Expansion,File 0, [[@LINE]]:5 -> [[@LINE]]:9 = #1 (Expanded file = 1)
|
||||
} // CHECK-DAG: File 0, [[@LINE-1]]:10 -> [[@LINE-1]]:21 = #5
|
||||
}
|
||||
|
||||
int main() {
|
||||
fn1();
|
||||
fn2();
|
||||
fn3();
|
||||
fn4();
|
||||
fn5();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue