[Coverage] Prevent creating a redundant counter if a nested body ends with a macro.
authorIgor Kudrin <ikudrin.dev@gmail.com>
Mon, 29 Aug 2016 11:48:50 +0000 (11:48 +0000)
committerIgor Kudrin <ikudrin.dev@gmail.com>
Mon, 29 Aug 2016 11:48:50 +0000 (11:48 +0000)
commit8545dae226162723ee75867288103a9a71d0b91c
tree4aa01c97f8b06117649d157cfb441a2b1efddd9e
parent24281b4740799108fe935e3478dfbe3f27c2d36c
[Coverage] Prevent creating a redundant counter if a nested body ends with a macro.

If there were several nested statements arranged in a way that all of them
end up with the same macro, then the expansion of this macro was assigned
with all the corresponding counters of these statements.
As a result, the wrong counter value was shown for the macro in llvm-cov.

This patch fixes the issue by preventing adding a counter for an expanded
source range if it already has an assigned counter, which is expected
to come from the most specific statement.

Differential Revision: https://reviews.llvm.org/D23160

llvm-svn: 279962
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/test/CoverageMapping/macros.c