Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/IR/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Support/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down