Skip to content

Commit

Permalink
Use {DenseSet,SmallPtrSet}::contains (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Oct 30, 2021
1 parent afeb1e4 commit 972d413
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/VarBypassDetector.h
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Analysis/IRSimilarityIdentifier.cpp
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
Expand Up @@ -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))
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 972d413

Please sign in to comment.