]> granicus.if.org Git - clang/commit
[Coverage] Do not visit artificial stmts in defaulted methods (PR39822)
authorVedant Kumar <vsk@apple.com>
Wed, 28 Nov 2018 20:48:07 +0000 (20:48 +0000)
committerVedant Kumar <vsk@apple.com>
Wed, 28 Nov 2018 20:48:07 +0000 (20:48 +0000)
commit94338d81841086c2b7c4158206e322cae5d269fc
tree5452bbc4154f6afc317117ed733c77d88e7a8df4
parent42c648c35a0b35d4d6c851940f004b721fd874f9
[Coverage] Do not visit artificial stmts in defaulted methods (PR39822)

There is no reason to emit coverage mappings for artificial statements
contained within defaulted methods, as these statements are not visible
to users.

Only emit a mapping for the body of the defaulted method (clang treats
the text of the "default" keyword as the body when reporting locations).
This allows users to see how often the default method is called, but
trims down the coverage mapping by skipping visitation of the children
of the method.

The immediate motivation for this change is that the lexer's
getPreciseTokenLocEnd API cannot return the correct location when given
an artificial statement (with a somewhat made-up location) as an input.

Test by Orivej Desh!

Fixes llvm.org/PR39822.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347803 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CoverageMappingGen.cpp
test/CoverageMapping/default-method.cpp [new file with mode: 0644]