summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CoverageMappingGen.cpp
diff options
context:
space:
mode:
authorEli Friedman <efriedma@codeaurora.org>2017-08-03 22:27:36 +0000
committerEli Friedman <efriedma@codeaurora.org>2017-08-03 22:27:36 +0000
commit2d30c64ae3704c8698345711a2396b0d952aed64 (patch)
treec303fb68f553225293017f14b34f710630f782f8 /clang/lib/CodeGen/CoverageMappingGen.cpp
parent974d4eea93a62d54f53f569deb1038bd5c0fb207 (diff)
downloadbcm5719-llvm-2d30c64ae3704c8698345711a2396b0d952aed64.tar.gz
bcm5719-llvm-2d30c64ae3704c8698345711a2396b0d952aed64.zip
[coverage] Special-case calls to noreturn functions.
The code after a noreturn call doesn't execute. The pattern in the testcase is pretty common in LLVM (a switch with a default case that calls llvm_unreachable). Differential Revision: https://reviews.llvm.org/D36250 llvm-svn: 309995
Diffstat (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp')
-rw-r--r--clang/lib/CodeGen/CoverageMappingGen.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 1484ec78b88..28aabd0f071 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -716,6 +716,18 @@ struct CounterCoverageMappingBuilder
terminateRegion(S);
}
+ void VisitCallExpr(const CallExpr *E) {
+ extendRegion(E);
+ for (const Stmt *Child : E->children())
+ this->Visit(Child);
+
+ // Terminate the region when we hit a noreturn function.
+ // (This is helpful dealing with switch statements.)
+ QualType CalleeType = E->getCallee()->getType();
+ if (getFunctionExtInfo(*CalleeType).getNoReturn())
+ terminateRegion(E);
+ }
+
void VisitWhileStmt(const WhileStmt *S) {
extendRegion(S);
OpenPOWER on IntegriCloud