@@ -681,9 +681,8 @@ void DiagnosticEngine::formatDiagnosticText(
681
681
}
682
682
683
683
if (Modifier == " error" ) {
684
- assert (false && " encountered %error in diagnostic text" );
685
- Out << StringRef (" <<ERROR>>" );
686
- break ;
684
+ Out << StringRef (" <<INTERNAL ERROR: encountered %error in diagnostic text>>" );
685
+ continue ;
687
686
}
688
687
689
688
// Parse the optional argument list for a modifier, which is brace-enclosed.
@@ -696,12 +695,20 @@ void DiagnosticEngine::formatDiagnosticText(
696
695
// Find the digit sequence, and parse it into an argument index.
697
696
size_t Length = InText.find_if_not (isdigit);
698
697
unsigned ArgIndex;
699
- bool Result = InText.substr (0 , Length).getAsInteger (10 , ArgIndex);
700
- assert (!Result && " Unparseable argument index value?" );
701
- (void )Result;
702
- assert (ArgIndex < Args.size () && " Out-of-range argument index" );
698
+ bool IndexParseFailed = InText.substr (0 , Length).getAsInteger (10 , ArgIndex);
699
+
700
+ if (IndexParseFailed) {
701
+ Out << StringRef (" <<INTERNAL ERROR: unparseable argument index in diagnostic text>>" );
702
+ continue ;
703
+ }
704
+
703
705
InText = InText.substr (Length);
704
706
707
+ if (ArgIndex >= Args.size ()) {
708
+ Out << StringRef (" <<INTERNAL ERROR: out-of-range argument index in diagnostic text>>" );
709
+ continue ;
710
+ }
711
+
705
712
// Convert the argument to a string.
706
713
formatDiagnosticArgument (Modifier, ModifierArguments, Args, ArgIndex,
707
714
FormatOpts, Out);
0 commit comments