forked from OSchip/llvm-project
[Driver, Frontend] Use StringRef::contains (NFC)
This commit is contained in:
parent
b492b0be95
commit
cf68e1b2fb
|
@ -118,11 +118,11 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
|
|||
return Distro::Fedora;
|
||||
if (Data.startswith("Red Hat Enterprise Linux") ||
|
||||
Data.startswith("CentOS") || Data.startswith("Scientific Linux")) {
|
||||
if (Data.find("release 7") != StringRef::npos)
|
||||
if (Data.contains("release 7"))
|
||||
return Distro::RHEL7;
|
||||
else if (Data.find("release 6") != StringRef::npos)
|
||||
else if (Data.contains("release 6"))
|
||||
return Distro::RHEL6;
|
||||
else if (Data.find("release 5") != StringRef::npos)
|
||||
else if (Data.contains("release 5"))
|
||||
return Distro::RHEL5;
|
||||
}
|
||||
return Distro::UnknownDistro;
|
||||
|
|
|
@ -436,8 +436,7 @@ static llvm::Triple computeTargetTriple(const Driver &D,
|
|||
// GNU/Hurd's triples should have been -hurd-gnu*, but were historically made
|
||||
// -gnu* only, and we can not change this, so we have to detect that case as
|
||||
// being the Hurd OS.
|
||||
if (TargetTriple.find("-unknown-gnu") != StringRef::npos ||
|
||||
TargetTriple.find("-pc-gnu") != StringRef::npos)
|
||||
if (TargetTriple.contains("-unknown-gnu") || TargetTriple.contains("-pc-gnu"))
|
||||
Target.setOSName("hurd");
|
||||
|
||||
// Handle Apple-specific options available here.
|
||||
|
|
|
@ -583,7 +583,7 @@ std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD,
|
|||
// for the linker flavor is brittle. In addition, prepending "ld." or "ld64."
|
||||
// to a relative path is surprising. This is more complex due to priorities
|
||||
// among -B, COMPILER_PATH and PATH. --ld-path= should be used instead.
|
||||
if (UseLinker.find('/') != StringRef::npos)
|
||||
if (UseLinker.contains('/'))
|
||||
getDriver().Diag(diag::warn_drv_fuse_ld_path);
|
||||
|
||||
if (llvm::sys::path::is_absolute(UseLinker)) {
|
||||
|
|
|
@ -644,7 +644,7 @@ static void addDebugPrefixMapArg(const Driver &D, const ArgList &Args, ArgString
|
|||
for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ,
|
||||
options::OPT_fdebug_prefix_map_EQ)) {
|
||||
StringRef Map = A->getValue();
|
||||
if (Map.find('=') == StringRef::npos)
|
||||
if (!Map.contains('='))
|
||||
D.Diag(diag::err_drv_invalid_argument_to_option)
|
||||
<< Map << A->getOption().getName();
|
||||
else
|
||||
|
@ -659,7 +659,7 @@ static void addMacroPrefixMapArg(const Driver &D, const ArgList &Args,
|
|||
for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ,
|
||||
options::OPT_fmacro_prefix_map_EQ)) {
|
||||
StringRef Map = A->getValue();
|
||||
if (Map.find('=') == StringRef::npos)
|
||||
if (!Map.contains('='))
|
||||
D.Diag(diag::err_drv_invalid_argument_to_option)
|
||||
<< Map << A->getOption().getName();
|
||||
else
|
||||
|
@ -674,7 +674,7 @@ static void addCoveragePrefixMapArg(const Driver &D, const ArgList &Args,
|
|||
for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ,
|
||||
options::OPT_fcoverage_prefix_map_EQ)) {
|
||||
StringRef Map = A->getValue();
|
||||
if (Map.find('=') == StringRef::npos)
|
||||
if (!Map.contains('='))
|
||||
D.Diag(diag::err_drv_invalid_argument_to_option)
|
||||
<< Map << A->getOption().getName();
|
||||
else
|
||||
|
|
|
@ -110,7 +110,7 @@ void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ,
|
||||
options::OPT_fdebug_prefix_map_EQ)) {
|
||||
StringRef Map = A->getValue();
|
||||
if (Map.find('=') == StringRef::npos)
|
||||
if (!Map.contains('='))
|
||||
D.Diag(diag::err_drv_invalid_argument_to_option)
|
||||
<< Map << A->getOption().getName();
|
||||
else {
|
||||
|
|
|
@ -930,7 +930,7 @@ void tools::gnutools::Assembler::ConstructJob(Compilation &C,
|
|||
for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ,
|
||||
options::OPT_fdebug_prefix_map_EQ)) {
|
||||
StringRef Map = A->getValue();
|
||||
if (Map.find('=') == StringRef::npos)
|
||||
if (!Map.contains('='))
|
||||
D.Diag(diag::err_drv_invalid_argument_to_option)
|
||||
<< Map << A->getOption().getName();
|
||||
else {
|
||||
|
|
|
@ -206,7 +206,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
|
|||
ExtraOpts.push_back("max-page-size=4096");
|
||||
}
|
||||
|
||||
if (GCCInstallation.getParentLibPath().find("opt/rh/") != StringRef::npos)
|
||||
if (GCCInstallation.getParentLibPath().contains("opt/rh/"))
|
||||
// With devtoolset on RHEL, we want to add a bin directory that is relative
|
||||
// to the detected gcc install, because if we are using devtoolset gcc then
|
||||
// we want to use other tools from devtoolset (e.g. ld) instead of the
|
||||
|
|
|
@ -999,7 +999,7 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
|
|||
diag::err_analyzer_config_no_value) << configVal;
|
||||
break;
|
||||
}
|
||||
if (val.find('=') != StringRef::npos) {
|
||||
if (val.contains('=')) {
|
||||
Diags.Report(SourceLocation(),
|
||||
diag::err_analyzer_config_multiple_values)
|
||||
<< configVal;
|
||||
|
@ -2061,13 +2061,13 @@ static bool ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
|
|||
if (!Args.hasArg(OPT_fno_sanitize_ignorelist)) {
|
||||
for (const auto *A : Args.filtered(OPT_fsanitize_ignorelist_EQ)) {
|
||||
StringRef Val = A->getValue();
|
||||
if (Val.find('=') == StringRef::npos)
|
||||
if (!Val.contains('='))
|
||||
Opts.ExtraDeps.emplace_back(std::string(Val), EDK_SanitizeIgnorelist);
|
||||
}
|
||||
if (Opts.IncludeSystemHeaders) {
|
||||
for (const auto *A : Args.filtered(OPT_fsanitize_system_ignorelist_EQ)) {
|
||||
StringRef Val = A->getValue();
|
||||
if (Val.find('=') == StringRef::npos)
|
||||
if (!Val.contains('='))
|
||||
Opts.ExtraDeps.emplace_back(std::string(Val), EDK_SanitizeIgnorelist);
|
||||
}
|
||||
}
|
||||
|
@ -2084,7 +2084,7 @@ static bool ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
|
|||
// Only the -fmodule-file=<file> form.
|
||||
for (const auto *A : Args.filtered(OPT_fmodule_file)) {
|
||||
StringRef Val = A->getValue();
|
||||
if (Val.find('=') == StringRef::npos)
|
||||
if (!Val.contains('='))
|
||||
Opts.ExtraDeps.emplace_back(std::string(Val), EDK_ModuleFile);
|
||||
}
|
||||
|
||||
|
@ -2728,7 +2728,7 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
|
|||
// Only the -fmodule-file=<file> form.
|
||||
for (const auto *A : Args.filtered(OPT_fmodule_file)) {
|
||||
StringRef Val = A->getValue();
|
||||
if (Val.find('=') == StringRef::npos)
|
||||
if (!Val.contains('='))
|
||||
Opts.ModuleFiles.push_back(std::string(Val));
|
||||
}
|
||||
|
||||
|
@ -3003,7 +3003,7 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
|
|||
// Only the -fmodule-file=<name>=<file> form.
|
||||
for (const auto *A : Args.filtered(OPT_fmodule_file)) {
|
||||
StringRef Val = A->getValue();
|
||||
if (Val.find('=') != StringRef::npos){
|
||||
if (Val.contains('=')) {
|
||||
auto Split = Val.split('=');
|
||||
Opts.PrebuiltModuleFiles.insert(
|
||||
{std::string(Split.first), std::string(Split.second)});
|
||||
|
|
|
@ -43,7 +43,7 @@ LayoutOverrideSource::LayoutOverrideSource(StringRef Filename) {
|
|||
StringRef LineStr(Line);
|
||||
|
||||
// Determine whether the following line will start a
|
||||
if (LineStr.find("*** Dumping AST Record Layout") != StringRef::npos) {
|
||||
if (LineStr.contains("*** Dumping AST Record Layout")) {
|
||||
// Flush the last type/layout, if there is one.
|
||||
if (!CurrentType.empty())
|
||||
Layouts[CurrentType] = CurrentLayout;
|
||||
|
|
|
@ -99,9 +99,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool match(StringRef S) override {
|
||||
return S.find(Text) != StringRef::npos;
|
||||
}
|
||||
bool match(StringRef S) override { return S.contains(Text); }
|
||||
};
|
||||
|
||||
/// RegexDirective - Directive with regular-expression matching.
|
||||
|
|
Loading…
Reference in New Issue