[llvm-branch-commits] [clang] 8acb5f2 - [clang][driver][NFC] Use StringRef instead of std::string
Nathan James via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Dec 15 08:24:20 PST 2020
Author: Nathan James
Date: 2020-12-15T16:19:12Z
New Revision: 8acb5f2723ecaf0f1904a085ad79d0623cec38f6
URL: https://github.com/llvm/llvm-project/commit/8acb5f2723ecaf0f1904a085ad79d0623cec38f6
DIFF: https://github.com/llvm/llvm-project/commit/8acb5f2723ecaf0f1904a085ad79d0623cec38f6.diff
LOG: [clang][driver][NFC] Use StringRef instead of std::string
Added:
Modified:
clang/lib/Driver/Driver.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 5e4eb8c4e6c5..dc9ec1b9c362 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -779,10 +779,9 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
/// by Dirs.
///
static bool searchForFile(SmallVectorImpl<char> &FilePath,
- ArrayRef<std::string> Dirs,
- StringRef FileName) {
+ ArrayRef<StringRef> Dirs, StringRef FileName) {
SmallString<128> WPath;
- for (const std::string &Dir : Dirs) {
+ for (const StringRef &Dir : Dirs) {
if (Dir.empty())
continue;
WPath.clear();
@@ -807,7 +806,7 @@ bool Driver::readConfigFile(StringRef FileName) {
// Read options from config file.
llvm::SmallString<128> CfgFileName(FileName);
llvm::sys::path::native(CfgFileName);
- ConfigFile = std::string(CfgFileName.str());
+ ConfigFile = std::string(CfgFileName);
bool ContainErrors;
CfgOptions = std::make_unique<InputArgList>(
ParseArgStrings(NewCfgArgs, IsCLMode(), ContainErrors));
@@ -864,9 +863,10 @@ bool Driver::loadConfigFile() {
std::vector<std::string> ConfigFiles =
CLOptions->getAllArgValues(options::OPT_config);
if (ConfigFiles.size() > 1) {
- if (!std::all_of(
- ConfigFiles.begin(), ConfigFiles.end(),
- [ConfigFiles](std::string s) { return s == ConfigFiles[0]; })) {
+ if (!std::all_of(ConfigFiles.begin(), ConfigFiles.end(),
+ [ConfigFiles](const std::string &s) {
+ return s == ConfigFiles[0];
+ })) {
Diag(diag::err_drv_duplicate_config);
return true;
}
@@ -939,10 +939,7 @@ bool Driver::loadConfigFile() {
}
// Prepare list of directories where config file is searched for.
- SmallVector<std::string, 3> CfgFileSearchDirs;
- CfgFileSearchDirs.push_back(UserConfigDir);
- CfgFileSearchDirs.push_back(SystemConfigDir);
- CfgFileSearchDirs.push_back(Dir);
+ StringRef CfgFileSearchDirs[] = {UserConfigDir, SystemConfigDir, Dir};
// Try to find config file. First try file with corrected architecture.
llvm::SmallString<128> CfgFilePath;
@@ -973,7 +970,7 @@ bool Driver::loadConfigFile() {
// --config. If it was deduced from executable name, it is not an error.
if (FileSpecifiedExplicitly) {
Diag(diag::err_drv_config_file_not_found) << CfgFileName;
- for (const std::string &SearchDir : CfgFileSearchDirs)
+ for (const StringRef &SearchDir : CfgFileSearchDirs)
if (!SearchDir.empty())
Diag(diag::note_drv_config_file_searched_in) << SearchDir;
return true;
More information about the llvm-branch-commits
mailing list