@@ -660,10 +660,6 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
660660 break ;
661661 }
662662
663- if (Arch.back () == ' _' )
664- return createStringError (errc::invalid_argument,
665- " extension name missing after separator '_'" );
666-
667663 // Skip baseline.
668664 StringRef Exts = Arch.drop_front (1 );
669665
@@ -703,18 +699,18 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
703699 // Consume the base ISA version number and any '_' between rvxxx and the
704700 // first extension
705701 Exts = Exts.drop_front (ConsumeLength);
706- Exts.consume_front (" _" );
707702
708- SmallVector<StringRef, 8 > SplitExts;
709- // Only split if the string is not empty. Otherwise the split will push an
710- // empty string into the vector.
711- if (!Exts.empty ())
712- Exts.split (SplitExts, ' _' );
703+ while (!Exts.empty ()) {
704+ if (Exts.front () == ' _' ) {
705+ if (Exts.size () == 1 || Exts[1 ] == ' _' )
706+ return createStringError (errc::invalid_argument,
707+ " extension name missing after separator '_'" );
708+ Exts = Exts.drop_front ();
709+ }
713710
714- for (auto Ext : SplitExts) {
715- if (Ext.empty ())
716- return createStringError (errc::invalid_argument,
717- " extension name missing after separator '_'" );
711+ size_t Idx = Exts.find (' _' );
712+ StringRef Ext = Exts.slice (0 , Idx);
713+ Exts = Exts.slice (Idx, StringRef::npos);
718714
719715 do {
720716 if (RISCVISAUtils::AllStdExts.contains (Ext.front ())) {
0 commit comments