[clang-tools-extra] 972d413 - Use {DenseSet, SmallPtrSet}::contains (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 29 20:26:22 PDT 2021


Author: Kazu Hirata
Date: 2021-10-29T20:26:07-07:00
New Revision: 972d4133e9685558d0a1740d306af70c57e8e67a

URL: https://github.com/llvm/llvm-project/commit/972d4133e9685558d0a1740d306af70c57e8e67a
DIFF: https://github.com/llvm/llvm-project/commit/972d4133e9685558d0a1740d306af70c57e8e67a.diff

LOG: Use {DenseSet,SmallPtrSet}::contains (NFC)

Added: 
    

Modified: 
    clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
    clang/lib/CodeGen/VarBypassDetector.h
    llvm/lib/Analysis/IRSimilarityIdentifier.cpp
    llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
index 8255ea519f65f..da67c7ee27c2e 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -230,7 +230,7 @@ bool alwaysReturns(const ExtractionZone &EZ) {
 }
 
 bool ExtractionZone::isRootStmt(const Stmt *S) const {
-  return RootStmts.find(S) != RootStmts.end();
+  return RootStmts.contains(S);
 }
 
 // Finds the function in which the zone lies.

diff  --git a/clang/lib/CodeGen/VarBypassDetector.h b/clang/lib/CodeGen/VarBypassDetector.h
index b654eefd963d0..164e88c0b2f1b 100644
--- a/clang/lib/CodeGen/VarBypassDetector.h
+++ b/clang/lib/CodeGen/VarBypassDetector.h
@@ -55,7 +55,7 @@ class VarBypassDetector {
   /// Returns true if the variable declaration was by bypassed by any goto or
   /// switch statement.
   bool IsBypassed(const VarDecl *D) const {
-    return AlwaysBypassed || Bypasses.find(D) != Bypasses.end();
+    return AlwaysBypassed || Bypasses.contains(D);
   }
 
 private:

diff  --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
index 50831d311a6de..f22c6aa04f5ee 100644
--- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
+++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
@@ -624,8 +624,8 @@ bool IRSimilarityCandidate::checkRelativeLocations(RelativeLocMapping A,
   B.IRSC.getBasicBlocks(BasicBlockB);
   
   // Determine if the block is contained in the region.
-  bool AContained = BasicBlockA.find(ABB) != BasicBlockA.end();
-  bool BContained = BasicBlockB.find(BBB) != BasicBlockB.end();
+  bool AContained = BasicBlockA.contains(ABB);
+  bool BContained = BasicBlockB.contains(BBB);
 
   // Both blocks need to be contained in the region, or both need to be outside
   // the reigon.
@@ -895,14 +895,14 @@ void IRSimilarityCandidate::createCanonicalRelationFrom(
       bool Found = false;
       for (unsigned Val : GVNMapping.second) {
         // We make sure the target value number hasn't already been reserved.
-        if (UsedGVNs.find(Val) != UsedGVNs.end())
+        if (UsedGVNs.contains(Val))
           continue;
 
         // We make sure that the opposite mapping is still consistent.
         DenseMap<unsigned, DenseSet<unsigned>>::iterator It =
             FromSourceMapping.find(Val);
 
-        if (It->second.find(SourceGVN) == It->second.end())
+        if (!It->second.contains(SourceGVN))
           continue;
 
         // We pick the first item that satisfies these conditions.

diff  --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
index cfa74464559fa..8c45232060706 100644
--- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
@@ -490,7 +490,7 @@ struct MainSwitch {
   }
 
   bool isPredictableValue(Value *InpVal, SmallSet<Value *, 16> &SeenValues) {
-    if (SeenValues.find(InpVal) != SeenValues.end())
+    if (SeenValues.contains(InpVal))
       return true;
 
     if (isa<ConstantInt>(InpVal))
@@ -505,7 +505,7 @@ struct MainSwitch {
 
   void addInstToQueue(Value *Val, std::deque<Instruction *> &Q,
                       SmallSet<Value *, 16> &SeenValues) {
-    if (SeenValues.find(Val) != SeenValues.end())
+    if (SeenValues.contains(Val))
       return;
     if (Instruction *I = dyn_cast<Instruction>(Val))
       Q.push_back(I);
@@ -668,7 +668,7 @@ struct AllSwitchPaths {
 
       for (Value *Incoming : CurPhi->incoming_values()) {
         if (Incoming == FirstDef || isa<ConstantInt>(Incoming) ||
-            SeenValues.find(Incoming) != SeenValues.end()) {
+            SeenValues.contains(Incoming)) {
           continue;
         }
 


        


More information about the cfe-commits mailing list