summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CoverageMappingGen.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2015-05-01 19:23:34 +0000
committerJustin Bogner <mail@justinbogner.com>2015-05-01 19:23:34 +0000
commit88c8a7cc71f2f389058635ec61df4e1a76419c1f (patch)
tree2e96617a4492238aa7a22584c1cf78375e3189d4 /lib/CodeGen/CoverageMappingGen.cpp
parentd61f6739d7a3bd637b85230eccf22a1072c62643 (diff)
downloadclang-88c8a7cc71f2f389058635ec61df4e1a76419c1f.tar.gz
InstrProf: Fix a coverage crash where a macro begins in an unreachable block
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236335 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CoverageMappingGen.cpp')
-rw-r--r--lib/CodeGen/CoverageMappingGen.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/CodeGen/CoverageMappingGen.cpp b/lib/CodeGen/CoverageMappingGen.cpp
index 38848b032c..fca17264e8 100644
--- a/lib/CodeGen/CoverageMappingGen.cpp
+++ b/lib/CodeGen/CoverageMappingGen.cpp
@@ -447,7 +447,10 @@ struct CounterCoverageMappingBuilder
/// This should be used after visiting any statements in non-source order.
void adjustForOutOfOrderTraversal(SourceLocation EndLoc) {
MostRecentLocation = EndLoc;
- if (MostRecentLocation == getEndOfFileOrMacro(MostRecentLocation))
+ // Avoid adding duplicate regions if we have a completed region on the top
+ // of the stack and are adjusting to the end of a virtual file.
+ if (getRegion().hasEndLoc() &&
+ MostRecentLocation == getEndOfFileOrMacro(MostRecentLocation))
MostRecentLocation = getIncludeOrExpansionLoc(MostRecentLocation);
}