[PATCH] D36250: [coverage] Special-case calls to noreturn functions.
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 3 15:28:31 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309995: [coverage] Special-case calls to noreturn functions. (authored by efriedma).
Changed prior to commit:
https://reviews.llvm.org/D36250?vs=109457&id=109644#toc
Repository:
rL LLVM
https://reviews.llvm.org/D36250
Files:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/test/CoverageMapping/switch.cpp
Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
@@ -716,6 +716,18 @@
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);
Index: cfe/trunk/test/CoverageMapping/switch.cpp
===================================================================
--- cfe/trunk/test/CoverageMapping/switch.cpp
+++ cfe/trunk/test/CoverageMapping/switch.cpp
@@ -97,3 +97,16 @@
break;
}
}
+
+void abort(void) __attribute((noreturn));
+ // CHECK: noret
+int noret(int x) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+9]]:2
+ switch (x) {
+ default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:12
+ abort();
+ case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13
+ return 5;
+ case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:14
+ return 10;
+ }
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36250.109644.patch
Type: text/x-patch
Size: 1431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170803/c113324f/attachment-0001.bin>
More information about the cfe-commits
mailing list