Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / utils / graph_header_deps.py
blobbb5889f4e97796fda496116b82b74a12a19e476d
1 #!/usr/bin/env python
2 # ===----------------------------------------------------------------------===##
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 # ===----------------------------------------------------------------------===##
10 import argparse
11 import sys
13 if __name__ == "__main__":
14 """Converts a header dependency CSV file to Graphviz dot file.
16 The header dependency CSV files are found on the directory
17 libcxx/test/libcxx/transitive_includes
18 """
20 parser = argparse.ArgumentParser(
21 description="""Converts a libc++ dependency CSV file to a Graphviz dot file.
22 For example:
23 libcxx/utils/graph_header_deps.py libcxx/test/libcxx/transitive_includes/cxx20.csv | dot -Tsvg > graph.svg
24 """,
25 formatter_class=argparse.RawDescriptionHelpFormatter,
27 parser.add_argument(
28 "input",
29 default=None,
30 metavar="FILE",
31 help="The header dependency CSV file.",
33 options = parser.parse_args()
35 print(
36 """digraph includes {
37 graph [nodesep=0.5, ranksep=1];
38 node [shape=box, width=4];"""
40 with open(options.input, "r") as f:
41 for line in f.readlines():
42 elements = line.rstrip().split(" ")
43 assert len(elements) == 2
45 print(f'\t"{elements[0]}" -> "{elements[1]}"')
47 print("}")