From 1bab17c289afe831813a96e25f17eaeafcda7bc2 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Thu, 19 Feb 2015 03:10:30 +0000 Subject: [PATCH] InstrProf: Always emit a coverage region for the condition of an if When tools like llvm-cov show regions, it's much easier to understand what's happening if the condition of an if shows a counter as well as the body. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229813 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CoverageMappingGen.cpp | 5 ++++- test/CoverageMapping/break.c | 8 +++++--- test/CoverageMapping/continue.c | 6 +++--- test/CoverageMapping/if.c | 6 +++++- test/CoverageMapping/includehell.cpp | 7 +++++++ test/CoverageMapping/label.cpp | 22 ++++++++++++---------- test/CoverageMapping/macro-expansion.c | 20 ++++++++++++-------- test/CoverageMapping/macro-expressions.cpp | 1 + test/CoverageMapping/macroscopes.cpp | 4 ++++ test/CoverageMapping/moremacros.c | 10 +++++++--- test/CoverageMapping/objc.m | 7 ++++--- test/CoverageMapping/preprocessor.c | 3 ++- test/CoverageMapping/return.c | 11 +++++++---- test/CoverageMapping/switchmacro.c | 2 +- test/CoverageMapping/test.c | 3 ++- test/CoverageMapping/trycatch.cpp | 7 ++++--- 16 files changed, 80 insertions(+), 42 deletions(-) diff --git a/lib/CodeGen/CoverageMappingGen.cpp b/lib/CodeGen/CoverageMappingGen.cpp index ad4a9753bb..4bd4eb6da2 100644 --- a/lib/CodeGen/CoverageMappingGen.cpp +++ b/lib/CodeGen/CoverageMappingGen.cpp @@ -787,11 +787,14 @@ struct CounterCoverageMappingBuilder void VisitIfStmt(const IfStmt *S) { extendRegion(S); - Visit(S->getCond()); Counter ParentCount = getRegion().getCounter(); Counter ThenCount = getRegionCounter(S); + // Emitting a counter for the condition makes it easier to interpret the + // counter for the body when looking at the coverage. + propagateCounts(ParentCount, S->getCond()); + extendRegion(S->getThen()); Counter OutCount = propagateCounts(ThenCount, S->getThen()); diff --git a/test/CoverageMapping/break.c b/test/CoverageMapping/break.c index 07f1d6bc90..99439c8bc6 100644 --- a/test/CoverageMapping/break.c +++ b/test/CoverageMapping/break.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name break.c %s | FileCheck %s -int main() { // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+28]]:2 = #0 +int main() { // CHECK: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0 int cnt = 0; // CHECK-NEXT: File 0, [[@LINE+1]]:9 -> [[@LINE+1]]:18 = #0 while(cnt < 100) { // CHECK-NEXT: File 0, [[@LINE]]:20 -> [[@LINE+3]]:4 = #1 break; @@ -13,14 +13,16 @@ int main() { // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+28]]:2 = #0 } ++cnt; } // CHECK-NEXT: File 0, [[@LINE+1]]:9 -> [[@LINE+1]]:18 = ((#0 + #3) - #4) - while(cnt < 100) { // CHECK-NEXT: File 0, [[@LINE]]:20 -> [[@LINE+6]]:4 = #3 + while(cnt < 100) { // CHECK-NEXT: File 0, [[@LINE]]:20 -> [[@LINE+7]]:4 = #3 + // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+1]]:16 = #3 if(cnt == 0) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+3]]:6 = #4 break; ++cnt; // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE+1]]:6 = 0 } ++cnt; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+1]]:4 = (#3 - #4) } // CHECK-NEXT: File 0, [[@LINE+1]]:9 -> [[@LINE+1]]:18 = (#0 + #6) - while(cnt < 100) { // CHECK-NEXT: File 0, [[@LINE]]:20 -> [[@LINE+7]]:4 = #5 + while(cnt < 100) { // CHECK-NEXT: File 0, [[@LINE]]:20 -> [[@LINE+8]]:4 = #5 + // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+1]]:16 = #5 if(cnt == 0) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+2]]:6 = #6 ++cnt; } else { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+2]]:6 = (#5 - #6) diff --git a/test/CoverageMapping/continue.c b/test/CoverageMapping/continue.c index f100dba00b..c86651e221 100644 --- a/test/CoverageMapping/continue.c +++ b/test/CoverageMapping/continue.c @@ -4,15 +4,15 @@ int main() { // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+21]]:2 int j = 0; // CHECK-NEXT: File 0, [[@LINE+2]]:18 -> [[@LINE+2]]:24 = (#0 + #1) // CHECK-NEXT: File 0, [[@LINE+1]]:26 -> [[@LINE+1]]:29 = #1 for(int i = 0; i < 20; ++i) { // CHECK-NEXT: File 0, [[@LINE]]:31 -> [[@LINE+17]]:4 = #1 - if(i < 10) { // CHECK-NEXT: File 0, [[@LINE]]:16 -> [[@LINE+13]]:6 = #2 - if(i < 5) { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+3]]:8 = #3 + if(i < 10) { // CHECK: File 0, [[@LINE]]:16 -> [[@LINE+13]]:6 = #2 + if(i < 5) { // CHECK: File 0, [[@LINE]]:17 -> [[@LINE+3]]:8 = #3 continue; j = 1; // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE+1]]:8 = 0 } else { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+2]]:8 = (#2 - #3) j = 2; } j = 3; // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE+6]]:6 = (#2 - #3) - if(i < 7) { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+3]]:8 = #4 + if(i < 7) { // CHECK: File 0, [[@LINE]]:17 -> [[@LINE+3]]:8 = #4 continue; j = 4; // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE+1]]:8 = 0 } else j = 5; // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE]]:19 = ((#2 - #3) - #4) diff --git a/test/CoverageMapping/if.c b/test/CoverageMapping/if.c index bfc4cc4bdd..73b2308716 100644 --- a/test/CoverageMapping/if.c +++ b/test/CoverageMapping/if.c @@ -1,13 +1,17 @@ // RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name if.c %s | FileCheck %s -int main() { // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+21]]:2 = #0 +int main() { // CHECK: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0 int i = 0; + // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+1]]:12 = #0 if(i == 0) i = 1; // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE]]:19 = #1 + // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+1]]:12 = #0 if(i == 1) i = 2; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:10 = #2 + // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+1]]:12 = #0 if(i == 0) { i = 1; // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #3 i = 2; } + // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+1]]:12 = #0 if(i != 0) { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #4 i = 1; } else { // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+2]]:4 = (#0 - #4) diff --git a/test/CoverageMapping/includehell.cpp b/test/CoverageMapping/includehell.cpp index 830bc4f450..5a9ff78386 100644 --- a/test/CoverageMapping/includehell.cpp +++ b/test/CoverageMapping/includehell.cpp @@ -51,22 +51,29 @@ int main() { // CHECK-START-NEXT: File [[START3]], 4:29 -> 5:1 = #9 // CHECK-CODE: File [[CODE1:[0-9]]], 1:1 -> 14:1 = #1 +// CHECK-CODE-NEXT: File [[CODE1]], 4:5 -> 4:11 = #1 // CHECK-CODE-NEXT: File [[CODE1]], 4:13 -> 6:2 = #2 // CHECK-CODE-NEXT: File [[CODE1]], 6:8 -> 8:2 = (#1 - #2) +// CHECK-CODE-NEXT: File [[CODE1]], 9:5 -> 9:9 = #1 // CHECK-CODE-NEXT: File [[CODE1]], 9:11 -> 11:2 = #3 // CHECK-CODE-NEXT: File [[CODE1]], 11:8 -> 13:2 = (#1 - #3) // CHECK-CODE: File [[CODE2:[0-9]]], 1:1 -> 14:1 = #5 +// CHECK-CODE-NEXT: File [[CODE2]], 4:5 -> 4:11 = #5 // CHECK-CODE-NEXT: File [[CODE2]], 4:13 -> 6:2 = #6 // CHECK-CODE-NEXT: File [[CODE2]], 6:8 -> 8:2 = (#5 - #6) +// CHECK-CODE-NEXT: File [[CODE2]], 9:5 -> 9:9 = #5 // CHECK-CODE-NEXT: File [[CODE2]], 9:11 -> 11:2 = #7 // CHECK-CODE-NEXT: File [[CODE2]], 11:8 -> 13:2 = (#5 - #7) // CHECK-END: File [[END1:[0-9]]], 1:1 -> 3:2 = #1 // CHECK-END-NEXT: File [[END1]], 1:1 -> 6:1 = #0 +// CHECK-END-NEXT: File [[END1]], 5:5 -> 5:9 = #0 // CHECK-END-NEXT: File [[END1]], 5:11 -> 5:16 = #4 // CHECK-END: File [[END2:[0-9]]], 1:1 -> 3:2 = #5 // CHECK-END-NEXT: File [[END2]], 1:1 -> 6:1 = #0 +// CHECK-END-NEXT: File [[END2]], 5:5 -> 5:9 = #0 // CHECK-END-NEXT: File [[END2]], 5:11 -> 5:16 = #8 // CHECK-END: File [[END3:[0-9]]], 1:1 -> 3:2 = #9 // CHECK-END-NEXT: File [[END3]], 1:1 -> 6:1 = #0 +// CHECK-END-NEXT: File [[END3]], 5:5 -> 5:9 = #0 // CHECK-END-NEXT: File [[END3]], 5:11 -> 5:16 = #10 diff --git a/test/CoverageMapping/label.cpp b/test/CoverageMapping/label.cpp index 2fa58b68c3..52618f7c2e 100644 --- a/test/CoverageMapping/label.cpp +++ b/test/CoverageMapping/label.cpp @@ -1,10 +1,11 @@ // RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name label.cpp %s | FileCheck %s // CHECK: func -void func() { // CHECK-NEXT: File 0, [[@LINE]]:13 -> [[@LINE+18]]:2 = #0 +void func() { // CHECK-NEXT: File 0, [[@LINE]]:13 -> {{[0-9]+}}:2 = #0 int i = 0; // CHECK-NEXT: File 0, [[@LINE+2]]:14 -> [[@LINE+2]]:20 = (#0 + #3) // CHECK-NEXT: File 0, [[@LINE+1]]:22 -> [[@LINE+1]]:25 = #3 - for(i = 0; i < 10; ++i) { // CHECK-NEXT: File 0, [[@LINE]]:27 -> [[@LINE+10]]:4 = #1 + for(i = 0; i < 10; ++i) { // CHECK-NEXT: File 0, [[@LINE]]:27 -> [[@LINE+11]]:4 = #1 + // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+1]]:13 = #1 if(i < 5) { // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+6]]:6 = #2 { x: // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE+4]]:6 = #3 @@ -17,13 +18,13 @@ void func() { // CHECK-NEXT: File 0, [[@LINE]]:13 -> [[@LINE+18]] } static int j = 0; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+4]]:2 = ((#0 + #3) - #1) ++j; - if(j == 1) + if(j == 1) // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE]]:12 = ((#0 + #3) - #1) goto x; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:11 = #4 } // CHECK-NEXT: test1 -void test1(int x) { // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+7]]:2 = #0 - if(x == 0) +void test1(int x) { // CHECK-NEXT: File 0, [[@LINE]]:19 -> {{[0-9]+}}:2 = #0 + if(x == 0) // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE]]:12 = #0 goto a; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:11 = #1 goto b; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:9 = (#0 - #1) a: // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE+3]]:2 = #2 @@ -32,10 +33,11 @@ b: // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE+2]]:2 } // CHECK-NEXT: test2 -void test2(int x) { // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+8]]:2 = #0 - if(x == 0) +void test2(int x) { // CHECK-NEXT: File 0, [[@LINE]]:19 -> {{[0-9]+}}:2 = #0 + if(x == 0) // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE]]:12 = #0 goto a; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:11 = #1 - // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+1]]:25 = (#0 - #1) + // CHECK-NEXT: File 0, [[@LINE+2]]:8 -> [[@LINE+2]]:25 = (#0 - #1) + // CHECK-NEXT: File 0, [[@LINE+1]]:11 -> [[@LINE+1]]:17 = (#0 - #1) else if(x == 1) goto b; // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE]]:25 = #2 a: // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE+3]]:2 = #3 b: // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE+2]]:2 = #4 @@ -43,11 +45,11 @@ b: // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE+2]]:2 } // CHECK-NEXT: main -int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+17]]:2 = #0 +int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0 int j = 0; for(int i = 0; i < 10; ++i) { // CHECK: File 0, [[@LINE]]:31 -> [[@LINE+11]]:4 = #1 a: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+10]]:4 = #2 - if(i < 3) + if(i < 3) // CHECK-NEXT: File 0, [[@LINE]]:8 -> [[@LINE]]:13 = #2 goto e; // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #3 goto c; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:11 = (#2 - #3) b: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:4 = #4 diff --git a/test/CoverageMapping/macro-expansion.c b/test/CoverageMapping/macro-expansion.c index 099dd3fb3d..e87f444832 100644 --- a/test/CoverageMapping/macro-expansion.c +++ b/test/CoverageMapping/macro-expansion.c @@ -1,17 +1,20 @@ // RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expansion.c %s | FileCheck %s // CHECK: func -// CHECK: File 1, [[@LINE+4]]:12 -> [[@LINE+4]]:38 = #0 -// CHECK-NEXT: File 1, [[@LINE+3]]:15 -> [[@LINE+3]]:28 = (#0 + #2) +// CHECK: File 1, [[@LINE+5]]:12 -> [[@LINE+5]]:38 = #0 +// CHECK-NEXT: File 1, [[@LINE+4]]:15 -> [[@LINE+4]]:28 = (#0 + #2) +// CHECK-NEXT: File 1, [[@LINE+3]]:21 -> [[@LINE+3]]:22 = (#0 + #2) // CHECK-NEXT: File 1, [[@LINE+2]]:24 -> [[@LINE+2]]:26 = #3 // CHECK-NEXT: File 1, [[@LINE+1]]:36 -> [[@LINE+1]]:37 = (#0 + #2) #define M1 do { if (0) {} } while (0) -// CHECK-NEXT: File 2, [[@LINE+8]]:15 -> [[@LINE+8]]:41 = #0 -// CHECK-NEXT: File 2, [[@LINE+7]]:18 -> [[@LINE+7]]:31 = (#0 + #4) -// CHECK-NEXT: File 2, [[@LINE+6]]:27 -> [[@LINE+6]]:29 = #5 -// CHECK-NEXT: File 2, [[@LINE+5]]:39 -> [[@LINE+5]]:40 = (#0 + #4) -// CHECK-NEXT: File 3, [[@LINE+4]]:15 -> [[@LINE+4]]:41 = #0 -// CHECK-NEXT: File 3, [[@LINE+3]]:18 -> [[@LINE+3]]:31 = (#0 + #6) +// CHECK-NEXT: File 2, [[@LINE+10]]:15 -> [[@LINE+10]]:41 = #0 +// CHECK-NEXT: File 2, [[@LINE+9]]:18 -> [[@LINE+9]]:31 = (#0 + #4) +// CHECK-NEXT: File 2, [[@LINE+8]]:24 -> [[@LINE+8]]:25 = (#0 + #4) +// CHECK-NEXT: File 2, [[@LINE+7]]:27 -> [[@LINE+7]]:29 = #5 +// CHECK-NEXT: File 2, [[@LINE+6]]:39 -> [[@LINE+6]]:40 = (#0 + #4) +// CHECK-NEXT: File 3, [[@LINE+5]]:15 -> [[@LINE+5]]:41 = #0 +// CHECK-NEXT: File 3, [[@LINE+4]]:18 -> [[@LINE+4]]:31 = (#0 + #6) +// CHECK-NEXT: File 3, [[@LINE+3]]:24 -> [[@LINE+3]]:25 = (#0 + #6) // CHECK-NEXT: File 3, [[@LINE+2]]:27 -> [[@LINE+2]]:29 = #7 // CHECK-NEXT: File 3, [[@LINE+1]]:39 -> [[@LINE+1]]:40 = (#0 + #6) #define M2(x) do { if (x) {} } while (0) @@ -34,6 +37,7 @@ // Check for the expansion of M2 within M3. // CHECK-NEXT: File 9, {{[0-9]+}}:15 -> {{[0-9]+}}:41 = (#0 + #8) // CHECK-NEXT: File 9, {{[0-9]+}}:18 -> {{[0-9]+}}:31 = ((#0 + #8) + #9) +// CHECK-NEXT: File 9, {{[0-9]+}}:24 -> {{[0-9]+}}:25 = ((#0 + #8) + #9) // CHECK-NEXT: File 9, {{[0-9]+}}:27 -> {{[0-9]+}}:29 = #10 // CHECK-NEXT: File 9, {{[0-9]+}}:39 -> {{[0-9]+}}:40 = ((#0 + #8) + #9) diff --git a/test/CoverageMapping/macro-expressions.cpp b/test/CoverageMapping/macro-expressions.cpp index b9782b0c12..00e273bd78 100644 --- a/test/CoverageMapping/macro-expressions.cpp +++ b/test/CoverageMapping/macro-expressions.cpp @@ -15,6 +15,7 @@ // CHECK: foo // CHECK-NEXT: File 0, [[@LINE+1]]:17 -> {{[0-9]+}}:2 = #0 void foo(int i) { + // CHECK-NEXT: File 0, [[@LINE+2]]:7 -> [[@LINE+2]]:8 = #0 // CHECK-NEXT: File 0, [[@LINE+1]]:10 -> [[@LINE+1]]:12 = #1 if (0) {} diff --git a/test/CoverageMapping/macroscopes.cpp b/test/CoverageMapping/macroscopes.cpp index 2a6763e58f..a3a9297968 100644 --- a/test/CoverageMapping/macroscopes.cpp +++ b/test/CoverageMapping/macroscopes.cpp @@ -72,8 +72,10 @@ int main() { // CHECK-NEXT: File 1, 3:47 -> 3:50 = #1 // CHECK-NEXT: File 1, 3:52 -> 3:53 = #1 // CHECK-NEXT: File 2, 10:3 -> 20:4 = #1 +// CHECK-NEXT: File 2, 11:7 -> 11:13 = #1 // CHECK-NEXT: File 2, 11:15 -> 13:4 = #2 // CHECK-NEXT: File 2, 13:10 -> 15:4 = (#1 - #2) +// CHECK-NEXT: File 2, 16:7 -> 16:11 = #1 // CHECK-NEXT: File 2, 16:13 -> 18:4 = #3 // CHECK-NEXT: File 2, 18:10 -> 20:4 = (#1 - #3) // CHECK-NEXT: File 3, 6:3 -> 7:4 = #1 @@ -82,8 +84,10 @@ int main() { // CHECK-NEXT: File 4, 3:47 -> 3:50 = #4 // CHECK-NEXT: File 4, 3:52 -> 3:53 = #4 // CHECK-NEXT: File 5, 10:3 -> 20:4 = #4 +// CHECK-NEXT: File 5, 11:7 -> 11:13 = #4 // CHECK-NEXT: File 5, 11:15 -> 13:4 = #5 // CHECK-NEXT: File 5, 13:10 -> 15:4 = (#4 - #5) +// CHECK-NEXT: File 5, 16:7 -> 16:11 = #4 // CHECK-NEXT: File 5, 16:13 -> 18:4 = #6 // CHECK-NEXT: File 5, 18:10 -> 20:4 = (#4 - #6) // CHECK-NEXT: File 6, 6:3 -> 7:4 = #4 diff --git a/test/CoverageMapping/moremacros.c b/test/CoverageMapping/moremacros.c index b059a3c059..d4a8f87a48 100644 --- a/test/CoverageMapping/moremacros.c +++ b/test/CoverageMapping/moremacros.c @@ -4,10 +4,12 @@ #define RBRAC } // CHECK: main: -// CHECK-NEXT: File 0, [[@LINE+1]]:40 -> [[@LINE+24]]:2 = #0 +// CHECK-NEXT: File 0, [[@LINE+1]]:40 -> {{[0-9]+}}:2 = #0 int main(int argc, const char *argv[]) { + // CHECK-NEXT: File 0, [[@LINE+1]]:7 -> [[@LINE+1]]:12 = #0 if (!argc) {} // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE]]:16 = #1 + // CHECK-NEXT: File 0, [[@LINE+3]]:7 -> [[@LINE+3]]:12 = #0 // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:14 -> [[@LINE+2]]:19 = #2 // CHECK-NEXT: File 0, [[@LINE+1]]:19 -> [[@LINE+4]]:8 = #2 if (!argc) LBRAC @@ -15,14 +17,16 @@ int main(int argc, const char *argv[]) { // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:8 = #2 RBRAC - // CHECK-NEXT: File 0, [[@LINE+3]]:3 -> [[@LINE+13]]:2 = (#0 - #2) + // CHECK-NEXT: File 0, [[@LINE+4]]:3 -> [[@LINE+15]]:2 = (#0 - #2) + // CHECK-NEXT: File 0, [[@LINE+3]]:7 -> [[@LINE+3]]:12 = (#0 - #2) // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:14 -> [[@LINE+2]]:19 = #3 // CHECK-NEXT: File 0, [[@LINE+1]]:19 -> [[@LINE+3]]:4 = #3 if (!argc) LBRAC return 0; } - // CHECK-NEXT: File 0, [[@LINE+2]]:3 -> [[@LINE+6]]:2 = ((#0 - #2) - #3) + // CHECK-NEXT: File 0, [[@LINE+3]]:3 -> [[@LINE+7]]:2 = ((#0 - #2) - #3) + // CHECK-NEXT: File 0, [[@LINE+2]]:7 -> [[@LINE+2]]:12 = ((#0 - #2) - #3) // CHECK-NEXT: File 0, [[@LINE+1]]:14 -> [[@LINE+4]]:8 = #4 if (!argc) { return 0; diff --git a/test/CoverageMapping/objc.m b/test/CoverageMapping/objc.m index a3b1dbd450..8456dc3842 100644 --- a/test/CoverageMapping/objc.m +++ b/test/CoverageMapping/objc.m @@ -6,7 +6,7 @@ // CHECK: func void func(A *a) { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+3]]:2 = #0 - if (a) + if (a) // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:8 = #0 [a bork: 20 ]; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:20 = #1 } @@ -16,9 +16,10 @@ void func(A *a) { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+3]]:2 = #0 @end // CHECK: func2 -void func2(NSArray *array) { // CHECK-NEXT: File 0, [[@LINE]]:28 -> [[@LINE+10]]:2 = #0 +void func2(NSArray *array) { // CHECK-NEXT: File 0, [[@LINE]]:28 -> {{[0-9]+}}:2 = #0 int i = 0; - for (NSArray *x in array) { // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+6]]:4 = #1 + for (NSArray *x in array) { // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+7]]:4 = #1 + // CHECK-NEXT: File 0, [[@LINE+1]]:9 -> [[@LINE+1]]:10 = #1 if (x) { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+2]]:6 = #2 i = 1; } else { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+2]]:6 = (#1 - #2) diff --git a/test/CoverageMapping/preprocessor.c b/test/CoverageMapping/preprocessor.c index d9ff5b1381..cdd448cd20 100644 --- a/test/CoverageMapping/preprocessor.c +++ b/test/CoverageMapping/preprocessor.c @@ -15,7 +15,7 @@ void func() { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0 #endif // CHECK: main -int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+19]]:2 = #0 +int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0 int i = 0; #if 0 // CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+4]]:2 = 0 if(i == 0) { @@ -24,6 +24,7 @@ int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+19]]:2 = #0 #endif #if 1 + // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+1]]:12 = #0 if(i == 0) { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #1 i = 1; } diff --git a/test/CoverageMapping/return.c b/test/CoverageMapping/return.c index a05695b7f7..ab63c2c286 100644 --- a/test/CoverageMapping/return.c +++ b/test/CoverageMapping/return.c @@ -7,13 +7,15 @@ void func() { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+3]]:2 } // CHECK-NEXT: func2 -void func2() { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+13]]:2 = #0 +void func2() { // CHECK-NEXT: File 0, [[@LINE]]:14 -> {{[0-9]+}}:2 = #0 // CHECK-NEXT: File 0, [[@LINE+2]]:18 -> [[@LINE+2]]:24 = ((#0 + #1) - #2) // CHECK-NEXT: File 0, [[@LINE+1]]:26 -> [[@LINE+1]]:29 = (#1 - #2) - for(int i = 0; i < 10; ++i) { // CHECK-NEXT: File 0, [[@LINE]]:31 -> [[@LINE+9]]:4 = #1 + for(int i = 0; i < 10; ++i) { // CHECK-NEXT: File 0, [[@LINE]]:31 -> {{[0-9]+}}:4 = #1 + // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+1]]:13 = #1 if(i > 2) { // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+2]]:6 = #2 return; - } // CHECK-NEXT: File 0, [[@LINE+1]]:5 -> [[@LINE+6]]:4 = (#1 - #2) + } // CHECK-NEXT: File 0, [[@LINE+2]]:5 -> {{[0-9]+}}:4 = (#1 - #2) + // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+1]]:14 = (#1 - #2) if(i == 3) { // CHECK-NEXT: File 0, [[@LINE]]:16 -> [[@LINE+2]]:6 = #3 int j = 1; } else { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+2]]:6 = ((#1 - #2) - #3) @@ -23,7 +25,8 @@ void func2() { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+1 } // CHECK-NEXT: func3 -void func3(int x) { // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+9]]:2 = #0 +void func3(int x) { // CHECK-NEXT: File 0, [[@LINE]]:19 -> {{[0-9]+}}:2 = #0 + // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+1]]:11 = #0 if(x > 5) { // CHECK-NEXT: File 0, [[@LINE]]:13 -> [[@LINE+6]]:4 = #1 while(x >= 9) { // CHECK-NEXT: File 0, [[@LINE]]:11 -> [[@LINE]]:17 = #1 return; // CHECK-NEXT: File 0, [[@LINE-1]]:19 -> [[@LINE+2]]:6 = #2 diff --git a/test/CoverageMapping/switchmacro.c b/test/CoverageMapping/switchmacro.c index 5be38573d9..431d5c72ea 100644 --- a/test/CoverageMapping/switchmacro.c +++ b/test/CoverageMapping/switchmacro.c @@ -6,7 +6,7 @@ int foo(int i) { // CHECK-NEXT: File 0, [[@LINE]]:16 -> {{[0-9]+}}:2 = #0 switch (i) { default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> {{[0-9]+}}:11 = #2 - if (i == 1) + if (i == 1) // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:15 = #2 return 0; // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:15 = #3 // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:5 -> [[@LINE+2]]:8 = (#2 - #3) // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> {{[0-9]+}}:11 = (#2 - #3) diff --git a/test/CoverageMapping/test.c b/test/CoverageMapping/test.c index 0911cd857d..a274ce432b 100644 --- a/test/CoverageMapping/test.c +++ b/test/CoverageMapping/test.c @@ -14,7 +14,8 @@ int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+ } // CHECK-NEXT: foo -void foo() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+4]]:2 = #0 +void foo() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+5]]:2 = #0 + // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+1]]:7 = #0 if(1) { // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE+2]]:4 = #1 int i = 0; } diff --git a/test/CoverageMapping/trycatch.cpp b/test/CoverageMapping/trycatch.cpp index cd653341e7..696df5485b 100644 --- a/test/CoverageMapping/trycatch.cpp +++ b/test/CoverageMapping/trycatch.cpp @@ -10,10 +10,11 @@ class Warning { }; // CHECK: func -void func(int i) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+5]]:2 = #0 - if(i % 2) +void func(int i) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+6]]:2 = #0 + if(i % 2) // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE]]:11 = #0 throw Error(); // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:18 = #1 - else if(i == 8) // CHECK-NEXT: File 0, [[@LINE]]:8 -> [[@LINE+1]]:27 = (#0 - #1) + // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+2]]:27 = (#0 - #1) + else if(i == 8) // CHECK-NEXT: File 0, [[@LINE]]:11 -> [[@LINE]]:17 = (#0 - #1) throw ImportantError(); // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:27 = #2 } -- 2.40.0