@@ -4752,28 +4752,22 @@ static bool diagnoseSingleCandidateFailures(CalleeCandidateInfo &CCI,
4752
4752
argBindings[argIdx] = paramIdx;
4753
4753
}
4754
4754
4755
- auto firstRange = tuple->getElement (argIdx)->getSourceRange ();
4756
- if (!first.empty ()) {
4757
- firstRange.Start = tuple->getElementNameLoc (argIdx);
4758
- }
4759
- unsigned OOOParamIdx = argBindings[argIdx];
4760
- if (Bindings[OOOParamIdx].size () > 1 ) {
4761
- firstRange.End =
4762
- tuple->getElement (Bindings[OOOParamIdx].back ())->getEndLoc ();
4763
- }
4755
+ auto argRange = [&](unsigned argIdx, Identifier label) -> SourceRange {
4756
+ auto range = tuple->getElement (argIdx)->getSourceRange ();
4757
+ if (!label.empty ())
4758
+ range.Start = tuple->getElementNameLoc (argIdx);
4764
4759
4765
- auto secondRange = tuple->getElement (prevArgIdx)->getSourceRange ();
4766
- if (!second.empty ()) {
4767
- secondRange.Start = tuple->getElementNameLoc (prevArgIdx);
4768
- }
4769
- unsigned OOOPrevParamIdx = argBindings[prevArgIdx];
4770
- if (Bindings[OOOPrevParamIdx].size () > 1 ) {
4771
- secondRange.End =
4772
- tuple->getElement (Bindings[OOOPrevParamIdx].back ())->getEndLoc ();
4773
- }
4760
+ unsigned paramIdx = argBindings[argIdx];
4761
+ if (Bindings[paramIdx].size () > 1 )
4762
+ range.End = tuple->getElement (Bindings[paramIdx].back ())->getEndLoc ();
4774
4763
4775
- SourceLoc diagLoc = firstRange.Start ;
4764
+ return range;
4765
+ };
4776
4766
4767
+ auto firstRange = argRange (argIdx, first);
4768
+ auto secondRange = argRange (prevArgIdx, second);
4769
+
4770
+ SourceLoc diagLoc = firstRange.Start ;
4777
4771
if (first.empty () && second.empty ()) {
4778
4772
TC.diagnose (diagLoc, diag::argument_out_of_order_unnamed_unnamed,
4779
4773
argIdx + 1 , prevArgIdx + 1 )
0 commit comments