diff options
| author | Rui Ueyama <ruiu@google.com> | 2017-07-19 21:40:26 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2017-07-19 21:40:26 +0000 |
| commit | 12234f8093b39bbd9ca9235be98d44a7cc7d59f2 (patch) | |
| tree | b6783fce247a4007806b62fe68f4830e3c8f3e77 | |
| parent | 1985e9b7e1f430da20efa7d8f48ac0ad6583322b (diff) | |
| download | bcm5719-llvm-12234f8093b39bbd9ca9235be98d44a7cc7d59f2.tar.gz bcm5719-llvm-12234f8093b39bbd9ca9235be98d44a7cc7d59f2.zip | |
Use StringRef::contains().
llvm-svn: 308526
| -rw-r--r-- | lld/COFF/Driver.cpp | 4 | ||||
| -rw-r--r-- | lld/COFF/DriverUtils.cpp | 4 | ||||
| -rw-r--r-- | lld/ELF/Error.cpp | 2 | ||||
| -rw-r--r-- | lld/ELF/SymbolTable.cpp | 8 | ||||
| -rw-r--r-- | lld/lib/Core/Reproduce.cpp | 6 |
5 files changed, 11 insertions, 13 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index a33ebedca10..ce382a09e0d 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -247,7 +247,7 @@ StringRef LinkerDriver::doFindFile(StringRef Filename) { 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::findFile(StringRef Filename) { // 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); diff --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp index 39d58246964..a9942364aa5 100644 --- a/lld/COFF/DriverUtils.cpp +++ b/lld/COFF/DriverUtils.cpp @@ -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; diff --git a/lld/ELF/Error.cpp b/lld/ELF/Error.cpp index 224570ea742..dce57776ebe 100644 --- a/lld/ELF/Error.cpp +++ b/lld/ELF/Error.cpp @@ -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) { diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index 0c932400f0a..78a2df59364 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -325,11 +325,9 @@ Symbol *SymbolTable<ELFT>::addUndefined(StringRef Name, bool IsLocal, // .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>::assignExactVersion(SymbolVersion Ver, // 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(); diff --git a/lld/lib/Core/Reproduce.cpp b/lld/lib/Core/Reproduce.cpp index e3629a93cbe..6295e628bcd 100644 --- a/lld/lib/Core/Reproduce.cpp +++ b/lld/lib/Core/Reproduce.cpp @@ -44,9 +44,9 @@ std::string lld::relativeToRoot(StringRef Path) { // 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) { |

