[clang-format] Fix a bug in aligning comments above PPDirective (#72791)
[llvm-project.git] / clang / utils / analyze_safe_buffer_debug_notes.py
blobf0a6e4de6fdbe6b2e6e70128a195c30c586de122
1 import sys
2 from collections import OrderedDict
4 class Trie:
5 def __init__(self, name):
6 self.name = name
7 self.children = OrderedDict()
8 self.count = 1
10 def add(self, name):
11 if name in self.children:
12 self.children[name].count += 1
13 else:
14 self.children[name] = Trie(name)
15 return self.children[name]
17 def print(self, depth):
18 if depth > 0:
19 print('|', end="")
20 for i in range(depth):
21 print('-', end="")
22 if depth > 0:
23 print(end=" ")
24 print(self.name, '#', self.count)
25 for key, child in self.children.items():
26 child.print(depth + 1)
29 Root = Trie("Root")
31 if __name__ == "__main__":
32 for line in sys.stdin:
33 words = line.split('==>')
34 words = [word.strip() for word in words]
35 MyTrie = Root;
36 for word in words:
37 MyTrie = MyTrie.add(word)
39 Root.print(0)