diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h index 76efa9bd63522..7137c699cc992 100644 --- a/llvm/include/llvm/IR/Constants.h +++ b/llvm/include/llvm/IR/Constants.h @@ -672,7 +672,7 @@ class ConstantDataSequential : public ConstantData { 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 diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index f1dd39ce133a8..a407be929af85 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -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(); diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp index 7f8315529e675..91051cd4e2d51 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp @@ -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 Lock(ArchSubtargetMutex); ArchSubtarget[std::string(STI->getCPU())] = std::unique_ptr(ArchSTI);