diff options
author | Vedant Kumar <vsk@apple.com> | 2017-09-18 23:37:30 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2017-09-18 23:37:30 +0000 |
commit | a1c4deb79225755b50b18cf35f74c90ac3e4ff68 (patch) | |
tree | d5707a095f4f6bb07252fc00a27d64e64a3e7da9 /clang/lib/CodeGen/CoverageMappingGen.cpp | |
parent | ad8f637bd83aeeca7321d6c74b3d7787587c0d55 (diff) | |
download | llvm-a1c4deb79225755b50b18cf35f74c90ac3e4ff68.zip llvm-a1c4deb79225755b50b18cf35f74c90ac3e4ff68.tar.gz llvm-a1c4deb79225755b50b18cf35f74c90ac3e4ff68.tar.bz2 |
[Coverage] Use a new API to label gap areas
This will make it possible for llvm-cov to pick better line execution
counts, and is part of the fix for llvm.org/PR34612.
llvm-svn: 313598
Diffstat (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp')
-rw-r--r-- | clang/lib/CodeGen/CoverageMappingGen.cpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index cf736a4..943c7e0 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -48,11 +48,16 @@ class SourceMappingRegion { /// Whether this region should be emitted after its parent is emitted. bool DeferRegion; + /// Whether this region is a gap region. The count from a gap region is set + /// as the line execution count if there are no other regions on the line. + bool GapRegion; + public: SourceMappingRegion(Counter Count, Optional<SourceLocation> LocStart, - Optional<SourceLocation> LocEnd, bool DeferRegion = false) + Optional<SourceLocation> LocEnd, bool DeferRegion = false, + bool GapRegion = false) : Count(Count), LocStart(LocStart), LocEnd(LocEnd), - DeferRegion(DeferRegion) {} + DeferRegion(DeferRegion), GapRegion(GapRegion) {} const Counter &getCounter() const { return Count; } @@ -79,6 +84,10 @@ public: bool isDeferred() const { return DeferRegion; } void setDeferred(bool Deferred) { DeferRegion = Deferred; } + + bool isGap() const { return GapRegion; } + + void setGap(bool Gap) { GapRegion = Gap; } }; /// Spelling locations for the start and end of a source region. @@ -322,9 +331,16 @@ public: // Find the spelling locations for the mapping region. SpellingRegion SR{SM, LocStart, LocEnd}; assert(SR.isInSourceOrder() && "region start and end out of order"); - MappingRegions.push_back(CounterMappingRegion::makeRegion( - Region.getCounter(), *CovFileID, SR.LineStart, SR.ColumnStart, - SR.LineEnd, SR.ColumnEnd)); + + if (Region.isGap()) { + MappingRegions.push_back(CounterMappingRegion::makeGapRegion( + Region.getCounter(), *CovFileID, SR.LineStart, SR.ColumnStart, + SR.LineEnd, SR.ColumnEnd)); + } else { + MappingRegions.push_back(CounterMappingRegion::makeRegion( + Region.getCounter(), *CovFileID, SR.LineStart, SR.ColumnStart, + SR.LineEnd, SR.ColumnEnd)); + } } } @@ -496,6 +512,7 @@ struct CounterCoverageMappingBuilder if (!SpellingRegion(SM, DR.getStartLoc(), DeferredEndLoc).isInSourceOrder()) return Index; + DR.setGap(true); DR.setCounter(Count); DR.setEndLoc(DeferredEndLoc); handleFileExit(DeferredEndLoc); @@ -1112,6 +1129,9 @@ static void dump(llvm::raw_ostream &OS, StringRef FunctionName, case CounterMappingRegion::SkippedRegion: OS << "Skipped,"; break; + case CounterMappingRegion::GapRegion: + OS << "Gap,"; + break; } OS << "File " << R.FileID << ", " << R.LineStart << ":" << R.ColumnStart |