diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp --- a/llvm/lib/Support/RISCVISAInfo.cpp +++ b/llvm/lib/Support/RISCVISAInfo.cpp @@ -699,9 +699,10 @@ auto StdExtsItr = StdExts.begin(); auto StdExtsEnd = StdExts.end(); - auto GoToNextExt = [](StringRef::iterator &I, unsigned ConsumeLength) { + auto GoToNextExt = [](StringRef::iterator &I, unsigned ConsumeLength, + StringRef::iterator E) { I += 1 + ConsumeLength; - if (*I == '_') + if (I != E && *I == '_') ++I; }; for (auto I = Exts.begin(), E = Exts.end(); I != E;) { @@ -737,7 +738,7 @@ ExperimentalExtensionVersionCheck)) { if (IgnoreUnknown) { consumeError(std::move(E)); - GoToNextExt(I, ConsumeLength); + GoToNextExt(I, ConsumeLength, Exts.end()); continue; } return std::move(E); @@ -747,7 +748,7 @@ // Currently LLVM supports only "mafdcvh". if (!isSupportedExtension(StringRef(&C, 1))) { if (IgnoreUnknown) { - GoToNextExt(I, ConsumeLength); + GoToNextExt(I, ConsumeLength, Exts.end()); continue; } return createStringError(errc::invalid_argument, @@ -758,7 +759,7 @@ // Consume full extension name and version, including any optional '_' // between this extension and the next - GoToNextExt(I, ConsumeLength); + GoToNextExt(I, ConsumeLength, Exts.end()); } // Handle other types of extensions other than the standard