File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -460,19 +460,18 @@ RISCVISAInfo::parseNormalizedArchString(StringRef Arch) {
460460
461461 // Split Prefix into the extension name and the major version number
462462 // (the trailing digits of Prefix).
463- int TrailingDigits = 0 ;
464- StringRef ExtName = Prefix;
465- while (!ExtName.empty ()) {
466- if (!isDigit (ExtName.back ()))
463+ size_t VersionStart = Prefix.size ();
464+ while (VersionStart != 0 ) {
465+ if (!isDigit (Prefix[VersionStart - 1 ]))
467466 break ;
468- ExtName = ExtName.drop_back (1 );
469- TrailingDigits++;
467+ --VersionStart;
470468 }
471- if (!TrailingDigits )
469+ if (VersionStart == Prefix. size () )
472470 return createStringError (errc::invalid_argument,
473471 " extension lacks version in expected format" );
474472
475- StringRef MajorVersionStr = Prefix.take_back (TrailingDigits);
473+ StringRef ExtName = Prefix.slice (0 , VersionStart);
474+ StringRef MajorVersionStr = Prefix.slice (VersionStart, StringRef::npos);
476475 if (MajorVersionStr.getAsInteger (10 , MajorVersion))
477476 return createStringError (errc::invalid_argument,
478477 " failed to parse major version number" );
You can’t perform that action at this time.
0 commit comments