aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas van Kempen <nvankemp@gmail.com>2024-04-19 17:00:13 -0400
committerGitHub <noreply@github.com>2024-04-19 14:00:13 -0700
commit5232cec8f947ed8bff4ca57f990954228d58e66d (patch)
tree24ca16f17ecbb7cf9102ce380a8eabf6c1a1efee
parentd634b233640dc38cf5f673a9cfcd1fe55124430a (diff)
downloadllvm-5232cec8f947ed8bff4ca57f990954228d58e66d.zip
llvm-5232cec8f947ed8bff4ca57f990954228d58e66d.tar.gz
llvm-5232cec8f947ed8bff4ca57f990954228d58e66d.tar.bz2
Apply modernize-use-starts-ends-with on llvm-project (#89140)
Run `modernize-use-starts-ends-with` on llvm-project. Two instances are flagged, minor readability improvements, extremely minor performance improvements. ``` python3 clang-tools-extra/clang-tidy/tool/run-clang-tidy.py \ -clang-tidy-binary="build/bin/clang-tidy" \ -clang-apply-replacements-binary="build/bin/clang-apply-replacements" \ -checks="-*,modernize-use-starts-ends-with" \ -header-filter=".*" \ -fix -format ``` I am working on some additions to this check, but they don't seem to flag any additional cases anyway.
-rw-r--r--clang-tools-extra/clang-doc/Representation.cpp4
-rw-r--r--lldb/unittests/Host/FileSystemTest.cpp2
-rw-r--r--llvm/unittests/Support/VirtualFileSystemTest.cpp2
3 files changed, 4 insertions, 4 deletions
diff --git a/clang-tools-extra/clang-doc/Representation.cpp b/clang-tools-extra/clang-doc/Representation.cpp
index 84233c3..2afff29 100644
--- a/clang-tools-extra/clang-doc/Representation.cpp
+++ b/clang-tools-extra/clang-doc/Representation.cpp
@@ -380,8 +380,8 @@ ClangDocContext::ClangDocContext(tooling::ExecutionContext *ECtx,
this->SourceRoot = std::string(SourceRootDir);
if (!RepositoryUrl.empty()) {
this->RepositoryUrl = std::string(RepositoryUrl);
- if (!RepositoryUrl.empty() && RepositoryUrl.find("http://") != 0 &&
- RepositoryUrl.find("https://") != 0)
+ if (!RepositoryUrl.empty() && !RepositoryUrl.starts_with("http://") &&
+ !RepositoryUrl.starts_with("https://"))
this->RepositoryUrl->insert(0, "https://");
}
}
diff --git a/lldb/unittests/Host/FileSystemTest.cpp b/lldb/unittests/Host/FileSystemTest.cpp
index 3b5ee7c..58887f6 100644
--- a/lldb/unittests/Host/FileSystemTest.cpp
+++ b/lldb/unittests/Host/FileSystemTest.cpp
@@ -93,7 +93,7 @@ public:
std::map<std::string, vfs::Status>::iterator I;
std::string Path;
bool isInPath(StringRef S) {
- if (Path.size() < S.size() && S.find(Path) == 0) {
+ if (Path.size() < S.size() && S.starts_with(Path)) {
auto LastSep = S.find_last_of('/');
if (LastSep == Path.size() || LastSep == Path.size() - 1)
return true;
diff --git a/llvm/unittests/Support/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp
index e9b4ac3..e9fd967 100644
--- a/llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ b/llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -101,7 +101,7 @@ public:
std::map<std::string, vfs::Status>::iterator I;
std::string Path;
bool isInPath(StringRef S) {
- if (Path.size() < S.size() && S.find(Path) == 0) {
+ if (Path.size() < S.size() && S.starts_with(Path)) {
auto LastSep = S.find_last_of('/');
if (LastSep == Path.size() || LastSep == Path.size() - 1)
return true;