Skip to content

Commit

Permalink
Simplify users of StringRef::{l,r}trim (NFC)
Browse files Browse the repository at this point in the history
r260925 introduced a version of the *trim methods which is preferable
when trimming a single kind of character. Update all users in llvm.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260926 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
vedantk committed Feb 16, 2016
1 parent 9ae3e2c commit 7e9bf09
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/llvm/Object/Archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct ArchiveMemberHeader {
sys::fs::perms getAccessMode() const;
sys::TimeValue getLastModified() const;
llvm::StringRef getRawLastModified() const {
return StringRef(LastModified, sizeof(LastModified)).rtrim(" ");
return StringRef(LastModified, sizeof(LastModified)).rtrim(' ');
}
unsigned getUID() const;
unsigned getGID() const;
Expand Down
17 changes: 8 additions & 9 deletions lib/Object/Archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ ErrorOr<uint32_t> ArchiveMemberHeader::getSize() const {

sys::fs::perms ArchiveMemberHeader::getAccessMode() const {
unsigned Ret;
if (StringRef(AccessMode, sizeof(AccessMode)).rtrim(" ").getAsInteger(8, Ret))
if (StringRef(AccessMode, sizeof(AccessMode)).rtrim(' ').getAsInteger(8, Ret))
llvm_unreachable("Access mode is not an octal number.");
return static_cast<sys::fs::perms>(Ret);
}

sys::TimeValue ArchiveMemberHeader::getLastModified() const {
unsigned Seconds;
if (StringRef(LastModified, sizeof(LastModified)).rtrim(" ")
if (StringRef(LastModified, sizeof(LastModified)).rtrim(' ')
.getAsInteger(10, Seconds))
llvm_unreachable("Last modified time not a decimal number.");

Expand All @@ -70,14 +70,14 @@ sys::TimeValue ArchiveMemberHeader::getLastModified() const {

unsigned ArchiveMemberHeader::getUID() const {
unsigned Ret;
if (StringRef(UID, sizeof(UID)).rtrim(" ").getAsInteger(10, Ret))
if (StringRef(UID, sizeof(UID)).rtrim(' ').getAsInteger(10, Ret))
llvm_unreachable("UID time not a decimal number.");
return Ret;
}

unsigned ArchiveMemberHeader::getGID() const {
unsigned Ret;
if (StringRef(GID, sizeof(GID)).rtrim(" ").getAsInteger(10, Ret))
if (StringRef(GID, sizeof(GID)).rtrim(' ').getAsInteger(10, Ret))
llvm_unreachable("GID time not a decimal number.");
return Ret;
}
Expand Down Expand Up @@ -108,7 +108,7 @@ Archive::Child::Child(const Archive *Parent, const char *Start,
StringRef Name = getRawName();
if (Name.startswith("#1/")) {
uint64_t NameSize;
if (Name.substr(3).rtrim(" ").getAsInteger(10, NameSize))
if (Name.substr(3).rtrim(' ').getAsInteger(10, NameSize))
llvm_unreachable("Long name length is not an integer");
StartOfFile += NameSize;
}
Expand Down Expand Up @@ -197,7 +197,7 @@ ErrorOr<StringRef> Archive::Child::getName() const {
// It's a long name.
// Get the offset.
std::size_t offset;
if (name.substr(1).rtrim(" ").getAsInteger(10, offset))
if (name.substr(1).rtrim(' ').getAsInteger(10, offset))
llvm_unreachable("Long name offset is not an integer");

// Verify it.
Expand All @@ -213,10 +213,9 @@ ErrorOr<StringRef> Archive::Child::getName() const {
return StringRef(addr);
} else if (name.startswith("#1/")) {
uint64_t name_size;
if (name.substr(3).rtrim(" ").getAsInteger(10, name_size))
if (name.substr(3).rtrim(' ').getAsInteger(10, name_size))
llvm_unreachable("Long name length is not an ingeter");
return Data.substr(sizeof(ArchiveMemberHeader), name_size)
.rtrim(StringRef("\0", 1));
return Data.substr(sizeof(ArchiveMemberHeader), name_size).rtrim('\0');
}
// It's a simple name.
if (name[name.size() - 1] == '/')
Expand Down
2 changes: 1 addition & 1 deletion lib/Support/YAMLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,7 @@ StringRef ScalarNode::getValue(SmallVectorImpl<char> &Storage) const {
return UnquotedValue;
}
// Plain or block.
return Value.rtrim(" ");
return Value.rtrim(' ');
}

StringRef ScalarNode::unescapeDoubleQuoted( StringRef UnquotedValue
Expand Down

0 comments on commit 7e9bf09

Please sign in to comment.