[lld] r308526 - Use StringRef::contains().
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 19 14:40:26 PDT 2017
Author: ruiu
Date: Wed Jul 19 14:40:26 2017
New Revision: 308526
URL: http://llvm.org/viewvc/llvm-project?rev=308526&view=rev
Log:
Use StringRef::contains().
Modified:
lld/trunk/COFF/Driver.cpp
lld/trunk/COFF/DriverUtils.cpp
lld/trunk/ELF/Error.cpp
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/lib/Core/Reproduce.cpp
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=308526&r1=308525&r2=308526&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Wed Jul 19 14:40:26 2017
@@ -247,7 +247,7 @@ StringRef LinkerDriver::doFindFile(Strin
bool HasPathSep = (Filename.find_first_of("/\\") != StringRef::npos);
if (HasPathSep)
return Filename;
- bool HasExt = (Filename.find('.') != StringRef::npos);
+ bool HasExt = Filename.contains('.');
for (StringRef Dir : SearchPaths) {
SmallString<128> Path = Dir;
sys::path::append(Path, Filename);
@@ -275,7 +275,7 @@ Optional<StringRef> LinkerDriver::findFi
// Find library file from search path.
StringRef LinkerDriver::doFindLib(StringRef Filename) {
// Add ".lib" to Filename if that has no file extension.
- bool HasExt = (Filename.find('.') != StringRef::npos);
+ bool HasExt = Filename.contains('.');
if (!HasExt)
Filename = Saver.save(Filename + ".lib");
return doFindFile(Filename);
Modified: lld/trunk/COFF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DriverUtils.cpp?rev=308526&r1=308525&r2=308526&view=diff
==============================================================================
--- lld/trunk/COFF/DriverUtils.cpp (original)
+++ lld/trunk/COFF/DriverUtils.cpp Wed Jul 19 14:40:26 2017
@@ -459,12 +459,12 @@ Export parseExport(StringRef Arg) {
if (E.Name.empty())
goto err;
- if (E.Name.find('=') != StringRef::npos) {
+ if (E.Name.contains('=')) {
StringRef X, Y;
std::tie(X, Y) = E.Name.split("=");
// If "<name>=<dllname>.<name>".
- if (Y.find(".") != StringRef::npos) {
+ if (Y.contains(".")) {
E.Name = X;
E.ForwardTo = Y;
return E;
Modified: lld/trunk/ELF/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.cpp?rev=308526&r1=308525&r2=308526&view=diff
==============================================================================
--- lld/trunk/ELF/Error.cpp (original)
+++ lld/trunk/ELF/Error.cpp Wed Jul 19 14:40:26 2017
@@ -41,7 +41,7 @@ static void newline(const Twine &Msg) {
if (Flag)
*ErrorOS << "\n";
- Flag = (StringRef(Msg.str()).find('\n') != StringRef::npos);
+ Flag = StringRef(Msg.str()).contains('\n');
}
static void print(StringRef S, raw_ostream::Colors C) {
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=308526&r1=308525&r2=308526&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Wed Jul 19 14:40:26 2017
@@ -325,11 +325,9 @@ Symbol *SymbolTable<ELFT>::addUndefined(
// .symver foo,foo@@@VER
// we can delete this hack.
static int compareVersion(Symbol *S, StringRef Name) {
- if (Name.find("@@") != StringRef::npos &&
- S->body()->getName().find("@@") == StringRef::npos)
+ if (Name.contains("@@") && !S->body()->getName().contains("@@"))
return 1;
- if (Name.find("@@") == StringRef::npos &&
- S->body()->getName().find("@@") != StringRef::npos)
+ if (!Name.contains("@@") && S->body()->getName().contains("@@"))
return -1;
return 0;
}
@@ -720,7 +718,7 @@ void SymbolTable<ELFT>::assignExactVersi
// Skip symbols containing version info because symbol versions
// specified by symbol names take precedence over version scripts.
// See parseSymbolVersion().
- if (B->getName().find('@') != StringRef::npos)
+ if (B->getName().contains('@'))
continue;
Symbol *Sym = B->symbol();
Modified: lld/trunk/lib/Core/Reproduce.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Reproduce.cpp?rev=308526&r1=308525&r2=308526&view=diff
==============================================================================
--- lld/trunk/lib/Core/Reproduce.cpp (original)
+++ lld/trunk/lib/Core/Reproduce.cpp Wed Jul 19 14:40:26 2017
@@ -44,9 +44,9 @@ std::string lld::relativeToRoot(StringRe
// Quote a given string if it contains a space character.
std::string lld::quote(StringRef S) {
- if (S.find(' ') == StringRef::npos)
- return S;
- return ("\"" + S + "\"").str();
+ if (S.contains(' '))
+ return ("\"" + S + "\"").str();
+ return S;
}
std::string lld::rewritePath(StringRef S) {
More information about the llvm-commits
mailing list