@@ -430,6 +430,20 @@ class SourceMappingRegion {
430
430
assert (EndLoc && " Region has no end location" );
431
431
return *EndLoc;
432
432
}
433
+
434
+ void print (llvm::raw_ostream &OS, const SourceManager &SM) const {
435
+ OS << " [" ;
436
+ if (hasStartLoc ())
437
+ getStartLoc ().print (OS, SM);
438
+ else
439
+ OS << " ?" ;
440
+ OS << " , " ;
441
+ if (hasEndLoc ())
442
+ getEndLoc ().print (OS, SM);
443
+ else
444
+ OS << " ?" ;
445
+ OS << " ]" ;
446
+ }
433
447
};
434
448
435
449
// / An ASTWalker that maps ASTNodes to profiling counters.
@@ -754,6 +768,11 @@ struct CoverageMapping : public ASTWalker {
754
768
void pushRegion (ASTNode Node) {
755
769
RegionStack.emplace_back (Node, getCounter (Node), Node.getStartLoc (),
756
770
getEndLoc (Node));
771
+ LLVM_DEBUG ({
772
+ llvm::dbgs () << " Pushed region: " ;
773
+ RegionStack.back ().print (llvm::dbgs (), SM);
774
+ llvm::dbgs () << " \n " ;
775
+ });
757
776
}
758
777
759
778
// / Replace the current region's count by pushing an incomplete region.
@@ -780,6 +799,8 @@ struct CoverageMapping : public ASTWalker {
780
799
auto ParentIt = I;
781
800
SourceLoc EndLoc = ParentIt->getEndLoc ();
782
801
802
+ unsigned FirstPoppedIndex = SourceRegions.size ();
803
+ (void )FirstPoppedIndex;
783
804
SourceRegions.push_back (std::move (*I++));
784
805
for (; I != E; ++I) {
785
806
if (!I->hasStartLoc ())
@@ -789,6 +810,14 @@ struct CoverageMapping : public ASTWalker {
789
810
SourceRegions.push_back (std::move (*I));
790
811
}
791
812
813
+ LLVM_DEBUG ({
814
+ for (unsigned Idx = FirstPoppedIndex; Idx < SourceRegions.size (); ++Idx) {
815
+ llvm::dbgs () << " Popped region: " ;
816
+ SourceRegions[Idx].print (llvm::dbgs (), SM);
817
+ llvm::dbgs () << " \n " ;
818
+ }
819
+ });
820
+
792
821
RegionStack.erase (ParentIt, E);
793
822
}
794
823
0 commit comments