[clang] 3cfe375 - Use StringRef::contains (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 24 22:05:44 PST 2021
Author: Kazu Hirata
Date: 2021-12-24T22:05:34-08:00
New Revision: 3cfe375ae43139839af01e29c3ec03654e98186b
URL: https://github.com/llvm/llvm-project/commit/3cfe375ae43139839af01e29c3ec03654e98186b
DIFF: https://github.com/llvm/llvm-project/commit/3cfe375ae43139839af01e29c3ec03654e98186b.diff
LOG: Use StringRef::contains (NFC)
Added:
Modified:
clang-tools-extra/clang-tidy/android/CloexecCheck.cpp
clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp
clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
clang/tools/driver/driver.cpp
llvm/lib/Support/RISCVISAInfo.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/android/CloexecCheck.cpp b/clang-tools-extra/clang-tidy/android/CloexecCheck.cpp
index 64c8797934d23..d373877713f18 100644
--- a/clang-tools-extra/clang-tidy/android/CloexecCheck.cpp
+++ b/clang-tools-extra/clang-tidy/android/CloexecCheck.cpp
@@ -87,7 +87,7 @@ void CloexecCheck::insertStringFlag(
// Check if the <Mode> may be in the mode string.
const auto *ModeStr = dyn_cast<StringLiteral>(ModeArg->IgnoreParenCasts());
- if (!ModeStr || (ModeStr->getString().find(Mode) != StringRef::npos))
+ if (!ModeStr || ModeStr->getString().contains(Mode))
return;
std::string ReplacementText = buildFixMsgForStringFlag(
diff --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
index 8da0469554250..4bf841648f948 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
@@ -64,7 +64,7 @@ static std::string collapseConsecutive(StringRef Str, char C) {
static bool hasReservedDoubleUnderscore(StringRef Name,
const LangOptions &LangOpts) {
if (LangOpts.CPlusPlus)
- return Name.find("__") != StringRef::npos;
+ return Name.contains("__");
return Name.startswith("__");
}
diff --git a/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp b/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp
index 26b1d8ecdc319..40dda98b1e49b 100644
--- a/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp
@@ -25,7 +25,7 @@ bool containsEscapes(StringRef HayStack, StringRef Escapes) {
return false;
while (BackSlash != StringRef::npos) {
- if (Escapes.find(HayStack[BackSlash + 1]) == StringRef::npos)
+ if (!Escapes.contains(HayStack[BackSlash + 1]))
return false;
BackSlash = HayStack.find('\\', BackSlash + 2);
}
diff --git a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
index 7dc519c152828..07e962a07e843 100644
--- a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -81,7 +81,7 @@ static SourceLocation findEndLocation(const Stmt &S, const SourceManager &SM,
SourceRange TokRange(Loc, TokEndLoc);
StringRef Comment = Lexer::getSourceText(
CharSourceRange::getTokenRange(TokRange), SM, Context->getLangOpts());
- if (Comment.startswith("/*") && Comment.find('\n') != StringRef::npos) {
+ if (Comment.startswith("/*") && Comment.contains('\n')) {
// Multi-line block comment, insert brace before.
break;
}
diff --git a/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp b/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
index 4f81dc49ded7c..c8a8edf67884e 100644
--- a/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
@@ -71,7 +71,7 @@ void NamedParameterCheck::check(const MatchFinder::MatchResult &Result) {
const char *Begin = SM.getCharacterData(Parm->getBeginLoc());
const char *End = SM.getCharacterData(Parm->getLocation());
StringRef Data(Begin, End - Begin);
- if (Data.find("/*") != StringRef::npos)
+ if (Data.contains("/*"))
continue;
UnnamedParams.push_back(std::make_pair(Function, I));
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index c9129ee9e502c..a7bfb07e002bf 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -120,7 +120,7 @@ static void ApplyOneQAOverride(raw_ostream &OS,
OS << "### Adding argument " << Str << " at end\n";
Args.push_back(Str);
} else if (Edit[0] == 's' && Edit[1] == '/' && Edit.endswith("/") &&
- Edit.slice(2, Edit.size()-1).find('/') != StringRef::npos) {
+ Edit.slice(2, Edit.size() - 1).contains('/')) {
StringRef MatchPattern = Edit.substr(2).split('/').first;
StringRef ReplPattern = Edit.substr(2).split('/').second;
ReplPattern = ReplPattern.slice(0, ReplPattern.size()-1);
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp
index 15a249e6177eb..e2e4340f44e9f 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -565,7 +565,7 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
// TODO: Use version number when setting target features
// Currently LLVM supports only "mafdcbv".
StringRef SupportedStandardExtension = "mafdcbv";
- if (SupportedStandardExtension.find(C) == StringRef::npos)
+ if (!SupportedStandardExtension.contains(C))
return createStringError(errc::invalid_argument,
"unsupported standard user-level extension '%c'",
C);
More information about the cfe-commits
mailing list