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