diff --git a/include/revng-c/DataLayoutAnalysis/DLATypeSystem.h b/include/revng-c/DataLayoutAnalysis/DLATypeSystem.h index 8f8fbb651..9f6c8431e 100644 --- a/include/revng-c/DataLayoutAnalysis/DLATypeSystem.h +++ b/include/revng-c/DataLayoutAnalysis/DLATypeSystem.h @@ -276,8 +276,8 @@ protected: addLink(LayoutTypeSystemNode *Src, LayoutTypeSystemNode *Tgt, TagT &&Tag) { if (Src == nullptr or Tgt == nullptr or Src == Tgt) return std::make_pair(nullptr, false); - revng_assert(Layouts.count(Src)); - revng_assert(Layouts.count(Tgt)); + revng_assert(Layouts.contains(Src)); + revng_assert(Layouts.contains(Tgt)); auto It = LinkTags.insert(std::forward(Tag)).first; revng_assert(It != LinkTags.end()); const TypeLinkTag *T = &*It; diff --git a/include/revng-c/RestructureCFG/BasicBlockNodeImpl.h b/include/revng-c/RestructureCFG/BasicBlockNodeImpl.h index 9f92941dc..12b61e766 100644 --- a/include/revng-c/RestructureCFG/BasicBlockNodeImpl.h +++ b/include/revng-c/RestructureCFG/BasicBlockNodeImpl.h @@ -195,14 +195,14 @@ inline void handleNeighbors(const BBNodeMap &SubMap, Neighbors.erase(std::remove_if(Neighbors.begin(), Neighbors.end(), - [&SubMap](const auto &NodeWithLabels) { - return !SubMap.count(NodeWithLabels.first); + [&SubMap](const auto &LabeledNode) { + return !SubMap.contains(LabeledNode.first); }), Neighbors.end()); for (auto &NeighborLabelPair : Neighbors) { auto &Neighbor = NeighborLabelPair.first; - revng_assert(SubMap.count(Neighbor) != 0); + revng_assert(SubMap.contains(Neighbor)); Neighbor = SubMap.at(Neighbor); } } diff --git a/include/revng-c/RestructureCFG/GenerateAst.h b/include/revng-c/RestructureCFG/GenerateAst.h index 961cab29d..e60598986 100644 --- a/include/revng-c/RestructureCFG/GenerateAst.h +++ b/include/revng-c/RestructureCFG/GenerateAst.h @@ -285,9 +285,8 @@ template inline ASTNode *findASTNode(ASTTree &AST, typename RegionCFG::BBNodeMap &TileToNodeMap, BasicBlockNode *Node) { - if (TileToNodeMap.count(Node) != 0) { - Node = TileToNodeMap.at(Node); - } + if (auto It = TileToNodeMap.find(Node); It != TileToNodeMap.end()) + Node = It->second; return AST.findASTNode(Node); } diff --git a/include/revng-c/RestructureCFG/MetaRegion.h b/include/revng-c/RestructureCFG/MetaRegion.h index 8fa1df761..42d58ddbc 100644 --- a/include/revng-c/RestructureCFG/MetaRegion.h +++ b/include/revng-c/RestructureCFG/MetaRegion.h @@ -98,7 +98,9 @@ public: bool isSCS() const { return IsSCS; } - bool containsNode(BasicBlockNodeT *Node) const { return Nodes.count(Node); } + bool containsNode(BasicBlockNodeT *Node) const { + return Nodes.contains(Node); + } void insertNode(BasicBlockNodeT *NewNode) { Nodes.insert(NewNode); } diff --git a/include/revng-c/RestructureCFG/MetaRegionImpl.h b/include/revng-c/RestructureCFG/MetaRegionImpl.h index 17771c109..5683ce49f 100644 --- a/include/revng-c/RestructureCFG/MetaRegionImpl.h +++ b/include/revng-c/RestructureCFG/MetaRegionImpl.h @@ -27,12 +27,9 @@ void MetaRegion::updateNodes(BasicBlockNodeTSet &Removal, BasicBlockNodeTVect &OutlinedNodes) { // Remove the old SCS nodes bool NeedSubstitution = false; - for (BasicBlockNodeT *Node : Removal) { - if (Nodes.count(Node) != 0) { - Nodes.erase(Node); + for (BasicBlockNodeT *Node : Removal) + if (Nodes.erase(Node)) NeedSubstitution = true; - } - } // Add the collapsed node. if (NeedSubstitution) { diff --git a/include/revng-c/RestructureCFG/RegionCFGTreeImpl.h b/include/revng-c/RestructureCFG/RegionCFGTreeImpl.h index 0f5e3f762..6943352ec 100644 --- a/include/revng-c/RestructureCFG/RegionCFGTreeImpl.h +++ b/include/revng-c/RestructureCFG/RegionCFGTreeImpl.h @@ -388,11 +388,9 @@ RegionCFG::cloneUntilExit(BasicBlockNode *Node, // Ensure that we are not processing the sink node. revng_assert(CurrentNode != Sink); - if (AlreadyProcessed.count(CurrentNode) == 0) { - AlreadyProcessed.insert(CurrentNode); - } else { + auto [_, Inserted] = AlreadyProcessed.insert(CurrentNode); + if (!Inserted) continue; - } // Get the clone of the `CurrentNode`. BasicBlockNode *CurrentClone = CloneMap.at(CurrentNode); @@ -469,7 +467,7 @@ inline void RegionCFG::untangle() { llvm::ReversePostOrderTraversal *> RPOT(EntryNode); for (BasicBlockNode *RPOTBB : RPOT) { - if (ConditionalNodesSet.count(RPOTBB) != 0) { + if (ConditionalNodesSet.contains(RPOTBB)) { ConditionalNodes.push_back(RPOTBB); } } @@ -876,7 +874,7 @@ inline void RegionCFG::inflate() { RevPostOrderList.push_back(RPOTBB); NodesEquivalenceClass[RPOTBB].insert(RPOTBB); CloneToOriginalMap[RPOTBB] = RPOTBB; - if (ConditionalNodesSet.count(RPOTBB)) + if (ConditionalNodesSet.contains(RPOTBB)) ConditionalNodes.push_back(RPOTBB); } NodesEquivalenceClass[nullptr] = {}; @@ -923,7 +921,7 @@ inline void RegionCFG::inflate() { int Iteration = 0; while (++ListIt != RevPostOrderList.end() and not WorkList.empty()) { - if (not WorkList.count(*ListIt)) + if (not WorkList.contains(*ListIt)) continue; // Go to the next node in reverse postorder. // Otherwise this node is in the worklist, and we have to analyze it. @@ -935,14 +933,14 @@ inline void RegionCFG::inflate() { bool AllPredAreVisited = std::all_of(Candidate->predecessors().begin(), Candidate->predecessors().end(), [&Visited](auto *Pred) { - return Visited.count(Pred); + return Visited.contains(Pred); }); WorkList.erase(Candidate); Visited.insert(Candidate); // Comb end flag, which is useful to understand if the dummies we will // insert will need to substitute the current postdominator. - bool IsCombEnd = CombEndSetIt->second.count(Candidate); + bool IsCombEnd = CombEndSetIt->second.contains(Candidate); if (not IsCombEnd) { for (auto &[Successor, EdgeLabel] : Candidate->labeled_successors()) { @@ -964,7 +962,7 @@ inline void RegionCFG::inflate() { revng_log(CombLogger, "Current predecessors are:"); for (BasicBlockNode *Predecessor : Candidate->predecessors()) { revng_log(CombLogger, Predecessor->getNameStr()); - if (Visited.count(Predecessor)) + if (Visited.contains(Predecessor)) NewDummyPredecessors.push_back(Predecessor); } @@ -1045,7 +1043,7 @@ inline void RegionCFG::inflate() { // they become predecessors of Duplicated BasicBlockNodeTVect NotVisitedPredecessors; for (BasicBlockNode *Predecessor : Candidate->predecessors()) - if (not Visited.count(Predecessor)) + if (not Visited.contains(Predecessor)) NotVisitedPredecessors.push_back(Predecessor); for (BasicBlockNode *Predecessor : NotVisitedPredecessors) { diff --git a/include/revng-c/RestructureCFG/Utils.h b/include/revng-c/RestructureCFG/Utils.h index 9a9ae0da5..a2a1a5a72 100644 --- a/include/revng-c/RestructureCFG/Utils.h +++ b/include/revng-c/RestructureCFG/Utils.h @@ -133,11 +133,7 @@ using BasicBlockNodeTSet = typename BasicBlockNode::BBNodeSet; template inline bool alreadyOnStackQuick(BasicBlockNodeTSet &StackSet, BasicBlockNode *Node) { - if (StackSet.count(Node)) { - return true; - } else { - return false; - } + return StackSet.contains(Node); } template @@ -183,7 +179,7 @@ findReachableNodes(BasicBlockNode *Source, // computed a filtered post dominator tree, and the `nullptr` passed as // argument represents exactly the `VirtualRoot` node which acts as a sink // needed for the tree computation. - if ((Targets.count(Vertex) != 0) + if ((Targets.contains(Vertex)) or (Target == nullptr && Vertex->successor_size() == 0)) { for (auto StackE : Stack) { Targets.insert(StackE.first); @@ -205,7 +201,7 @@ findReachableNodes(BasicBlockNode *Source, BasicBlockNode *NextSuccessor = Vertex->getSuccessorI(Index); Index++; Stack.push_back(std::make_pair(Vertex, Index)); - if (VisitedEdges.count(std::make_pair(Vertex, NextSuccessor)) == 0 + if (not VisitedEdges.contains(std::make_pair(Vertex, NextSuccessor)) and NextSuccessor != Source and !alreadyOnStackQuick(StackSet, NextSuccessor)) { Stack.push_back(std::make_pair(NextSuccessor, 0)); diff --git a/include/revng-c/Support/IRHelpers.h b/include/revng-c/Support/IRHelpers.h index 42f72bd15..2982dffab 100644 --- a/include/revng-c/Support/IRHelpers.h +++ b/include/revng-c/Support/IRHelpers.h @@ -47,7 +47,7 @@ inline void pushInstructionALAP(llvm::DominatorTree &DT, revng_assert(CommonDominator != nullptr); for (Instruction &I : *CommonDominator) { - if (I.isTerminator() or Users.count(&I) != 0) { + if (I.isTerminator() or Users.contains(&I)) { ToMove->moveBefore(&I); return; } diff --git a/include/revng-c/Support/PTMLC.h b/include/revng-c/Support/PTMLC.h index 0c1e58df2..c417ae3b2 100644 --- a/include/revng-c/Support/PTMLC.h +++ b/include/revng-c/Support/PTMLC.h @@ -420,7 +420,7 @@ public: } std::string getLineComment(const llvm::StringRef Str) { - revng_check(Str.find("\n") == llvm::StringRef::npos); + revng_check(!Str.contains('\n')); return ptml::PTMLBuilder::tokenTag("// " + Str.str(), ptml::tokens::Comment) + "\n"; } diff --git a/lib/Backend/DecompileFunction.cpp b/lib/Backend/DecompileFunction.cpp index 852b91b48..87c45574a 100644 --- a/lib/Backend/DecompileFunction.cpp +++ b/lib/Backend/DecompileFunction.cpp @@ -2012,9 +2012,7 @@ void CCodeGenerator::emitFunction(bool NeedsLocalStateVar, auto VarTypeIt = TypeMap.find(VarToDeclare); if (VarTypeIt != TypeMap.end()) { - Out << getNamedCInstance(TypeMap.at(VarToDeclare), - VarName, - ThePTMLCBuilder) + Out << getNamedCInstance(VarTypeIt->second, VarName, ThePTMLCBuilder) << ";\n"; } else { // The only types that are allowed to be missing from the TypeMap diff --git a/lib/DataLayoutAnalysis/DLATypeSystem.cpp b/lib/DataLayoutAnalysis/DLATypeSystem.cpp index a2aecdc0f..502730049 100644 --- a/lib/DataLayoutAnalysis/DLATypeSystem.cpp +++ b/lib/DataLayoutAnalysis/DLATypeSystem.cpp @@ -478,8 +478,7 @@ bool LayoutTypeSystem::verifyConsistency() const { } // same edge with same tag - auto It = P.first->Successors.find({ NodePtr, P.second }); - if (It == P.first->Successors.end()) { + if (!P.first->Successors.contains({ NodePtr, P.second })) { if (VerifyDLALog.isEnabled()) revng_check(false); return false; @@ -493,8 +492,7 @@ bool LayoutTypeSystem::verifyConsistency() const { } // same edge with same tag - auto It = P.first->Predecessors.find({ NodePtr, P.second }); - if (It == P.first->Predecessors.end()) { + if (!P.first->Predecessors.contains({ NodePtr, P.second })) { if (VerifyDLALog.isEnabled()) revng_check(false); return false; @@ -560,7 +558,7 @@ bool LayoutTypeSystem::verifyDAG() const { std::set Visited; for (const auto &Node : llvm::nodes(this)) { revng_assert(Node != nullptr); - if (Visited.count(Node)) + if (Visited.contains(Node)) continue; using NonPointerFilterT = EdgeFilteredGraph Visited; for (const auto &Node : llvm::nodes(this)) { revng_assert(Node != nullptr); - if (Visited.count(Node)) + if (Visited.contains(Node)) continue; using GraphNodeT = const LayoutTypeSystemNode *; @@ -619,7 +617,7 @@ bool LayoutTypeSystem::verifyPointerDAG() const { std::set Visited; for (const auto &Node : llvm::nodes(this)) { revng_assert(Node != nullptr); - if (Visited.count(Node)) + if (Visited.contains(Node)) continue; using GraphNodeT = const LayoutTypeSystemNode *; @@ -662,7 +660,7 @@ bool LayoutTypeSystem::verifyInstanceAtOffset0DAG() const { std::set Visited; for (const auto &Node : llvm::nodes(this)) { revng_assert(Node != nullptr); - if (Visited.count(Node)) + if (Visited.contains(Node)) continue; using GraphNodeT = const LayoutTypeSystemNode *; diff --git a/lib/DataLayoutAnalysis/Middleend/CollapseSCC.cpp b/lib/DataLayoutAnalysis/Middleend/CollapseSCC.cpp index 17c609959..bbd05d621 100644 --- a/lib/DataLayoutAnalysis/Middleend/CollapseSCC.cpp +++ b/lib/DataLayoutAnalysis/Middleend/CollapseSCC.cpp @@ -44,7 +44,7 @@ static bool collapseSCCs(LayoutTypeSystem &TS) { for (const auto &Node : llvm::nodes(&TS)) { revng_assert(Node != nullptr); revng_log(LogVerbose, "## Analyzing SCCs from " << Node); - if (VisitedNodes.count(Node)) { + if (VisitedNodes.contains(Node)) { revng_log(LogVerbose, "## Was already visited"); continue; } @@ -53,7 +53,7 @@ static bool collapseSCCs(LayoutTypeSystem &TS) { llvm::scc_iterator E = llvm::scc_end(NodeT(Node)); for (const auto &SCC : llvm::make_range(I, E)) { revng_assert(not SCC.empty()); - if (VisitedNodes.count(SCC[0])) + if (VisitedNodes.contains(SCC[0])) continue; VisitedNodes.insert(SCC.begin(), SCC.end()); diff --git a/lib/DataLayoutAnalysis/Middleend/DLAPruneLayoutNodesWithoutLayout.cpp b/lib/DataLayoutAnalysis/Middleend/DLAPruneLayoutNodesWithoutLayout.cpp index 602250f81..b5ad61484 100644 --- a/lib/DataLayoutAnalysis/Middleend/DLAPruneLayoutNodesWithoutLayout.cpp +++ b/lib/DataLayoutAnalysis/Middleend/DLAPruneLayoutNodesWithoutLayout.cpp @@ -51,8 +51,8 @@ bool PruneLayoutNodesWithoutLayout::runOnTypeSystem(LayoutTypeSystem &TS) { using GT = GraphTraits; if (std::any_of(GT::child_begin(N), GT::child_end(N), - [&ToRemove](LTSN *Chld) { - return ToRemove.count(Chld) == 0; + [&ToRemove](LTSN *Child) { + return !ToRemove.contains(Child); })) { revng_log(Log, "### ChildHasLayout(N)!"); continue; diff --git a/lib/DataLayoutAnalysis/Middleend/DeduplicateFields.cpp b/lib/DataLayoutAnalysis/Middleend/DeduplicateFields.cpp index cb7847e41..d414c346f 100644 --- a/lib/DataLayoutAnalysis/Middleend/DeduplicateFields.cpp +++ b/lib/DataLayoutAnalysis/Middleend/DeduplicateFields.cpp @@ -510,7 +510,7 @@ bool DeduplicateFields::runOnTypeSystem(LayoutTypeSystem &TS) { // need to re-process it, hence we add it to FieldsToCompare, // then set NodeWithFieldsChanged, and remove it from // AnalyzedNodesNotMerged. - if (OriginalFields.count(PreservedNode)) { + if (OriginalFields.contains(PreservedNode)) { LoggerIndent MaxIndent{ Log }; revng_log(Log, "Is an original field. Re-enqueue it for " diff --git a/lib/DataLayoutAnalysis/Middleend/RemoveBackedges.cpp b/lib/DataLayoutAnalysis/Middleend/RemoveBackedges.cpp index 671835e09..63a6f972f 100644 --- a/lib/DataLayoutAnalysis/Middleend/RemoveBackedges.cpp +++ b/lib/DataLayoutAnalysis/Middleend/RemoveBackedges.cpp @@ -69,7 +69,7 @@ static bool removeBackedgesFromSCC(LayoutTypeSystem &TS) { std::set Visited; for (const auto &Node : llvm::nodes(&TS)) { revng_assert(Node != nullptr); - if (Visited.count(Node)) + if (Visited.contains(Node)) continue; auto I = llvm::scc_begin(typename SCC::SCCNodeView(Node)); @@ -289,7 +289,7 @@ static bool removeBackedgesFromSCC(LayoutTypeSystem &TS) { // We haven't pushed, either because NextChild is on the stack, or // because it was visited before. - if (InStack.count(NextChild)) { + if (InStack.contains(NextChild)) { // If it's on the stack, we're closing a loop. // Add all the cross color edges to the edges ToRemove. @@ -369,7 +369,7 @@ static bool removeBackedgesFromSCC(LayoutTypeSystem &TS) { std::set Visited; for (const auto &Node : llvm::nodes(&TS)) { revng_assert(Node != nullptr); - if (Visited.count(Node)) + if (Visited.contains(Node)) continue; auto I = llvm::scc_begin(MixedNodeT(Node)); diff --git a/lib/HeadersGeneration/ModelToHeader.cpp b/lib/HeadersGeneration/ModelToHeader.cpp index 60bf8deb8..2d66e45f7 100644 --- a/lib/HeadersGeneration/ModelToHeader.cpp +++ b/lib/HeadersGeneration/ModelToHeader.cpp @@ -73,7 +73,7 @@ static void printTypeDefinitions(const model::Binary &Model, for (const auto *Child : llvm::children(Node)) { revng_log(Log, "= child " << getNodeLabel(Child)); - if (Defined.count(Child)) + if (Defined.contains(Child)) revng_log(Log, " DEFINED"); else revng_log(Log, " NOT DEFINED"); diff --git a/lib/IRCanonicalization/MarkAssignments/MarkAssignments.cpp b/lib/IRCanonicalization/MarkAssignments/MarkAssignments.cpp index 2031adcec..4eb0bd85a 100644 --- a/lib/IRCanonicalization/MarkAssignments/MarkAssignments.cpp +++ b/lib/IRCanonicalization/MarkAssignments/MarkAssignments.cpp @@ -171,7 +171,7 @@ public: bool isPending(Instruction *Key) const { revng_assert(not IsBottom); - return TaintedPending.count(Key); + return TaintedPending.contains(Key); } public: diff --git a/lib/PromoteStackPointer/SegregateStackAccessesPass.cpp b/lib/PromoteStackPointer/SegregateStackAccessesPass.cpp index faebd87fd..17ce5b1d9 100644 --- a/lib/PromoteStackPointer/SegregateStackAccessesPass.cpp +++ b/lib/PromoteStackPointer/SegregateStackAccessesPass.cpp @@ -124,7 +124,7 @@ public: void recordSpan(const Span &Span, Value *BaseAddress) { auto Offset = BaseOffset + Span.Offset; - revng_assert(Map.count(Offset) == 0); + revng_assert(!Map.contains(Offset)); Map[Offset] = { Span.Size, BaseAddress }; revng_assert(verify()); diff --git a/lib/RestructureCFG/ASTNode.cpp b/lib/RestructureCFG/ASTNode.cpp index 82dfa70e5..ad7000ffe 100644 --- a/lib/RestructureCFG/ASTNode.cpp +++ b/lib/RestructureCFG/ASTNode.cpp @@ -35,12 +35,12 @@ IfNode *ContinueNode::getComputationIfNode() const { void IfNode::updateASTNodesPointers(ASTNodeMap &SubstitutionMap) { // Update the pointers to the `then` and `else` branches. if (hasThen()) { - revng_assert(SubstitutionMap.count(Then) != 0); + revng_assert(SubstitutionMap.contains(Then)); Then = SubstitutionMap[Then]; } if (hasElse()) { - revng_assert(SubstitutionMap.count(Else) != 0); + revng_assert(SubstitutionMap.contains(Else)); Else = SubstitutionMap[Else]; } } @@ -56,7 +56,7 @@ void SequenceNode::updateASTNodesPointers(ASTNodeMap &SubstitutionMap) { // Update all the pointers of the sequence node. for (auto NodeIt = NodeVec.begin(); NodeIt != NodeVec.end(); NodeIt++) { ASTNode *Node = *NodeIt; - revng_assert(SubstitutionMap.count(Node) != 0); + revng_assert(SubstitutionMap.contains(Node)); ASTNode *NewNode = SubstitutionMap[Node]; *NodeIt = NewNode; } diff --git a/lib/RestructureCFG/ASTTree.cpp b/lib/RestructureCFG/ASTTree.cpp index 00d7f9e70..a6552866e 100644 --- a/lib/RestructureCFG/ASTTree.cpp +++ b/lib/RestructureCFG/ASTTree.cpp @@ -135,7 +135,7 @@ ASTNode *ASTTree::copyASTNodesFrom(ASTTree &OldAST) { } } - revng_assert(ASTSubstitutionMap.count(OldAST.getRoot()) != 0); + revng_assert(ASTSubstitutionMap.contains(OldAST.getRoot())); return ASTSubstitutionMap[OldAST.getRoot()]; } diff --git a/lib/RestructureCFG/RestructureCFG.cpp b/lib/RestructureCFG/RestructureCFG.cpp index 9b62a6654..d54e94f64 100644 --- a/lib/RestructureCFG/RestructureCFG.cpp +++ b/lib/RestructureCFG/RestructureCFG.cpp @@ -154,7 +154,7 @@ mergeSCSAbnormalRetreating(MetaRegionBBVect &MetaRegions, MetaRegionBB &Region = *RegionIt; // Do not re-analyze blacklisted metaregions. - if (BlacklistedMetaregions.count(&Region) == 0) { + if (!BlacklistedMetaregions.contains(&Region)) { // Iterate over all the backedges present in the graph, if the current // region contains the source of a backedge, it should contain also the @@ -286,10 +286,10 @@ static MetaRegionBBPtrVect applyPartialOrder(MetaRegionBBVect &V) { while (V.size() != Processed.size()) { for (auto RegionIt1 = V.begin(); RegionIt1 != V.end(); RegionIt1++) { - if (Processed.count(&*RegionIt1) == 0) { + if (!Processed.contains(&*RegionIt1)) { bool FoundParent = false; for (auto RegionIt2 = V.begin(); RegionIt2 != V.end(); RegionIt2++) { - if ((RegionIt1 != RegionIt2) and Processed.count(&*RegionIt2) == 0) { + if ((RegionIt1 != RegionIt2) and !Processed.contains(&*RegionIt2)) { if ((*RegionIt1).getParent() == &*RegionIt2) { FoundParent = true; break; @@ -357,7 +357,7 @@ createMetaRegions(const std::set &Backedges) { do { OldNodes = Nodes; for (BasicBlockNodeBB *Node : Nodes) { - if ((Node != Head) and (AdditionalSCSNodes.count(Node) != 0)) { + if ((Node != Head) and (AdditionalSCSNodes.contains(Node))) { CombLogger << "Adding additional nodes for region with head: "; CombLogger << Head->getNameStr(); CombLogger << " and relative to node: "; @@ -818,7 +818,7 @@ bool restructureCFG(Function &F, ASTTree &AST) { // Handle outgoing edges from SCS nodes. for (const auto &[Successor, Labels] : Node->labeled_successors()) { - revng_assert(not Backedges.count(EdgeDescriptor(Node, Successor))); + revng_assert(not Backedges.contains(EdgeDescriptor(Node, Successor))); using ED = EdgeDescriptor; auto *NewEdgeSrc = ClonedMap.at(Node); auto *NewEdgeTgt = Successor; @@ -851,7 +851,7 @@ bool restructureCFG(Function &F, ASTTree &AST) { } // Are we moving a backedge with the first iteration outlining? - revng_assert(not Backedges.count({ Predecessor, Node })); + revng_assert(not Backedges.contains({ Predecessor, Node })); moveEdgeTarget(EdgeDescriptor(Predecessor, Node), ClonedMap.at(Node)); @@ -969,7 +969,7 @@ bool restructureCFG(Function &F, ASTTree &AST) { std::set OutEdges = Meta->getOutEdges(); for (EdgeDescriptor Edge : OutEdges) { // We should not be adding new backedges. - revng_assert(not Backedges.count(Edge)); + revng_assert(not Backedges.contains(Edge)); unsigned Idx = SuccessorsIdxMap.at(DeduplicationMap.at(Edge.second)); auto *IdxSetNode = RootCFG.addSetStateNode(Idx, Edge.second->getName()); diff --git a/lib/Support/IRHelpers.cpp b/lib/Support/IRHelpers.cpp index bc1d3041b..6da0d9fcd 100644 --- a/lib/Support/IRHelpers.cpp +++ b/lib/Support/IRHelpers.cpp @@ -79,7 +79,7 @@ getConstQualifiedExtractedValuesFromInstruction(T *I) { if (isCallToTagged(IdentUser, FunctionTags::Parentheses)) NextToVisit.insert(IdentUser); } else if (auto *PHIUser = llvm::dyn_cast(User)) { - if (not Visited.count(PHIUser)) + if (not Visited.contains(PHIUser)) NextToVisit.insert(PHIUser); } } diff --git a/lib/ValueManipulationAnalysis/ContractedGraph.h b/lib/ValueManipulationAnalysis/ContractedGraph.h index 87c125ad7..7b136a4f1 100644 --- a/lib/ValueManipulationAnalysis/ContractedGraph.h +++ b/lib/ValueManipulationAnalysis/ContractedGraph.h @@ -27,7 +27,7 @@ struct ContractedNode { /// Check if a TypeFlowNode is part of this super node bool contains(TypeFlowNode *TFN) const { - return InitialNodes.count(TFN) or AdditionalNodes.count(TFN); + return InitialNodes.contains(TFN) or AdditionalNodes.contains(TFN); } }; diff --git a/lib/ValueManipulationAnalysis/Mincut.cpp b/lib/ValueManipulationAnalysis/Mincut.cpp index 0842ec599..689d15fe7 100644 --- a/lib/ValueManipulationAnalysis/Mincut.cpp +++ b/lib/ValueManipulationAnalysis/Mincut.cpp @@ -82,7 +82,7 @@ static unsigned calcCost(ContractedGraph &G) { NodeColor.Bits.reset(G.Color.firstSetBit()); for (auto *Succ : TFGNode->successors()) { - if (Visited.count(Succ)) + if (Visited.contains(Succ)) continue; ColorSet CommonColors; diff --git a/lib/ValueManipulationAnalysis/TypeFlowGraph.cpp b/lib/ValueManipulationAnalysis/TypeFlowGraph.cpp index 386029a26..5edc2dc72 100644 --- a/lib/ValueManipulationAnalysis/TypeFlowGraph.cpp +++ b/lib/ValueManipulationAnalysis/TypeFlowGraph.cpp @@ -218,7 +218,7 @@ static ColorSet getAcceptedColors(FunctionMetadataCache &Cache, TypeFlowNode *TypeFlowGraph::addNodeContaining(FunctionMetadataCache &Cache, const UseOrValue &NC) { - revng_assert(not ContentToNodeMap.count(NC)); + revng_assert(not ContentToNodeMap.contains(NC)); NodeColorProperty InitialColors = { NO_COLOR, getAcceptedColors(Cache, NC, Model) }; @@ -456,7 +456,7 @@ TypeFlowGraph vma::makeTypeFlowGraphFromFunction(FunctionMetadataCache &Cache, // Add the Value node TypeFlowNode *InstNode; - if (TG.ContentToNodeMap.count(&I)) { + if (TG.ContentToNodeMap.contains(&I)) { // If the instruction has already been added, it must be because of a // phi revng_assert(any_of(I.users(), IsPhiInstr)); @@ -489,7 +489,7 @@ TypeFlowGraph vma::makeTypeFlowGraphFromFunction(FunctionMetadataCache &Cache, // The operand value should have already been visited, unless the // instruction is a phi or the operand is a non-instruction // (constant, global, arg). - if (not TG.ContentToNodeMap.count(Op.get())) { + if (not TG.ContentToNodeMap.contains(Op.get())) { revng_assert(I.getOpcode() == Instruction::PHI or not isa(Op.get())); TG.addNodeContaining(Cache, Op.get()); @@ -525,7 +525,7 @@ void vma::propagateColor(TypeFlowGraph &TG) { llvm::df_iterator_default_set Visited; for (auto *Node : TG.nodes()) { - bool AlreadyVisited = (Visited.find(Node) != Visited.end()); + bool AlreadyVisited = Visited.contains(Node); // Start from nodes that have only the desired color if (AlreadyVisited or not Node->getCandidates().contains(ColorSet(Filter))) continue; @@ -599,7 +599,7 @@ unsigned vma::countCasts(const TypeFlowGraph &TG) { for (const TypeFlowNode *Succ : TGNode->successors()) { // Ignore already visited nodes - if (Visited.count(Succ)) + if (Visited.contains(Succ)) continue; auto SuccBits = Succ->getCandidates().Bits;