-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[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
[llvm] Use StringRef::drop_back (NFC) #139471
Conversation
@llvm/pr-subscribers-llvm-support @llvm/pr-subscribers-backend-hexagon Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/139471.diff 3 Files Affected:
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<std::mutex> Lock(ArchSubtargetMutex);
ArchSubtarget[std::string(STI->getCPU())] =
std::unique_ptr<MCSubtargetInfo const>(ArchSTI);
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/9882 Here is the relevant piece of the build log for the reference
|
No description provided.