@@ -874,6 +874,42 @@ TEST_P(CoverageMappingTest, non_code_region_bitmask) {
874
874
ASSERT_EQ (1U , Names.size ());
875
875
}
876
876
877
+ // Test the order of MCDCDecision before Expansion
878
+ TEST_P (CoverageMappingTest, decision_before_expansion) {
879
+ startFunction (" foo" , 0x1234 );
880
+ addCMR (Counter::getCounter (0 ), " foo" , 3 , 23 , 5 , 2 );
881
+
882
+ // This(4:11) was put after Expansion(4:11) before the fix
883
+ addMCDCDecisionCMR (0 , 2 , " foo" , 4 , 11 , 4 , 20 );
884
+
885
+ addExpansionCMR (" foo" , " A" , 4 , 11 , 4 , 12 );
886
+ addExpansionCMR (" foo" , " B" , 4 , 19 , 4 , 20 );
887
+ addCMR (Counter::getCounter (0 ), " A" , 1 , 14 , 1 , 17 );
888
+ addCMR (Counter::getCounter (0 ), " A" , 1 , 14 , 1 , 17 );
889
+ addMCDCBranchCMR (Counter::getCounter (0 ), Counter::getCounter (1 ), 1 , 2 , 0 , " A" ,
890
+ 1 , 14 , 1 , 17 );
891
+ addCMR (Counter::getCounter (1 ), " B" , 1 , 14 , 1 , 17 );
892
+ addMCDCBranchCMR (Counter::getCounter (1 ), Counter::getCounter (2 ), 2 , 0 , 0 , " B" ,
893
+ 1 , 14 , 1 , 17 );
894
+
895
+ // InputFunctionCoverageData::Regions is rewritten after the write.
896
+ auto InputRegions = InputFunctions.back ().Regions ;
897
+
898
+ writeAndReadCoverageRegions ();
899
+
900
+ const auto &OutputRegions = OutputFunctions.back ().Regions ;
901
+
902
+ size_t N = ArrayRef (InputRegions).size ();
903
+ ASSERT_EQ (N, OutputRegions.size ());
904
+ for (size_t I = 0 ; I < N; ++I) {
905
+ ASSERT_EQ (InputRegions[I].Kind , OutputRegions[I].Kind );
906
+ ASSERT_EQ (InputRegions[I].FileID , OutputRegions[I].FileID );
907
+ ASSERT_EQ (InputRegions[I].ExpandedFileID , OutputRegions[I].ExpandedFileID );
908
+ ASSERT_EQ (InputRegions[I].startLoc (), OutputRegions[I].startLoc ());
909
+ ASSERT_EQ (InputRegions[I].endLoc (), OutputRegions[I].endLoc ());
910
+ }
911
+ }
912
+
877
913
TEST_P (CoverageMappingTest, strip_filename_prefix) {
878
914
ProfileWriter.addRecord ({" file1:func" , 0x1234 , {0 }}, Err);
879
915
0 commit comments