@@ -699,9 +699,10 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
699
699
700
700
auto StdExtsItr = StdExts.begin ();
701
701
auto StdExtsEnd = StdExts.end ();
702
- auto GoToNextExt = [](StringRef::iterator &I, unsigned ConsumeLength) {
702
+ auto GoToNextExt = [](StringRef::iterator &I, unsigned ConsumeLength,
703
+ StringRef::iterator E) {
703
704
I += 1 + ConsumeLength;
704
- if (*I == ' _' )
705
+ if (I != E && *I == ' _' )
705
706
++I;
706
707
};
707
708
for (auto I = Exts.begin (), E = Exts.end (); I != E;) {
@@ -737,7 +738,7 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
737
738
ExperimentalExtensionVersionCheck)) {
738
739
if (IgnoreUnknown) {
739
740
consumeError (std::move (E));
740
- GoToNextExt (I, ConsumeLength);
741
+ GoToNextExt (I, ConsumeLength, Exts. end () );
741
742
continue ;
742
743
}
743
744
return std::move (E);
@@ -747,7 +748,7 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
747
748
// Currently LLVM supports only "mafdcvh".
748
749
if (!isSupportedExtension (StringRef (&C, 1 ))) {
749
750
if (IgnoreUnknown) {
750
- GoToNextExt (I, ConsumeLength);
751
+ GoToNextExt (I, ConsumeLength, Exts. end () );
751
752
continue ;
752
753
}
753
754
return createStringError (errc::invalid_argument,
@@ -758,7 +759,7 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
758
759
759
760
// Consume full extension name and version, including any optional '_'
760
761
// between this extension and the next
761
- GoToNextExt (I, ConsumeLength);
762
+ GoToNextExt (I, ConsumeLength, Exts. end () );
762
763
}
763
764
764
765
// Handle other types of extensions other than the standard
0 commit comments