From 91f2e3c9c2650795d95c80a7f922054ca74c1ac5 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Thu, 19 Feb 2015 03:10:30 +0000 Subject: 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. llvm-svn: 229813 --- clang/lib/CodeGen/CoverageMappingGen.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'clang/lib') diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index ad4a9753bb1..4bd4eb6da2e 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/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()); -- cgit v1.2.3