summaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/CoverageMappingGen.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2016-05-31 18:06:19 +0000
committerVedant Kumar <vsk@apple.com>2016-05-31 18:06:19 +0000
commite0c001cbf6021ae5bf488457bbd2b6118b9aedc1 (patch)
tree4d734787df51579f84dd8fe6f2f2f31a63eb12cd /lib/CodeGen/CoverageMappingGen.cpp
parent4083a06092adf7132de7c94e763fd5cd29e5e302 (diff)
[Coverage] Fix crash on a switch partially covered by a macro (PR27948)
We have to handle file exits before and after visiting regions in the switch body. Fixes PR27948. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271308 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CoverageMappingGen.cpp')
-rw-r--r--lib/CodeGen/CoverageMappingGen.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/CodeGen/CoverageMappingGen.cpp b/lib/CodeGen/CoverageMappingGen.cpp
index d3fd19c174..4650001f80 100644
--- a/lib/CodeGen/CoverageMappingGen.cpp
+++ b/lib/CodeGen/CoverageMappingGen.cpp
@@ -783,8 +783,10 @@ struct CounterCoverageMappingBuilder
Visit(Child);
popRegions(Index);
}
- } else
+ } else {
+ handleFileExit(getStart(Body));
propagateCounts(Counter::getZero(), Body);
+ }
BreakContinue BC = BreakContinueStack.pop_back_val();
if (!BreakContinueStack.empty())
@@ -792,7 +794,9 @@ struct CounterCoverageMappingBuilder
BreakContinueStack.back().ContinueCount, BC.ContinueCount);
Counter ExitCount = getRegionCounter(S);
- pushRegion(ExitCount, getStart(S), getEnd(S));
+ SourceLocation ExitLoc = getEnd(S);
+ pushRegion(ExitCount, getStart(S), ExitLoc);
+ handleFileExit(ExitLoc);
}
void VisitSwitchCase(const SwitchCase *S) {