-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang] Use llvm::is_contained (NFC) #140985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_20250521_range_llvm_is_contained_clang
May 22, 2025
Merged
[clang] Use llvm::is_contained (NFC) #140985
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_20250521_range_llvm_is_contained_clang
May 22, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-clang Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/140985.diff 4 Files Affected:
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index a994b845e11fc..9f945066280b5 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -14627,8 +14627,8 @@ class Sema final : public SemaBase {
bool SatisfactionStackContains(const NamedDecl *D,
const llvm::FoldingSetNodeID &ID) const {
const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
- return llvm::find(SatisfactionStack, SatisfactionStackEntryTy{Can, ID}) !=
- SatisfactionStack.end();
+ return llvm::is_contained(SatisfactionStack,
+ SatisfactionStackEntryTy{Can, ID});
}
using SatisfactionStackEntryTy =
diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index c04b2099a4b9a..4b407a0172adb 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -654,14 +654,13 @@ void Interpreter::ResetExecutor() { IncrExecutor.reset(); }
llvm::Error Interpreter::Execute(PartialTranslationUnit &T) {
assert(T.TheModule);
- LLVM_DEBUG(llvm::dbgs()
- << "execute-ptu "
- << ((std::find(PTUs.begin(), PTUs.end(), T) != PTUs.end())
- ? std::distance(PTUs.begin(),
- std::find(PTUs.begin(), PTUs.end(), T))
- : -1)
- << ": [TU=" << T.TUPart << ", M=" << T.TheModule.get() << " ("
- << T.TheModule->getName() << ")]\n");
+ LLVM_DEBUG(
+ llvm::dbgs() << "execute-ptu "
+ << (llvm::is_contained(PTUs, T)
+ ? std::distance(PTUs.begin(), llvm::find(PTUs, T))
+ : -1)
+ << ": [TU=" << T.TUPart << ", M=" << T.TheModule.get()
+ << " (" << T.TheModule->getName() << ")]\n");
if (!IncrExecutor) {
auto Err = CreateExecutor();
if (Err)
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.h b/clang/unittests/ASTMatchers/ASTMatchersTest.h
index 6eea39ae787fa..c1d4daea2c9f1 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -110,7 +110,7 @@ testing::AssertionResult matchesConditionally(
// Append additional arguments at the end to allow overriding the default
// choices that we made above.
llvm::copy(CompileArgs, std::back_inserter(Args));
- if (llvm::find(Args, "-target") == Args.end()) {
+ if (!llvm::is_contained(Args, "-target")) {
// Use an unknown-unknown triple so we don't instantiate the full system
// toolchain. On Linux, instantiating the toolchain involves stat'ing
// large portions of /usr/lib, and this slows down not only this test, but
diff --git a/clang/unittests/Tooling/ToolingTest.cpp b/clang/unittests/Tooling/ToolingTest.cpp
index 8cdfffb54390e..cfa021a5ef137 100644
--- a/clang/unittests/Tooling/ToolingTest.cpp
+++ b/clang/unittests/Tooling/ToolingTest.cpp
@@ -793,7 +793,7 @@ TEST(ClangToolTest, StripDependencyFileAdjuster) {
Tool.run(Action.get());
auto HasFlag = [&FinalArgs](const std::string &Flag) {
- return llvm::find(FinalArgs, Flag) != FinalArgs.end();
+ return llvm::is_contained(FinalArgs, Flag);
};
EXPECT_FALSE(HasFlag("-MD"));
EXPECT_FALSE(HasFlag("-MMD"));
@@ -825,7 +825,7 @@ TEST(ClangToolTest, StripDependencyFileAdjusterShowIncludes) {
Tool.run(Action.get());
auto HasFlag = [&FinalArgs](const std::string &Flag) {
- return llvm::find(FinalArgs, Flag) != FinalArgs.end();
+ return llvm::is_contained(FinalArgs, Flag);
};
EXPECT_FALSE(HasFlag("/showIncludes"));
EXPECT_FALSE(HasFlag("/showIncludes:user"));
@@ -858,7 +858,7 @@ TEST(ClangToolTest, StripDependencyFileAdjusterMsvc) {
Tool.run(Action.get());
auto HasFlag = [&FinalArgs](const std::string &Flag) {
- return llvm::find(FinalArgs, Flag) != FinalArgs.end();
+ return llvm::is_contained(FinalArgs, Flag);
};
EXPECT_TRUE(HasFlag("-MD"));
EXPECT_TRUE(HasFlag("-MDd"));
@@ -891,7 +891,7 @@ TEST(ClangToolTest, StripPluginsAdjuster) {
Tool.run(Action.get());
auto HasFlag = [&FinalArgs](const std::string &Flag) {
- return llvm::find(FinalArgs, Flag) != FinalArgs.end();
+ return llvm::is_contained(FinalArgs, Flag);
};
EXPECT_FALSE(HasFlag("-Xclang"));
EXPECT_FALSE(HasFlag("-add-plugin"));
|
arsenm
approved these changes
May 22, 2025
tgymnich
approved these changes
May 22, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.