Skip to content

Commit 18549aa

Browse files
[llvm] Use StringRef::drop_back (NFC) (llvm#139471)
1 parent 6f84ec3 commit 18549aa

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

llvm/include/llvm/IR/Constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ class ConstantDataSequential : public ConstantData {
672672
StringRef getAsCString() const {
673673
assert(isCString() && "Isn't a C string");
674674
StringRef Str = getAsString();
675-
return Str.substr(0, Str.size() - 1);
675+
return Str.drop_back();
676676
}
677677

678678
/// Return the raw, underlying, bytes of this data. Note that this is an

llvm/lib/Support/CommandLine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ static Option *getOptionPred(StringRef Name, size_t &Length,
726726
// characters in it (so that the next iteration will not be the empty
727727
// string.
728728
while (OMI == OptionsMap.end() && Name.size() > 1) {
729-
Name = Name.substr(0, Name.size() - 1); // Chop off the last character.
729+
Name = Name.drop_back();
730730
OMI = OptionsMap.find(Name);
731731
if (OMI != OptionsMap.end() && !Pred(OMI->getValue()))
732732
OMI = OptionsMap.end();

llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,8 @@ MCSubtargetInfo *Hexagon_MC::createHexagonMCSubtargetInfo(const Triple &TT,
644644
void Hexagon_MC::addArchSubtarget(MCSubtargetInfo const *STI, StringRef FS) {
645645
assert(STI != nullptr);
646646
if (STI->getCPU().contains("t")) {
647-
auto ArchSTI = createHexagonMCSubtargetInfo(
648-
STI->getTargetTriple(),
649-
STI->getCPU().substr(0, STI->getCPU().size() - 1), FS);
647+
auto ArchSTI = createHexagonMCSubtargetInfo(STI->getTargetTriple(),
648+
STI->getCPU().drop_back(), FS);
650649
std::lock_guard<std::mutex> Lock(ArchSubtargetMutex);
651650
ArchSubtarget[std::string(STI->getCPU())] =
652651
std::unique_ptr<MCSubtargetInfo const>(ArchSTI);

0 commit comments

Comments
 (0)