@@ -669,9 +669,8 @@ void DiagnosticEngine::formatDiagnosticText(
669
669
}
670
670
671
671
if (Modifier == " error" ) {
672
- assert (false && " encountered %error in diagnostic text" );
673
- Out << StringRef (" <<ERROR>>" );
674
- break ;
672
+ Out << StringRef (" <<INTERNAL ERROR: encountered %error in diagnostic text>>" );
673
+ continue ;
675
674
}
676
675
677
676
// Parse the optional argument list for a modifier, which is brace-enclosed.
@@ -684,12 +683,20 @@ void DiagnosticEngine::formatDiagnosticText(
684
683
// Find the digit sequence, and parse it into an argument index.
685
684
size_t Length = InText.find_if_not (isdigit);
686
685
unsigned ArgIndex;
687
- bool Result = InText.substr (0 , Length).getAsInteger (10 , ArgIndex);
688
- assert (!Result && " Unparseable argument index value?" );
689
- (void )Result;
690
- assert (ArgIndex < Args.size () && " Out-of-range argument index" );
686
+ bool IndexParseFailed = InText.substr (0 , Length).getAsInteger (10 , ArgIndex);
687
+
688
+ if (IndexParseFailed) {
689
+ Out << StringRef (" <<INTERNAL ERROR: unparseable argument index in diagnostic text>>" );
690
+ continue ;
691
+ }
692
+
691
693
InText = InText.substr (Length);
692
694
695
+ if (ArgIndex >= Args.size ()) {
696
+ Out << StringRef (" <<INTERNAL ERROR: out-of-range argument index in diagnostic text>>" );
697
+ continue ;
698
+ }
699
+
693
700
// Convert the argument to a string.
694
701
formatDiagnosticArgument (Modifier, ModifierArguments, Args, ArgIndex,
695
702
FormatOpts, Out);
0 commit comments