[文档]classDominanceFrontier(Analysis):""" Computes the dominance frontier of all nodes in a function graph, and provides an easy-to-use interface for querying the frontier information. """
def_get_graph(self):ifself.func_graphisnotNone:returnself.func_graphreturnself.function.graph_ex(exception_edges=self._exception_edges)def_compute(self):g=self._get_graph()ifself.entryisnotNone:startpoint=self.entryelse:ifself.function.startpointisNone:# The function might be empty or is corrupted (maybe the object is created manually)raiseTypeError(f"Startpoint of function {self.function!r} is None. Is this function empty?")ifself.function.startpointnoting:# find the actual start pointstartpoint=next(iter(nnfornningifnn.addr==self.function.startpoint.addr),None)ifstartpointisNone:raiseValueError(f"Cannot find the startpoint of function {self.function!r} in the given function graph.")else:startpoint=self.function.startpoint# Compute the dominator treedoms=Dominators(g,startpoint)# Compute the dominance frontierdom_frontiers=compute_dominance_frontier(g,doms.dom)self.frontiers=dom_frontiers