forked from OSchip/llvm-project
[clang-tools-extra] Rename StringRef _lower() method calls to _insensitive()
This commit is contained in:
parent
e5c7c171e5
commit
86029e4c22
|
@ -150,11 +150,11 @@ llvm::Optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
|
|||
unsigned EditDistance = 3;
|
||||
for (const auto &NameAndEnum : Mapping) {
|
||||
if (IgnoreCase) {
|
||||
if (Value.equals_lower(NameAndEnum.second))
|
||||
if (Value.equals_insensitive(NameAndEnum.second))
|
||||
return NameAndEnum.first;
|
||||
} else if (Value.equals(NameAndEnum.second)) {
|
||||
return NameAndEnum.first;
|
||||
} else if (Value.equals_lower(NameAndEnum.second)) {
|
||||
} else if (Value.equals_insensitive(NameAndEnum.second)) {
|
||||
Closest = NameAndEnum.second;
|
||||
EditDistance = 0;
|
||||
continue;
|
||||
|
|
|
@ -70,9 +70,9 @@ void KernelNameRestrictionPPCallbacks::InclusionDirective(
|
|||
|
||||
bool KernelNameRestrictionPPCallbacks::fileNameIsRestricted(
|
||||
StringRef FileName) {
|
||||
return FileName.equals_lower("kernel.cl") ||
|
||||
FileName.equals_lower("verilog.cl") ||
|
||||
FileName.equals_lower("vhdl.cl");
|
||||
return FileName.equals_insensitive("kernel.cl") ||
|
||||
FileName.equals_insensitive("verilog.cl") ||
|
||||
FileName.equals_insensitive("vhdl.cl");
|
||||
}
|
||||
|
||||
void KernelNameRestrictionPPCallbacks::EndOfMainFile() {
|
||||
|
|
|
@ -176,8 +176,8 @@ static bool sameName(StringRef InComment, StringRef InDecl, bool StrictMode) {
|
|||
return InComment == InDecl;
|
||||
InComment = InComment.trim('_');
|
||||
InDecl = InDecl.trim('_');
|
||||
// FIXME: compare_lower only works for ASCII.
|
||||
return InComment.compare_lower(InDecl) == 0;
|
||||
// FIXME: compare_insensitive only works for ASCII.
|
||||
return InComment.compare_insensitive(InDecl) == 0;
|
||||
}
|
||||
|
||||
static bool looksLikeExpectMethod(const CXXMethodDecl *Expect) {
|
||||
|
|
|
@ -159,7 +159,7 @@ void PreferMemberInitializerCheck::check(
|
|||
if (S->getBeginLoc().isMacroID()) {
|
||||
StringRef MacroName = Lexer::getImmediateMacroName(
|
||||
S->getBeginLoc(), *Result.SourceManager, getLangOpts());
|
||||
if (MacroName.contains_lower("assert"))
|
||||
if (MacroName.contains_insensitive("assert"))
|
||||
return;
|
||||
}
|
||||
if (isControlStatement(S))
|
||||
|
|
|
@ -104,8 +104,8 @@ void StaticAssertCheck::check(const MatchFinder::MatchResult &Result) {
|
|||
|
||||
StringRef FalseMacroName =
|
||||
Lexer::getImmediateMacroName(FalseLiteralLoc, SM, Opts);
|
||||
if (FalseMacroName.compare_lower("false") == 0 ||
|
||||
FalseMacroName.compare_lower("null") == 0)
|
||||
if (FalseMacroName.compare_insensitive("false") == 0 ||
|
||||
FalseMacroName.compare_insensitive("null") == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -93,8 +93,8 @@ bool nameMatch(StringRef L, StringRef R, bool Strict) {
|
|||
return L.empty() || R.empty() || L == R;
|
||||
// We allow two names if one is a prefix/suffix of the other, ignoring case.
|
||||
// Important special case: this is true if either parameter has no name!
|
||||
return L.startswith_lower(R) || R.startswith_lower(L) ||
|
||||
L.endswith_lower(R) || R.endswith_lower(L);
|
||||
return L.startswith_insensitive(R) || R.startswith_insensitive(L) ||
|
||||
L.endswith_insensitive(R) || R.endswith_insensitive(L);
|
||||
}
|
||||
|
||||
DifferingParamsContainer
|
||||
|
|
|
@ -93,7 +93,7 @@ getNewSuffix(llvm::StringRef OldSuffix,
|
|||
// Else, find matching suffix, case-*insensitive*ly.
|
||||
auto NewSuffix = llvm::find_if(
|
||||
NewSuffixes, [OldSuffix](const std::string &PotentialNewSuffix) {
|
||||
return OldSuffix.equals_lower(PotentialNewSuffix);
|
||||
return OldSuffix.equals_insensitive(PotentialNewSuffix);
|
||||
});
|
||||
// Have a match, return it.
|
||||
if (NewSuffix != NewSuffixes.end())
|
||||
|
|
|
@ -1680,7 +1680,7 @@ private:
|
|||
C.SemaResult->Kind == CodeCompletionResult::RK_Macro) ||
|
||||
(C.IndexResult &&
|
||||
C.IndexResult->SymInfo.Kind == index::SymbolKind::Macro)) &&
|
||||
!C.Name.startswith_lower(Filter->pattern()))
|
||||
!C.Name.startswith_insensitive(Filter->pattern()))
|
||||
return None;
|
||||
return Filter->match(C.Name);
|
||||
}
|
||||
|
|
|
@ -296,9 +296,9 @@ enum DriverMode : unsigned char {
|
|||
DriverMode getDriverMode(const std::vector<std::string> &Args) {
|
||||
DriverMode Mode = DM_GCC;
|
||||
llvm::StringRef Argv0 = Args.front();
|
||||
if (Argv0.endswith_lower(".exe"))
|
||||
if (Argv0.endswith_insensitive(".exe"))
|
||||
Argv0 = Argv0.drop_back(strlen(".exe"));
|
||||
if (Argv0.endswith_lower("cl"))
|
||||
if (Argv0.endswith_insensitive("cl"))
|
||||
Mode = DM_CL;
|
||||
for (const llvm::StringRef Arg : Args) {
|
||||
if (Arg == "--driver-mode=cl") {
|
||||
|
|
|
@ -169,7 +169,7 @@ private:
|
|||
|
||||
void parse(Fragment::IndexBlock::ExternalBlock &F,
|
||||
Located<std::string> ExternalVal) {
|
||||
if (!llvm::StringRef(*ExternalVal).equals_lower("none")) {
|
||||
if (!llvm::StringRef(*ExternalVal).equals_insensitive("none")) {
|
||||
error("Only scalar value supported for External is 'None'",
|
||||
ExternalVal.Range);
|
||||
return;
|
||||
|
|
|
@ -27,13 +27,13 @@ llvm::Optional<Path> getCorrespondingHeaderOrSource(
|
|||
// Lookup in a list of known extensions.
|
||||
auto SourceIter =
|
||||
llvm::find_if(SourceExtensions, [&PathExt](PathRef SourceExt) {
|
||||
return SourceExt.equals_lower(PathExt);
|
||||
return SourceExt.equals_insensitive(PathExt);
|
||||
});
|
||||
bool IsSource = SourceIter != std::end(SourceExtensions);
|
||||
|
||||
auto HeaderIter =
|
||||
llvm::find_if(HeaderExtensions, [&PathExt](PathRef HeaderExt) {
|
||||
return HeaderExt.equals_lower(PathExt);
|
||||
return HeaderExt.equals_insensitive(PathExt);
|
||||
});
|
||||
bool IsHeader = HeaderIter != std::end(HeaderExtensions);
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ private:
|
|||
return false;
|
||||
|
||||
StringRef Name = getSimpleName(*Callee);
|
||||
if (!Name.startswith_lower("set"))
|
||||
if (!Name.startswith_insensitive("set"))
|
||||
return false;
|
||||
|
||||
// In addition to checking that the function has one parameter and its
|
||||
|
@ -168,10 +168,10 @@ private:
|
|||
// This currently doesn't handle cases where params use snake_case
|
||||
// and functions don't, e.g.
|
||||
// void setExceptionHandler(EHFunc exception_handler);
|
||||
// We could improve this by replacing `equals_lower` with some
|
||||
// We could improve this by replacing `equals_insensitive` with some
|
||||
// `sloppy_equals` which ignores case and also skips underscores.
|
||||
StringRef WhatItIsSetting = Name.substr(3).ltrim("_");
|
||||
return WhatItIsSetting.equals_lower(ParamNames[0]);
|
||||
return WhatItIsSetting.equals_insensitive(ParamNames[0]);
|
||||
}
|
||||
|
||||
bool shouldHint(const Expr *Arg, StringRef ParamName) {
|
||||
|
|
|
@ -378,7 +378,7 @@ static llvm::Optional<llvm::StringRef>
|
|||
wordMatching(llvm::StringRef Name, const llvm::StringSet<> *ContextWords) {
|
||||
if (ContextWords)
|
||||
for (const auto &Word : ContextWords->keys())
|
||||
if (Name.contains_lower(Word))
|
||||
if (Name.contains_insensitive(Word))
|
||||
return Word;
|
||||
return llvm::None;
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ evaluateDecisionForest(const SymbolQualitySignals &Quality,
|
|||
int NumMatch = 0;
|
||||
if (Relevance.ContextWords) {
|
||||
for (const auto &Word : Relevance.ContextWords->keys()) {
|
||||
if (Relevance.Name.contains_lower(Word)) {
|
||||
if (Relevance.Name.contains_insensitive(Word)) {
|
||||
++NumMatch;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -285,7 +285,8 @@ private:
|
|||
Line = Line.ltrim();
|
||||
if (!Line.startswith("error"))
|
||||
return false;
|
||||
return Line.contains_lower("includ"); // Matches "include" or "including".
|
||||
return Line.contains_insensitive(
|
||||
"includ"); // Matches "include" or "including".
|
||||
}
|
||||
|
||||
// Heuristically headers that only want to be included via an umbrella.
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace clangd {
|
|||
|
||||
#ifdef CLANGD_PATH_CASE_INSENSITIVE
|
||||
std::string maybeCaseFoldPath(PathRef Path) { return Path.lower(); }
|
||||
bool pathEqual(PathRef A, PathRef B) { return A.equals_lower(B); }
|
||||
bool pathEqual(PathRef A, PathRef B) { return A.equals_insensitive(B); }
|
||||
#else // NOT CLANGD_PATH_CASE_INSENSITIVE
|
||||
std::string maybeCaseFoldPath(PathRef Path) { return Path.str(); }
|
||||
bool pathEqual(PathRef A, PathRef B) { return A == B; }
|
||||
|
|
|
@ -470,9 +470,9 @@ bool ModularizeUtilities::isHeader(StringRef FileName) {
|
|||
StringRef Extension = llvm::sys::path::extension(FileName);
|
||||
if (Extension.size() == 0)
|
||||
return true;
|
||||
if (Extension.equals_lower(".h"))
|
||||
if (Extension.equals_insensitive(".h"))
|
||||
return true;
|
||||
if (Extension.equals_lower(".inc"))
|
||||
if (Extension.equals_insensitive(".inc"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue