[llvm] Use StringRef::drop_back (NFC) (#139471)

This commit is contained in:
Kazu Hirata 2025-05-11 15:37:41 -07:00 committed by GitHub
parent 6f84ec3496
commit 18549aa1cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 5 deletions

View File

@ -672,7 +672,7 @@ public:
StringRef getAsCString() const {
assert(isCString() && "Isn't a C string");
StringRef Str = getAsString();
return Str.substr(0, Str.size() - 1);
return Str.drop_back();
}
/// Return the raw, underlying, bytes of this data. Note that this is an

View File

@ -726,7 +726,7 @@ static Option *getOptionPred(StringRef Name, size_t &Length,
// characters in it (so that the next iteration will not be the empty
// string.
while (OMI == OptionsMap.end() && Name.size() > 1) {
Name = Name.substr(0, Name.size() - 1); // Chop off the last character.
Name = Name.drop_back();
OMI = OptionsMap.find(Name);
if (OMI != OptionsMap.end() && !Pred(OMI->getValue()))
OMI = OptionsMap.end();

View File

@ -644,9 +644,8 @@ MCSubtargetInfo *Hexagon_MC::createHexagonMCSubtargetInfo(const Triple &TT,
void Hexagon_MC::addArchSubtarget(MCSubtargetInfo const *STI, StringRef FS) {
assert(STI != nullptr);
if (STI->getCPU().contains("t")) {
auto ArchSTI = createHexagonMCSubtargetInfo(
STI->getTargetTriple(),
STI->getCPU().substr(0, STI->getCPU().size() - 1), FS);
auto ArchSTI = createHexagonMCSubtargetInfo(STI->getTargetTriple(),
STI->getCPU().drop_back(), FS);
std::lock_guard<std::mutex> Lock(ArchSubtargetMutex);
ArchSubtarget[std::string(STI->getCPU())] =
std::unique_ptr<MCSubtargetInfo const>(ArchSTI);