@@ -4738,28 +4738,22 @@ static bool diagnoseSingleCandidateFailures(CalleeCandidateInfo &CCI,
4738
4738
argBindings[argIdx] = paramIdx;
4739
4739
}
4740
4740
4741
- auto firstRange = tuple->getElement (argIdx)->getSourceRange ();
4742
- if (!first.empty ()) {
4743
- firstRange.Start = tuple->getElementNameLoc (argIdx);
4744
- }
4745
- unsigned OOOParamIdx = argBindings[argIdx];
4746
- if (Bindings[OOOParamIdx].size () > 1 ) {
4747
- firstRange.End =
4748
- tuple->getElement (Bindings[OOOParamIdx].back ())->getEndLoc ();
4749
- }
4741
+ auto argRange = [&](unsigned argIdx, Identifier label) -> SourceRange {
4742
+ auto range = tuple->getElement (argIdx)->getSourceRange ();
4743
+ if (!label.empty ())
4744
+ range.Start = tuple->getElementNameLoc (argIdx);
4750
4745
4751
- auto secondRange = tuple->getElement (prevArgIdx)->getSourceRange ();
4752
- if (!second.empty ()) {
4753
- secondRange.Start = tuple->getElementNameLoc (prevArgIdx);
4754
- }
4755
- unsigned OOOPrevParamIdx = argBindings[prevArgIdx];
4756
- if (Bindings[OOOPrevParamIdx].size () > 1 ) {
4757
- secondRange.End =
4758
- tuple->getElement (Bindings[OOOPrevParamIdx].back ())->getEndLoc ();
4759
- }
4746
+ unsigned paramIdx = argBindings[argIdx];
4747
+ if (Bindings[paramIdx].size () > 1 )
4748
+ range.End = tuple->getElement (Bindings[paramIdx].back ())->getEndLoc ();
4760
4749
4761
- SourceLoc diagLoc = firstRange.Start ;
4750
+ return range;
4751
+ };
4762
4752
4753
+ auto firstRange = argRange (argIdx, first);
4754
+ auto secondRange = argRange (prevArgIdx, second);
4755
+
4756
+ SourceLoc diagLoc = firstRange.Start ;
4763
4757
if (first.empty () && second.empty ()) {
4764
4758
TC.diagnose (diagLoc, diag::argument_out_of_order_unnamed_unnamed,
4765
4759
argIdx + 1 , prevArgIdx + 1 )
0 commit comments