[flang-commits] [flang] 4bac5f8 - Apply fixes from performance-faster-string-find (NFC)
Kazu Hirata via flang-commits
flang-commits at lists.llvm.org
Sun Apr 16 00:51:36 PDT 2023
Author: Kazu Hirata
Date: 2023-04-16T00:51:27-07:00
New Revision: 4bac5f8344ea6405e3964141c8f591c68eefd373
URL: https://github.com/llvm/llvm-project/commit/4bac5f8344ea6405e3964141c8f591c68eefd373
DIFF: https://github.com/llvm/llvm-project/commit/4bac5f8344ea6405e3964141c8f591c68eefd373.diff
LOG: Apply fixes from performance-faster-string-find (NFC)
Added:
Modified:
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
flang/lib/Semantics/check-io.cpp
lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp
llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index eeb0642baa100..9561b2b00904f 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -337,10 +337,10 @@ std::string IdentifierNamingCheck::HungarianNotation::getDeclTypeName(
Type.replace(Pos, Kw.size(), "");
}
}
- TypeName = Type.erase(0, Type.find_first_not_of(" "));
+ TypeName = Type.erase(0, Type.find_first_not_of(' '));
// Remove template parameters
- const size_t Pos = Type.find("<");
+ const size_t Pos = Type.find('<');
if (Pos != std::string::npos) {
TypeName = Type.erase(Pos, Type.size() - Pos);
}
@@ -377,14 +377,14 @@ std::string IdentifierNamingCheck::HungarianNotation::getDeclTypeName(
}
}
- TypeName = Type.erase(0, Type.find_first_not_of(" "));
+ TypeName = Type.erase(0, Type.find_first_not_of(' '));
if (!RedundantRemoved) {
- std::size_t FoundSpace = Type.find(" ");
+ std::size_t FoundSpace = Type.find(' ');
if (FoundSpace != std::string::npos)
Type = Type.substr(0, FoundSpace);
}
- TypeName = Type.erase(0, Type.find_first_not_of(" "));
+ TypeName = Type.erase(0, Type.find_first_not_of(' '));
QualType QT = VD->getType();
if (!QT.isNull() && QT->isArrayType())
@@ -586,7 +586,7 @@ std::string IdentifierNamingCheck::HungarianNotation::getDataTypePrefix(
if (PrefixStr.empty())
PrefixStr = HNOption.DerivedType.lookup("Array");
} else if (QT->isReferenceType()) {
- size_t Pos = ModifiedTypeName.find_last_of("&");
+ size_t Pos = ModifiedTypeName.find_last_of('&');
if (Pos != std::string::npos)
ModifiedTypeName = ModifiedTypeName.substr(0, Pos);
}
@@ -653,7 +653,7 @@ std::string IdentifierNamingCheck::HungarianNotation::getEnumPrefix(
std::string Name = ED->getName().str();
if (std::string::npos != Name.find("enum")) {
Name = Name.substr(strlen("enum"), Name.length() - strlen("enum"));
- Name = Name.erase(0, Name.find_first_not_of(" "));
+ Name = Name.erase(0, Name.find_first_not_of(' '));
}
static llvm::Regex Splitter(
diff --git a/flang/lib/Semantics/check-io.cpp b/flang/lib/Semantics/check-io.cpp
index 6df5eadc8ae62..1c1b07c422bac 100644
--- a/flang/lib/Semantics/check-io.cpp
+++ b/flang/lib/Semantics/check-io.cpp
@@ -101,7 +101,7 @@ void IoChecker::Enter(const parser::ConnectSpec &spec) {
// Ignore trailing spaces (12.5.6.2 p1) and convert to upper case
static std::string Normalize(const std::string &value) {
auto upper{parser::ToUpperCaseLetters(value)};
- std::size_t lastNonBlank{upper.find_last_not_of(" ")};
+ std::size_t lastNonBlank{upper.find_last_not_of(' ')};
upper.resize(lastNonBlank == std::string::npos ? 0 : lastNonBlank + 1);
return upper;
}
diff --git a/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp b/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp
index 277fec9f7116e..a38b75c9e615f 100644
--- a/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp
+++ b/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp
@@ -81,7 +81,7 @@ static std::optional<int> GetCGroupFileDescriptor(lldb::pid_t pid) {
if (line.find("0:") != 0)
continue;
- std::string slice = line.substr(line.find_first_of("/"));
+ std::string slice = line.substr(line.find_first_of('/'));
if (slice.empty())
return std::nullopt;
std::string cgroup_file = formatv("/sys/fs/cgroup/{0}", slice);
diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index bfa748e7a6950..ccb7a37c83d54 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -1256,7 +1256,7 @@ void DataFlowSanitizer::addGlobalNameSuffix(GlobalValue *GV) {
size_t Pos = Asm.find(SearchStr);
if (Pos != std::string::npos) {
Asm.replace(Pos, SearchStr.size(), ".symver " + GVName + Suffix + ",");
- Pos = Asm.find("@");
+ Pos = Asm.find('@');
if (Pos == std::string::npos)
report_fatal_error(Twine("unsupported .symver: ", Asm));
More information about the flang-commits
mailing list