From 055ebc348d81bb52d4eb549927457b6a16838a0d Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Tue, 16 Jun 2015 06:24:15 +0000 Subject: InstrProf: Fix coverage mapping when "if" is a macro We were propagating the coverage map into the body of an if statement, but not into the condition thereafter. This is fine as long as the two locations are in the same virtual file, but they won't be when the "if" part of the statement is from a macro and the condition is not. llvm-svn: 239803 --- clang/lib/CodeGen/CoverageMappingGen.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp') diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 024a45dba2b..9ad5d14edfd 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -806,6 +806,9 @@ struct CounterCoverageMappingBuilder void VisitIfStmt(const IfStmt *S) { extendRegion(S); + // Extend into the condition before we propagate through it below - this is + // needed to handle macros that generate the "if" but not the condition. + extendRegion(S->getCond()); Counter ParentCount = getRegion().getCounter(); Counter ThenCount = getRegionCounter(S); -- cgit v1.2.3