This is an archive of the discontinued LLVM Phabricator instance.

[Coverage] Support for C++17 if initializers
ClosedPublic

Authored by vsk on Oct 13 2016, 11:45 AM.

Details

Summary

Generate coverage mappings for <init> in if (<init>; <cond>).

Here's some sample output (let's hope phab gets the spaces right :) --

12|       |// CHECK-LABEL: define {{.*}}void @_Z11switch_initv()
13|       |// PGOGEN: store {{.*}} @[[SIC]], i64 0, i64 0
14|      1|void switch_init() {
15|      1|  switch (int i = true ? 0 : 1; i) {}
                                    ^1  ^0
16|      1|  // PGOGEN: store {{.*}} @[[SIC]], i64 0, i64 2
17|      1|  // PGOGEN: store {{.*}} @[[SIC]], i64 0, i64 1
18|      1|}
19|       |
20|       |// Note: We expect counters for the function entry block, the condition in the
21|       |// if initializer, and the if successor block.
22|       |//
23|       |// CHECK-LABEL: define {{.*}}void @_Z7if_initv()
24|       |// PGOGEN: store {{.*}} @[[IIC]], i64 0, i64 0
25|      1|void if_init() {
26|      1|  if (int i = true ? 0 : 1; i) {}
                                ^1  ^0 ^1 ^0
27|      1|  // PGOGEN: store {{.*}} @[[IIC]], i64 0, i64 2
28|      1|  // PGOGEN: store {{.*}} @[[IIC]], i64 0, i64 1
29|      1|}

I did some local testing of this patch (as well as D25539) using a maze of macros to generate parts of the IfStmt / SwitchStmt. The goal of that exercise was to break popRegions(). Ultimately I decided against checking those tests in because they seem a bit paranoid. We're not actually pushing new regions for the initializer statements..

Diff Detail

Repository
rL LLVM

Event Timeline

vsk updated this revision to Diff 74559.Oct 13 2016, 11:45 AM
vsk retitled this revision from to [Coverage] Support for C++17 if initializers.
vsk updated this object.
vsk added reviewers: arphaman, ikudrin.
vsk added a subscriber: cfe-commits.
ikudrin accepted this revision.Oct 14 2016, 7:07 AM
ikudrin edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Oct 14 2016, 7:07 AM
This revision was automatically updated to reflect the committed changes.
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp